content stringlengths 23 1.05M |
|---|
-- { dg-do run }
-- { dg-options "-O -gnatws" }
procedure Discr47 is
type Rec (D : Boolean := False) is record
case D is
when True => null;
when False => C : Character;
end case;
end record;
R : Rec;
begin
if R'Size /= 16 then
raise Program_Error;
end if;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- U S A G E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Hostparm;
with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with System.WCh_Con; use System.WCh_Con;
procedure Usage is
procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat");
-- Output two spaces followed by the switch character minus followed
-- Prefix, followed by the string given as the argument, and then
-- enough blanks to tab to column 13, i.e. assuming Sw is not longer
-- than 5 characters, the maximum allowed, Write_Switch_Char will
-- always output exactly 12 characters.
procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is
begin
Write_Str (" -");
Write_Str (Prefix);
Write_Str (Sw);
for J in 1 .. 12 - 3 - Prefix'Length - Sw'Length loop
Write_Char (' ');
end loop;
end Write_Switch_Char;
-- Start of processing for Usage
begin
Find_Program_Name;
-- For gnatmake, we are appending this information to the end of
-- the normal gnatmake output, so generate appropriate header
if Name_Len >= 8
and then (Name_Buffer (Name_Len - 7 .. Name_Len) = "gnatmake"
or else
Name_Buffer (Name_Len - 7 .. Name_Len) = "GNATMAKE")
then
Write_Eol;
Write_Line ("Compiler switches (passed to the compiler by gnatmake):");
else
-- Usage line
Write_Str ("Usage: ");
Write_Program_Name;
Write_Char (' ');
Write_Str ("switches sfile");
Write_Eol;
Write_Eol;
-- Line for sfile
Write_Line (" sfile Source file name");
end if;
Write_Eol;
-- Common GCC switches not available in JGNAT
if not Hostparm.Java_VM then
Write_Switch_Char ("fstack-check ", "");
Write_Line ("Generate stack checking code");
Write_Switch_Char ("fno-inline ", "");
Write_Line ("Inhibit all inlining (makes executable smaller)");
end if;
-- Common switches available to both GCC and JGNAT
Write_Switch_Char ("g ", "");
Write_Line ("Generate debugging information");
Write_Switch_Char ("Idir ", "");
Write_Line ("Specify source files search path");
Write_Switch_Char ("I- ", "");
Write_Line ("Do not look for sources in current directory");
Write_Switch_Char ("O[0123] ", "");
Write_Line ("Control the optimization level");
Write_Eol;
-- Individual lines for switches. Write_Switch_Char outputs fourteen
-- characters, so the remaining message is allowed to be a maximum
-- of 65 characters to be comfortable on an 80 character device.
-- If the Write_Str fits on one line, it is short enough!
-- Line for -gnata switch
Write_Switch_Char ("a");
Write_Line ("Assertions enabled. Pragma Assert/Debug to be activated");
-- Line for -gnatA switch
Write_Switch_Char ("A");
Write_Line ("Avoid processing gnat.adc, if present file will be ignored");
-- Line for -gnatb switch
Write_Switch_Char ("b");
Write_Line ("Generate brief messages to stderr even if verbose mode set");
-- Line for -gnatc switch
Write_Switch_Char ("c");
Write_Line ("Check syntax and semantics only (no code generation)");
-- Line for -gnatd switch
Write_Switch_Char ("d?");
Write_Line ("Compiler debug option ? ([.]a-z,A-Z,0-9), see debug.adb");
-- Line for -gnatD switch
Write_Switch_Char ("D");
Write_Line ("Debug expanded generated code rather than source code");
-- Line for -gnatec switch
Write_Switch_Char ("ec=?");
Write_Line ("Specify configuration pragmas file, e.g. -gnatec=/x/f.adc");
-- Line for -gnateD switch
Write_Switch_Char ("eD?");
Write_Line ("Define or redefine preprocessing symbol, e.g. -gnateDsym=val");
-- Line for -gnatef switch
Write_Switch_Char ("ef");
Write_Line ("Full source path in brief error messages");
-- Line for -gnateI switch
Write_Switch_Char ("eInn");
Write_Line ("Index in multi-unit source, e.g. -gnateI2");
-- Line for -gnatem switch
Write_Switch_Char ("em=?");
Write_Line ("Specify mapping file, e.g. -gnatem=mapping");
-- Line for -gnatep switch
Write_Switch_Char ("ep=?");
Write_Line ("Specify preprocessing data file, e.g. -gnatep=prep.data");
-- Line for -gnatE switch
Write_Switch_Char ("E");
Write_Line ("Dynamic elaboration checking mode enabled");
-- Line for -gnatf switch
Write_Switch_Char ("f");
Write_Line ("Full errors. Verbose details, all undefined references");
-- Line for -gnatF switch
Write_Switch_Char ("F");
Write_Line ("Force all import/export external names to all uppercase");
-- Line for -gnatg switch
Write_Switch_Char ("g");
Write_Line ("GNAT implementation mode (used for compiling GNAT units)");
-- Line for -gnatG switch
Write_Switch_Char ("G");
Write_Line ("Output generated expanded code in source form");
-- Line for -gnath switch
Write_Switch_Char ("h");
Write_Line ("Output this usage (help) information");
-- Line for -gnati switch
Write_Switch_Char ("i?");
Write_Line ("Identifier char set (?=1/2/3/4/5/8/9/p/f/n/w)");
-- Line for -gnatk switch
Write_Switch_Char ("k");
Write_Line ("Limit file names to nn characters (k = krunch)");
-- Line for -gnatl switch
Write_Switch_Char ("l");
Write_Line ("Output full source listing with embedded error messages");
-- Line for -gnatm switch
Write_Switch_Char ("mnn");
Write_Line ("Limit number of detected errors to nn (1-999999)");
-- Line for -gnatn switch
Write_Switch_Char ("n");
Write_Line ("Inlining of subprograms (apply pragma Inline across units)");
-- Line for -gnatN switch
Write_Switch_Char ("N");
Write_Line ("Full (frontend) inlining of subprograms");
-- Line for -gnato switch
Write_Switch_Char ("o");
Write_Line ("Enable overflow checking (off by default)");
-- Line for -gnatO switch
Write_Switch_Char ("O nm ");
Write_Line ("Set name of output ali file (internal switch)");
-- Line for -gnatp switch
Write_Switch_Char ("p");
Write_Line ("Suppress all checks");
-- Line for -gnatP switch
Write_Switch_Char ("P");
Write_Line ("Generate periodic calls to System.Polling.Poll");
-- Line for -gnatq switch
Write_Switch_Char ("q");
Write_Line ("Don't quit, try semantics, even if parse errors");
-- Line for -gnatQ switch
Write_Switch_Char ("Q");
Write_Line ("Don't quit, write ali/tree file even if compile errors");
-- Lines for -gnatR switch
Write_Switch_Char ("R?");
Write_Line ("List rep info (?=0/1/2/3 for none/types/all/variable)");
Write_Switch_Char ("R?s");
Write_Line ("List rep info to file.rep instead of standard output");
-- Lines for -gnats switch
Write_Switch_Char ("s");
Write_Line ("Syntax check only");
-- Lines for -gnatS switch
Write_Switch_Char ("S");
Write_Line ("Print listing of package Standard");
-- Lines for -gnatt switch
Write_Switch_Char ("t");
Write_Line ("Tree output file to be generated");
-- Line for -gnatT switch
Write_Switch_Char ("Tnn");
Write_Line ("All compiler tables start at nn times usual starting size");
-- Line for -gnatu switch
Write_Switch_Char ("u");
Write_Line ("List units for this compilation");
-- Line for -gnatU switch
Write_Switch_Char ("U");
Write_Line ("Enable unique tag for error messages");
-- Line for -gnatv switch
Write_Switch_Char ("v");
Write_Line ("Verbose mode. Full error output with source lines to stdout");
-- Line for -gnatV switch
Write_Switch_Char ("Vxx");
Write_Line
("Enable selected validity checking mode, xx = list of parameters:");
Write_Line (" a turn on all validity checking options");
Write_Line (" c turn on checking for copies");
Write_Line (" C turn off checking for copies");
Write_Line (" d turn on default (RM) checking");
Write_Line (" D turn off default (RM) checking");
Write_Line (" f turn on checking for floating-point");
Write_Line (" F turn off checking for floating-point");
Write_Line (" i turn on checking for in params");
Write_Line (" I turn off checking for in params");
Write_Line (" m turn on checking for in out params");
Write_Line (" M turn off checking for in out params");
Write_Line (" o turn on checking for operators/attributes");
Write_Line (" O turn off checking for operators/attributes");
Write_Line (" p turn on checking for parameters");
Write_Line (" P turn off checking for parameters");
Write_Line (" r turn on checking for returns");
Write_Line (" R turn off checking for returns");
Write_Line (" s turn on checking for subscripts");
Write_Line (" S turn off checking for subscripts");
Write_Line (" t turn on checking for tests");
Write_Line (" T turn off checking for tests");
Write_Line (" n turn off all validity checks (including RM)");
-- Lines for -gnatw switch
Write_Switch_Char ("wxx");
Write_Line ("Enable selected warning modes, xx = list of parameters:");
Write_Line (" a turn on all optional warnings (except d,h,l)");
Write_Line (" A turn off all optional warnings");
Write_Line (" b turn on warnings for bad fixed value " &
"(not multiple of small)");
Write_Line (" B* turn off warnings for bad fixed value " &
"(not multiple of small)");
Write_Line (" c turn on warnings for constant conditional");
Write_Line (" C* turn off warnings for constant conditional");
Write_Line (" d turn on warnings for implicit dereference");
Write_Line (" D* turn off warnings for implicit dereference");
Write_Line (" e treat all warnings as errors");
Write_Line (" f turn on warnings for unreferenced formal");
Write_Line (" F* turn off warnings for unreferenced formal");
Write_Line (" g* turn on warnings for unrecognized pragma");
Write_Line (" G turn off warnings for unrecognized pragma");
Write_Line (" h turn on warnings for hiding variable ");
Write_Line (" H* turn off warnings for hiding variable");
Write_Line (" i* turn on warnings for implementation unit");
Write_Line (" I turn off warnings for implementation unit");
Write_Line (" j turn on warnings for obsolescent " &
"(annex J) feature");
Write_Line (" J* turn off warnings for obsolescent " &
"(annex J) feature");
Write_Line (" k turn on warnings on constant variable");
Write_Line (" K* turn off warnings on constant variable");
Write_Line (" l turn on warnings for missing " &
"elaboration pragma");
Write_Line (" L* turn off warnings for missing " &
"elaboration pragma");
Write_Line (" m turn on warnings for variable assigned " &
"but not read");
Write_Line (" M* turn off warnings for variable assigned " &
"but not read");
Write_Line (" n* normal warning mode (cancels -gnatws/-gnatwe)");
Write_Line (" o* turn on warnings for address clause overlay");
Write_Line (" O turn off warnings for address clause overlay");
Write_Line (" p turn on warnings for ineffective pragma Inline");
Write_Line (" P* turn off warnings for ineffective pragma Inline");
Write_Line (" r turn on warnings for redundant construct");
Write_Line (" R* turn off warnings for redundant construct");
Write_Line (" s suppress all warnings");
Write_Line (" u turn on warnings for unused entity");
Write_Line (" U* turn off warnings for unused entity");
Write_Line (" v* turn on warnings for unassigned variable");
Write_Line (" V turn off warnings for unassigned variable");
Write_Line (" x* turn on warnings for export/import");
Write_Line (" X turn off warnings for export/import");
Write_Line (" y* turn on warnings for Ada 2005 incompatibility");
Write_Line (" Y turn off warnings for Ada 2005 incompatibility");
Write_Line (" z* turn on size/align warnings for " &
"unchecked conversion");
Write_Line (" Z turn off size/align warnings for " &
"unchecked conversion");
Write_Line (" * indicates default in above list");
-- Line for -gnatW switch
Write_Switch_Char ("W");
Write_Str ("Wide character encoding method (");
for J in WC_Encoding_Method loop
Write_Char (WC_Encoding_Letters (J));
if J = WC_Encoding_Method'Last then
Write_Char (')');
else
Write_Char ('/');
end if;
end loop;
Write_Eol;
-- Line for -gnatx switch
Write_Switch_Char ("x");
Write_Line ("Suppress output of cross-reference information");
-- Line for -gnatX switch
Write_Switch_Char ("X");
Write_Line ("Language extensions permitted");
-- Lines for -gnaty switch
Write_Switch_Char ("y");
Write_Line ("Enable default style checks (same as -gnaty3abcefhiklmnprst)");
Write_Switch_Char ("yxx");
Write_Line ("Enable selected style checks xx = list of parameters:");
Write_Line (" 1-9 check indentation");
Write_Line (" a check attribute casing");
Write_Line (" b check no blanks at end of lines");
Write_Line (" c check comment format");
Write_Line (" d check no DOS line terminators");
Write_Line (" e check end/exit labels present");
Write_Line (" f check no form feeds/vertical tabs in source");
Write_Line (" h check no horizontal tabs in source");
Write_Line (" i check if-then layout");
Write_Line (" I check mode in");
Write_Line (" k check casing rules for keywords");
Write_Line (" l check reference manual layout");
Write_Line (" Lnn check max nest level < nn ");
Write_Line (" m check line length <= 79 characters");
Write_Line (" n check casing of package Standard identifiers");
Write_Line (" Mnn check line length <= nn characters");
Write_Line (" o check subprogram bodies in alphabetical order");
Write_Line (" p check pragma casing");
Write_Line (" r check casing for identifier references");
Write_Line (" s check separate subprogram specs present");
Write_Line (" t check token separation rules");
Write_Line (" u check no unnecessary blank lines");
Write_Line (" x check extra parens around conditionals");
-- Lines for -gnatyN switch
Write_Switch_Char ("yN");
Write_Line ("Cancel all previously set style checks");
-- Lines for -gnatz switch
Write_Switch_Char ("z");
Write_Line ("Distribution stub generation (r/c for receiver/caller stubs)");
-- Line for -gnat83 switch
Write_Switch_Char ("83");
Write_Line ("Enforce Ada 83 restrictions");
-- Line for -gnat95 switch
Write_Switch_Char ("95");
if Ada_Version_Default = Ada_95 then
Write_Line ("Ada 95 mode (default)");
else
Write_Line ("Enforce Ada 95 restrictions");
end if;
-- Line for -gnat05 switch
Write_Switch_Char ("05");
if Ada_Version_Default = Ada_05 then
Write_Line ("Ada 2005 mode (default)");
else
Write_Line ("Allow Ada 2005 extensions");
end if;
end Usage;
|
-- 3-D gear wheels.
-- -----------------------------------------------------
-- A more simple version of this program was originaly
-- created in C by Brian Paul.
-- -----------------------------------------------------
-- Conversion to Ada + SDL, and extensions, written by:
-- Antonio F. Vargas - Ponta Delgada - Azores - Portugal
-- avargas@adapower.net
-- www.adapower.net/~avargas
-- -----------------------------------------------------
-- This program is in the public domain
-- -----------------------------------------------------
-- Command line options:
-- -info Print GL implementation information
-- (this is the original option).
-- -slow To slow down velocity under acelerated
-- hardware.
-- -window GUI window. Fullscreen is the default.
-- -nosound To play without sound.
-- -800x600 To create a video display of 800 by 600
-- the default mode is 640x480
-- -1024x768 To create a video display of 1024 by 768
-- -----------------------------------------------------
with Interfaces.C;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib;
with SDL.Video;
with SDL.Timer;
with SDL.Error;
with SDL.Events;
with SDL.Keyboard;
with SDL.Keysym;
with SDL.Types; use SDL.Types;
with SDL_Mixer;
with SDL.Audio;
with gl_h; use gl_h;
with AdaGL; use AdaGL;
procedure gears is
package CL renames Ada.Command_Line;
package C renames Interfaces.C;
use type C.unsigned;
use type C.int;
use type SDL.Init_Flags;
package Vd renames SDL.Video;
use type Vd.Surface_ptr;
use type Vd.Surface_Flags;
package Tm renames SDL.Timer;
package Er renames SDL.Error;
package Ev renames SDL.Events;
package Kb renames SDL.Keyboard;
package Ks renames SDL.Keysym;
package Au renames SDL.Audio;
use type Ks.SDLMod;
package Mix renames SDL_Mixer;
use type Mix.Chunk_ptr;
T0 : GLint := 0;
Frames : GLint := 0;
-- ===================================================================
-- Draw a gear wheel. You'll probably want to call this function when
-- building a display list since we do a lot of trig here.
-- Input: inner_radius - radius of hole at center
-- outer_radius - radius at center of teeth
-- width - width of gear
-- teeth - number of teeth
-- tooth_depth - depth of tooth
-- ===================================================================
procedure gear (
inner_radius : GLfloat;
outer_radius : GLfloat;
width : GLfloat;
teeth : GLint;
tooth_depth : GLfloat)
is
r0, r1, r2 : GLfloat;
angle, da : GLfloat;
u, v, len : GLfloat;
Pi : constant := Ada.Numerics.Pi;
package GLfloat_Math is new
Ada.Numerics.Generic_Elementary_Functions (GLfloat);
use GLfloat_Math;
begin
r0 := inner_radius;
r1 := outer_radius - tooth_depth / 2.0;
r2 := outer_radius + tooth_depth / 2.0;
da := 2.0 * Pi / GLfloat (teeth) / 4.0;
glShadeModel (GL_FLAT);
glNormal3f (0.0, 0.0, 1.0);
-- Draw front face
glBegin (GL_QUAD_STRIP);
for i in GLint range 0 .. teeth loop
angle := GLfloat (i) * 2.2 * Pi / GLfloat (teeth);
glVertex3f (r0 * Cos (angle), r0 * Sin (angle), width * 0.5);
glVertex3f (r1 * Cos (angle), r1 * Sin (angle), width * 0.5);
if i < teeth then
glVertex3f (r0 * Cos (angle), r0 * Sin (angle), width * 0.5);
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
width * 0.5);
end if;
end loop;
glEnd;
-- draw front sides of teeth
glBegin (GL_QUADS);
da := 2.0 * Pi / GLfloat (teeth) / 4.0;
for i in GLint range 0 .. teeth - 1 loop
angle := GLfloat (i) * 2.0 * Pi / GLfloat (teeth);
glVertex3f (r1 * Cos (angle), r1 * Sin (angle), width * 0.5);
glVertex3f (r2 * Cos (angle + da), r2 * Sin (angle + da), width * 0.5);
glVertex3f (r2 * Cos (angle + 2.0 * da),
r2 * Sin (angle + 2.0 * da),
width * 0.5);
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
width * 0.5);
end loop;
glEnd;
glNormal3f (0.0, 0.0, -1.0);
-- draw back face
glBegin (GL_QUAD_STRIP);
for i in GLint range 0 .. teeth loop
angle := GLfloat (i) * 2.0 * Pi / GLfloat (teeth);
glVertex3f (r1 * Cos (angle), r1 * Sin (angle), -width * 0.5);
glVertex3f (r0 * Cos (angle), r0 * Sin (angle), -width * 0.5);
if i < teeth then
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
-width * 0.5);
glVertex3f (r0 * Cos (angle),
r0 * Sin (angle),
-width * 0.5);
end if;
end loop;
glEnd;
-- draw back sides of teeth
glBegin (GL_QUADS);
da := 2.0 * Pi / GLfloat (teeth) /4.0;
for i in GLint range 0 .. teeth - 1 loop
angle := GLfloat (i) * 2.0 * Pi / GLfloat (teeth);
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
-width * 0.5);
glVertex3f (r2 * Cos (angle + 2.0 * da),
r2 * Sin (angle + 2.0 * da),
-width * 0.5);
glVertex3f (r2 * Cos (angle + da),
r2 * Sin (angle + da),
-width * 0.5);
glVertex3f (r1 * Cos (angle),
r1 * Sin (angle),
-width * 0.5);
end loop;
glEnd;
-- draw outward face of teeth
glBegin (GL_QUAD_STRIP);
for i in GLint range 0 .. teeth - 1 loop
angle := GLfloat (i) * 2.0 * Pi / GLfloat (teeth);
glVertex3f (r1 * Cos (angle), r1 * Sin (angle), width * 0.5);
glVertex3f (r1 * Cos (angle), r1 * Sin (angle), -width * 0.5);
u := r2 * Cos (angle + da) - r1 * Cos (angle);
v := r2 * Sin (angle + da) - r1 * Sin (angle);
len := Sqrt (u**2 + v**2);
u := u / len;
v := v / len;
glNormal3f (v, -u, 0.0);
glVertex3f (r2 * Cos (angle + da), r2 * Sin (angle + da), width * 0.5);
glVertex3f (r2 * Cos (angle + da), r2 * Sin (angle + da), -width * 0.5);
glNormal3f (Cos (angle), Sin (angle), 0.0);
glVertex3f (r2 * Cos (angle + 2.0 * da),
r2 * Sin (angle + 2.0 * da),
width * 0.5);
glVertex3f (r2 * Cos (angle + 2.0 * da),
r2 * Sin (angle + 2.0 * da),
-width * 0.5);
u := r1 * Cos (angle + 3.0 * da) - r2 * Cos (angle + 2.0 * da);
v := r1 * Sin (angle + 3.0 * da) - r2 * Sin (angle + 2.0 * da);
glNormal3f (v, -u, 0.0);
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
width * 0.5);
glVertex3f (r1 * Cos (angle + 3.0 * da),
r1 * Sin (angle + 3.0 * da),
-width * 0.5);
glNormal3f (Cos (angle), Sin (angle), 0.0);
end loop;
glVertex3f (r1 * Cos (0.0), r1 * Sin (0.0), width * 0.5);
glVertex3f (r1 * Cos (0.0), r1 * Sin (0.0), -width * 0.5);
glEnd;
glShadeModel (GL_SMOOTH);
-- draw inside radius cylinder
glBegin (GL_QUAD_STRIP);
for i in GLint range 0 .. teeth loop
angle := GLfloat (i) * 2.0 * Pi / GLfloat (teeth);
glNormal3f (-Cos (angle), -Sin (angle), 0.0);
glVertex3f (r0 * Cos (angle), r0 * Sin (angle), -width * 0.5);
glVertex3f (r0 * Cos (angle), r0 * Sin (angle), width * 0.5);
end loop;
glEnd;
end gear;
-- ===================================================================
view_rotx : GLfloat := 20.0;
view_roty : GLfloat := 30.0;
view_rotz : GLfloat := 0.0;
gear1, gear2, gear3 : GLuint;
angle : GLfloat := 0.0;
-- ===================================================================
procedure draw is
begin
glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glPushMatrix;
glRotatef (view_rotx, 1.0, 0.0, 0.0);
glRotatef (view_roty, 0.0, 1.0, 0.0);
glRotatef (view_rotz, 0.0, 0.0, 1.0);
glPushMatrix;
glTranslatef (-3.0, -2.0, 0.0);
glRotatef (angle, 0.0, 0.0, 1.0);
glCallList (gear1);
glPopMatrix;
glPushMatrix;
glTranslatef (3.1, -2.0, 0.0);
glRotatef (-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glCallList (gear2);
glPopMatrix;
glPushMatrix;
glTranslatef (-3.1, 4.2, 0.0);
glRotatef (-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList (gear3);
glPopMatrix;
glPopMatrix;
Vd.GL_SwapBuffers;
Frames := Frames + 1;
declare
t : GLint := GLint (Tm.GetTicks);
begin
if t - T0 >= 5000 then
declare
seconds : GLfloat := GLfloat (t - T0) / 1000.0;
fps : GLfloat := GLfloat (Frames) / seconds;
package GLfloat_IO is new Ada.Text_IO.Float_IO (GLfloat);
use GLfloat_IO;
begin
Put (GLint'Image (Frames) & " frames in ");
Put (seconds, 4, 2, 0); Put (" seconds = ");
Put (fps, 4, 2, 0); Put_Line (" FPS");
T0 := t;
Frames := 0;
end;
end if;
end; -- declare
end draw;
-- ===================================================================
procedure idle is
begin
angle := angle + 2.0;
end idle;
-- ===================================================================
-- New window size of exposure
procedure reshape (width : C.int; height : C.int) is
h : GLdouble := GLdouble (height) / GLdouble (width);
begin
glViewport (0, 0, GLint (width), GLint (height));
glMatrixMode (GL_PROJECTION);
glLoadIdentity;
glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity;
glTranslatef (0.0, 0.0, -40.0);
end reshape;
-- ===================================================================
procedure init (info : Boolean) is
pos : Four_GLfloat_Vector := (5.0, 5.0, 10.0, 0.0);
red : Four_GLfloat_Vector := (0.8, 0.1, 0.0, 1.0);
green : Four_GLfloat_Vector := (0.0, 0.8, 0.2, 1.0);
blue : Four_GLfloat_Vector := (0.2, 0.2, 1.0, 1.0);
begin
glLightfv (GL_LIGHT0, GL_POSITION, pos);
glEnable (GL_CULL_FACE);
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glEnable (GL_DEPTH_TEST);
-- make the gears
gear1 := glGenLists (1);
glNewList (gear1, GL_COMPILE);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear (1.0, 4.0, 1.0, 20, 0.7);
glEndList;
gear2 := glGenLists (1);
glNewList (gear2, GL_COMPILE);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear (0.5, 2.0, 2.0, 10, 0.7);
glEndList;
gear3 := glGenLists (1);
glNewList (gear3, GL_COMPILE);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear (1.3, 2.0, 0.5, 10, 0.7);
glEndList;
glEnable (GL_NORMALIZE);
if info then
Put_Line ("GL_RENDER = " & glGetString (GL_RENDER));
Put_Line ("GL_VERSION = " & glGetString (GL_VERSION));
Put_Line ("GL_VENDOR = " & glGetString (GL_VENDOR));
Put_Line ("GL_EXTENSIONS = " & glGetString (GL_EXTENSIONS));
end if;
end init;
-- ===================================================================
procedure Load_Sound (wave : in out Mix.Chunk_ptr; file : String) is
begin
wave := Mix.Load_WAV (file);
if wave = Mix.null_Chunk_ptr then
Put_Line ("Couldn't load " & file & ": " & Mix.Get_Error);
GNAT.OS_Lib.OS_Exit (2);
end if;
end Load_Sound;
-- ===================================================================
procedure Stop_Sound (wave : in out Mix.Chunk_ptr) is
begin
if wave /= Mix.null_Chunk_ptr then
Mix.FreeChunk (wave);
wave := Mix.null_Chunk_ptr;
end if;
end Stop_Sound;
-- ===================================================================
screen : Vd.Surface_ptr;
done : Boolean;
keys : Uint8_ptr;
Screen_Width : C.int := 640;
Screen_Hight : C.int := 480;
Slowly : Boolean := False;
Info : Boolean := False;
Full_Screen : Boolean := True;
Sound : Boolean := True;
argc : Integer := CL.Argument_Count;
Video_Flags : Vd.Surface_Flags := 0;
Initialization_Flags : SDL.Init_Flags := 0;
-- ===================================================================
procedure Manage_Command_Line is
begin
while argc > 0 loop
if CL.Argument (argc) = "-slow" then
Slowly := True;
argc := argc - 1;
elsif CL.Argument (argc) = "-window" then
Full_Screen := False;
argc := argc - 1;
elsif CL.Argument (argc) = "-1024x768" then
Screen_Width := 1024;
Screen_Hight := 768;
argc := argc - 1;
elsif CL.Argument (argc) = "-800x600" then
Screen_Width := 800;
Screen_Hight := 600;
argc := argc - 1;
elsif CL.Argument (argc) = "-info" then
Info := True;
argc := argc - 1;
elsif CL.Argument (argc) = "-nosound" then
Sound := False;
argc := argc - 1;
else
Put_Line ("Usage: " & CL.Command_Name & " " &
"[-slow] [-nosound] [-window] [-h] " &
"[[-800x600] | [-1024x768]]");
argc := argc - 1;
GNAT.OS_Lib.OS_Exit (0);
end if;
end loop;
end Manage_Command_Line;
-- ===================================================================
Gears_Working_Wave : Mix.Chunk_ptr := Mix.null_Chunk_ptr;
System_Rotation_Wave : Mix.Chunk_ptr := Mix.null_Chunk_ptr;
-- ===================================================================
procedure Initialize_Sound is
begin
if Sound then
if Mix.OpenAudio (22050, Au.AUDIO_S16, 2, 4096) < 0 then
Put_Line ("Couldn't open audio " & Mix.Get_Error);
GNAT.OS_Lib.OS_Exit (2);
end if;
Load_Sound (Gears_Working_Wave, "gears_working.wav");
Mix.PlayChannel (0, Gears_Working_Wave, -1);
Load_Sound (System_Rotation_Wave, "system_rotation.wav");
end if; -- Sound
end Initialize_Sound;
-- ===================================================================
procedure Main_System_Loop is
begin
while not done loop
declare
event : Ev.Event;
PollEvent_Result : C.int;
begin
idle;
loop
Ev.PollEventVP (PollEvent_Result, event);
exit when PollEvent_Result = 0;
case event.the_type is
when Ev.VIDEORESIZE =>
screen := Vd.SetVideoMode (
event.resize.w,
event.resize.h,
16,
Vd.OPENGL or Vd.RESIZABLE);
if screen /= null then
reshape (screen.w, screen.h);
else
-- Uh oh, we couldn't set the new video mode??
null;
end if;
when Ev.QUIT =>
done := True;
when others => null;
end case;
end loop;
keys := Kb.GetKeyState (null);
if Kb.Is_Key_Pressed (keys, Ks.K_ESCAPE) then
done := True;
end if;
if Kb.Is_Key_Pressed (keys, Ks.K_UP) then
view_rotx := view_rotx + 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
end if;
if Kb.Is_Key_Pressed (keys, Ks.K_DOWN) then
view_rotx := view_rotx - 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
end if;
if Kb.Is_Key_Pressed (keys, Ks.K_LEFT) then
view_roty := view_roty + 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
end if;
if Kb.Is_Key_Pressed (keys, Ks.K_RIGHT) then
view_roty := view_roty - 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
end if;
if Kb.Is_Key_Pressed (keys, Ks.K_z) then
if (Kb.GetModState and Ks.KMOD_SHIFT) /= 0 then
view_rotz := view_rotz - 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
else
view_rotz := view_rotz + 5.0;
Mix.PlayChannel (-1, System_Rotation_Wave, 0);
end if;
end if;
-- Allow the user what's happening
if Slowly then
Tm.SDL_Delay (23);
end if;
draw;
end; -- declare
end loop;
end Main_System_Loop;
-- ===================================================================
-- Gears Procedure body
-- ===================================================================
begin
Manage_Command_Line;
Initialization_Flags := SDL.INIT_VIDEO;
if Sound then
Initialization_Flags := Initialization_Flags or SDL.INIT_AUDIO;
end if;
if SDL.Init (Initialization_Flags) < 0 then
Put_Line ("Couldn't load SDL: " & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (1);
end if;
Video_Flags := Vd.OPENGL or Vd.RESIZABLE;
if Full_Screen then
Video_Flags := Video_Flags or Vd.FULLSCREEN;
end if;
screen := Vd.SetVideoMode (Screen_Width, Screen_Hight, 16, Video_Flags);
if screen = null then
Put_Line ("Couldn't set " & C.int'Image (Screen_Width) & "x" &
C.int'Image (Screen_Hight) & " GL video mode: " & Er.Get_Error);
SDL.SDL_Quit;
GNAT.OS_Lib.OS_Exit (2);
end if;
Vd.WM_Set_Caption ("Gears", "gears");
Initialize_Sound;
init (Info);
reshape (screen.w, screen.h);
done := False;
Main_System_Loop;
if Sound then
Stop_Sound (Gears_Working_Wave);
Mix.CloseAudio;
end if; -- Sound
SDL.SDL_Quit;
end gears;
|
--------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+owm@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Environment_Variables;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with GNATCOLL.JSON;
package body Open_Weather_Map.Client is
My_Debug : constant not null GNATCOLL.Traces.Trace_Handle :=
GNATCOLL.Traces.Create (Unit_Name => "OWM.CLIENT");
-----------------------------------------------------------------------------
-- Free
-----------------------------------------------------------------------------
procedure Free is
new Ada.Unchecked_Deallocation
(Object => AWS.Client.HTTP_Connection,
Name => AWS.Client.HTTP_Connection_Access);
type T_Local_Access is access all T;
-----------------------------------------------------------------------------
-- Free
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation (Object => T,
Name => T_Local_Access);
-----------------------------------------------------------------------------
-- Connection
-----------------------------------------------------------------------------
function Connection
(Self : in out T) return not null AWS.Client.HTTP_Connection_Access
is
use type Ada.Real_Time.Time;
Next_Allowed : constant Ada.Real_Time.Time := Self.Last_Access + Self.Rate_Limit;
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
My_Debug.all.Trace (Message => "Connection");
if Next_Allowed > Now then
My_Debug.all.Trace
(Message => "Connection: Rate limit exceeded, throttling...");
delay until Next_Allowed;
My_Debug.all.Trace (Message => "Connection: Rate limited.");
Self.Last_Access := Next_Allowed;
else
Self.Last_Access := Now;
end if;
return Self.HTTP_Connection;
end Connection;
-----------------------------------------------------------------------------
-- Create
-----------------------------------------------------------------------------
function Create
(Configuration : in GNATCOLL.JSON.JSON_Value;
Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit) return T_Access
is
Result : T_Access;
begin
My_Debug.all.Trace (Message => "Create");
begin
Result := new T;
Result.all.Initialize (Configuration => Configuration,
Rate_Limit => Rate_Limit);
return Result;
exception
when others =>
Destroy (Result);
raise;
end;
end Create;
-----------------------------------------------------------------------------
-- Destroy
-----------------------------------------------------------------------------
procedure Destroy (Self : in out T_Access) is
begin
if Self /= null then
Self.all.Finalize;
Free (T_Local_Access (Self));
end if;
end Destroy;
-----------------------------------------------------------------------------
-- Finalize
-----------------------------------------------------------------------------
overriding procedure Finalize (Self : in out T) is
begin
My_Debug.all.Trace (Message => "Finalize");
Free (Self.HTTP_Connection);
end Finalize;
-----------------------------------------------------------------------------
-- Initialize
-----------------------------------------------------------------------------
procedure Initialize
(Self : out T;
Configuration : in GNATCOLL.JSON.JSON_Value;
Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit)
is
-- Proxy information.
Network_Address : Ada.Strings.Unbounded.Unbounded_String;
User : Ada.Strings.Unbounded.Unbounded_String;
Password : Ada.Strings.Unbounded.Unbounded_String;
--------------------------------------------------------------------------
-- "+"
--------------------------------------------------------------------------
function "+"
(Source : in Ada.Strings.Unbounded.Unbounded_String) return String
renames Ada.Strings.Unbounded.To_String;
begin
My_Debug.all.Trace (Message => "Initialize");
Self.Rate_Limit := Rate_Limit;
Self.Last_Access := Ada.Real_Time.Time_First;
Get_Proxy_Information :
declare
use type Ada.Strings.Unbounded.Unbounded_String;
begin
-- TODO: Better error handling.
My_Debug.all.Trace
(Message => "Initialize: Loading proxy configuration...");
-- Try to get proxy URL from configuration file.
if
Configuration.Has_Field (Field => Config_Names.Field_Network_Address)
then
Network_Address :=
Configuration.Get (Field => Config_Names.Field_Network_Address);
end if;
-- If there's still no proxy URL, try to get it from the environment
-- variables.
if
Network_Address = AWS.Client.No_Data and then
Ada.Environment_Variables.Exists
(Name => Config_Names.Env_Network_Address)
then
Network_Address :=
Ada.Strings.Unbounded.To_Unbounded_String
(Source =>
Ada.Environment_Variables.Value
(Name => Config_Names.Env_Network_Address));
end if;
-- Proxy user and password are only useful if there actually is a
-- proxy.
if Network_Address /= AWS.Client.No_Data then
if Configuration.Has_Field (Field => Config_Names.Field_User) then
User := Configuration.Get (Field => Config_Names.Field_User);
-- Passwords only make sense if there's also a username.
if
Configuration.Has_Field (Field => Config_Names.Field_Password)
then
Password :=
Configuration.Get (Field => Config_Names.Field_Password);
end if;
end if;
end if;
My_Debug.all.Trace
(Message => "Initialize: Proxy configuration loaded.");
exception
when E : others =>
My_Debug.all.Trace
(E => E,
Msg => "Initialize: Error parsing configuration data: ");
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item =>
"Warning: Missing or invalid JSON data, " &
"proxy configuration may only be partial.");
end Get_Proxy_Information;
My_Debug.all.Trace
(Message =>
"Initialize: Proxy """ & (+Network_Address) & """" &
", user: """ & (+User) & """, password not shown.");
Create_Network_Connection :
begin
My_Debug.all.Trace
(Message => "Initialize: Creating network connection...");
Self.HTTP_Connection := new AWS.Client.HTTP_Connection'
(AWS.Client.Create
(Host => API_Host,
Proxy => +Network_Address,
Proxy_User => +User,
Proxy_Pwd => +Password,
Timeouts => AWS.Client.Timeouts (Each => 10.0)));
My_Debug.all.Trace
(Message => "Initialize: Network connection created.");
exception
when E : others =>
My_Debug.all.Trace
(E => E,
Msg => "Initialize: Error creating network connection: ");
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item => "Error: HTTP connection failed!");
end Create_Network_Connection;
end Initialize;
end Open_Weather_Map.Client;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M M A P . O S _ I N T E R F A C E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2007-2019, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- OS pecularities abstraction package for Win32 systems.
package System.Mmap.OS_Interface is
-- The Win package contains copy of definition found in recent System.Win32
-- unit provided with the GNAT compiler. The copy is needed to be able to
-- compile this unit with older compilers. Note that this internal Win
-- package can be removed when GNAT 6.1.0 is not supported anymore.
package Win is
subtype PVOID is Standard.System.Address;
type HANDLE is new Interfaces.C.ptrdiff_t;
type WORD is new Interfaces.C.unsigned_short;
type DWORD is new Interfaces.C.unsigned_long;
type LONG is new Interfaces.C.long;
type SIZE_T is new Interfaces.C.size_t;
type BOOL is new Interfaces.C.int;
for BOOL'Size use Interfaces.C.int'Size;
FALSE : constant := 0;
GENERIC_READ : constant := 16#80000000#;
GENERIC_WRITE : constant := 16#40000000#;
OPEN_EXISTING : constant := 3;
type OVERLAPPED is record
Internal : DWORD;
InternalHigh : DWORD;
Offset : DWORD;
OffsetHigh : DWORD;
hEvent : HANDLE;
end record;
type SECURITY_ATTRIBUTES is record
nLength : DWORD;
pSecurityDescriptor : PVOID;
bInheritHandle : BOOL;
end record;
type SYSTEM_INFO is record
dwOemId : DWORD;
dwPageSize : DWORD;
lpMinimumApplicationAddress : PVOID;
lpMaximumApplicationAddress : PVOID;
dwActiveProcessorMask : PVOID;
dwNumberOfProcessors : DWORD;
dwProcessorType : DWORD;
dwAllocationGranularity : DWORD;
wProcessorLevel : WORD;
wProcessorRevision : WORD;
end record;
type LP_SYSTEM_INFO is access all SYSTEM_INFO;
INVALID_HANDLE_VALUE : constant HANDLE := -1;
FILE_BEGIN : constant := 0;
FILE_SHARE_READ : constant := 16#00000001#;
FILE_ATTRIBUTE_NORMAL : constant := 16#00000080#;
FILE_MAP_COPY : constant := 1;
FILE_MAP_READ : constant := 4;
FILE_MAP_WRITE : constant := 2;
PAGE_READONLY : constant := 16#0002#;
PAGE_READWRITE : constant := 16#0004#;
INVALID_FILE_SIZE : constant := 16#FFFFFFFF#;
function CreateFile
(lpFileName : Standard.System.Address;
dwDesiredAccess : DWORD;
dwShareMode : DWORD;
lpSecurityAttributes : access SECURITY_ATTRIBUTES;
dwCreationDisposition : DWORD;
dwFlagsAndAttributes : DWORD;
hTemplateFile : HANDLE) return HANDLE;
pragma Import (Stdcall, CreateFile, "CreateFileW");
function WriteFile
(hFile : HANDLE;
lpBuffer : Standard.System.Address;
nNumberOfBytesToWrite : DWORD;
lpNumberOfBytesWritten : access DWORD;
lpOverlapped : access OVERLAPPED) return BOOL;
pragma Import (Stdcall, WriteFile, "WriteFile");
function ReadFile
(hFile : HANDLE;
lpBuffer : Standard.System.Address;
nNumberOfBytesToRead : DWORD;
lpNumberOfBytesRead : access DWORD;
lpOverlapped : access OVERLAPPED) return BOOL;
pragma Import (Stdcall, ReadFile, "ReadFile");
function CloseHandle (hObject : HANDLE) return BOOL;
pragma Import (Stdcall, CloseHandle, "CloseHandle");
function GetFileSize
(hFile : HANDLE; lpFileSizeHigh : access DWORD) return DWORD;
pragma Import (Stdcall, GetFileSize, "GetFileSize");
function SetFilePointer
(hFile : HANDLE;
lDistanceToMove : LONG;
lpDistanceToMoveHigh : access LONG;
dwMoveMethod : DWORD) return DWORD;
pragma Import (Stdcall, SetFilePointer, "SetFilePointer");
function CreateFileMapping
(hFile : HANDLE;
lpSecurityAttributes : access SECURITY_ATTRIBUTES;
flProtect : DWORD;
dwMaximumSizeHigh : DWORD;
dwMaximumSizeLow : DWORD;
lpName : Standard.System.Address) return HANDLE;
pragma Import (Stdcall, CreateFileMapping, "CreateFileMappingW");
function MapViewOfFile
(hFileMappingObject : HANDLE;
dwDesiredAccess : DWORD;
dwFileOffsetHigh : DWORD;
dwFileOffsetLow : DWORD;
dwNumberOfBytesToMap : SIZE_T) return Standard.System.Address;
pragma Import (Stdcall, MapViewOfFile, "MapViewOfFile");
function UnmapViewOfFile
(lpBaseAddress : Standard.System.Address) return BOOL;
pragma Import (Stdcall, UnmapViewOfFile, "UnmapViewOfFile");
procedure GetSystemInfo (lpSystemInfo : LP_SYSTEM_INFO);
pragma Import (Stdcall, GetSystemInfo, "GetSystemInfo");
end Win;
type System_File is record
Handle : Win.HANDLE;
Mapped : Boolean;
-- Whether mapping is requested by the user and available on the system
Mapping_Handle : Win.HANDLE;
Write : Boolean;
-- Whether this file can be written to
Length : File_Size;
-- Length of the file. Used to know what can be mapped in the file
end record;
type System_Mapping is record
Address : Standard.System.Address;
Length : File_Size;
end record;
Invalid_System_File : constant System_File :=
(Win.INVALID_HANDLE_VALUE, False, Win.INVALID_HANDLE_VALUE, False, 0);
Invalid_System_Mapping : constant System_Mapping :=
(Standard.System.Null_Address, 0);
function Open_Read
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return System_File;
-- Open a file for reading and return the corresponding System_File. Return
-- Invalid_System_File if unsuccessful.
function Open_Write
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return System_File;
-- Likewise for writing to a file
procedure Close (File : in out System_File);
-- Close a system file
function Read_From_Disk
(File : System_File;
Offset, Length : File_Size) return System.Strings.String_Access;
-- Read a fragment of a file. It is up to the caller to free the result
-- when done with it.
procedure Write_To_Disk
(File : System_File;
Offset, Length : File_Size;
Buffer : System.Strings.String_Access);
-- Write some content to a fragment of a file
procedure Create_Mapping
(File : System_File;
Offset, Length : in out File_Size;
Mutable : Boolean;
Mapping : out System_Mapping);
-- Create a memory mapping for the given File, for the area starting at
-- Offset and containing Length bytes. Store it to Mapping.
-- Note that Offset and Length may be modified according to the system
-- needs (for boudaries, for instance). The caller must cope with actually
-- wider mapped areas.
procedure Dispose_Mapping
(Mapping : in out System_Mapping);
-- Unmap a previously-created mapping
function Get_Page_Size return File_Size;
-- Return the number of bytes in a system page.
end System.Mmap.OS_Interface;
|
package body STR_Pack is
SCCS_ID : constant String := "@(#) str_pack.ada, Version 1.2";
Rcs_ID : constant String := "$Header: str_pack.a,v 0.1 86/04/01 15:13:01 ada Exp $";
function Upper_Case (S : in STR) return STR is
Upper_STR : STR (S.Name'Length) := S;
begin
for I in 1..S.Length loop
if S.Name(I) in 'a'..'z' then
Upper_STR.Name(I) := Character'Val(Character'Pos(S.Name(I)) -
Character'Pos('a') + Character'Pos('A'));
end if;
end loop;
return Upper_STR;
end Upper_Case;
function Lower_Case (S : in STR) return STR is
Lower_STR : STR (S.Name'Length) := S;
begin
for I in 1..S.Length loop
if S.Name(I) in 'A'..'Z' then
Lower_STR.Name(I) := Character'Val(Character'Pos(S.Name(I)) -
Character'Pos('A') + Character'Pos('a'));
end if;
end loop;
return Lower_STR;
end Lower_Case;
procedure Upper_Case(S: in out STR) is
begin
S := Upper_Case (S);
end Upper_Case;
procedure Lower_Case(S: in out STR) is
begin
S := Lower_Case (S);
end Lower_Case;
procedure Assign (Value: in STR; To: in out STR) is
begin
To := Value;
end Assign;
procedure Assign (Value: in String; To: in out STR) is
begin
To.Name(1..Value'Length) := Value;
To.Length := Value'Length;
end Assign;
procedure Assign (Value: in Character; To: in out STR) is
begin
To.Name(1) := Value;
To.Length := 1;
end Assign;
procedure Append (Tail: in STR; To: in out STR) is
F, L : Natural;
begin
F := To.Length + 1;
L := F + Tail.Length - 1;
To.Name(F..L) := Tail.Name(1..Tail.Length);
To.Length := L;
end Append;
procedure Append (Tail: in String; To: in out STR) is
F, L: Natural;
begin
F := To.Length + 1;
L := F + Tail'Length - 1;
To.Name(F .. L) := Tail;
To.Length := L;
end Append;
procedure Append (Tail: in Character; To: in out STR) is
begin
To.Length := To.Length + 1;
To.Name(To.Length) := Tail;
end Append;
function Length_of(S: STR) return Integer is
begin
return S.Length;
end Length_of;
function Value_of(S: STR) return String is
begin
return S.Name(1..S.Length);
end Value_of;
function Is_Empty(S: STR) return Boolean is
begin
return S.Length = 0;
end Is_Empty;
end STR_Pack;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Buffer_Package; use Buffer_Package;
package Utilities_Package is
type ERR_TYPE is (
ENDOFFILE,
NOBLOCKMARKED,
INVALIDEFUNCTIONNUMBER,
BEGINNINGOFLINE,
ENDOFLINE,
TOPOFFILE,
OUTOFMEMORY,
EMPTYCOMMAND,
COULDNOTOPENFILE,
COULDNOTOPENTEMPORARYFILE,
COULDNOTFORK,
NOPREVIOUSPOSITION,
INVALIDBOOKMARK,
BOOKMARKNOTSET,
CURSORINSIDEBLOCK,
INVALIDLINE,
INVALIDMAPPINGSPECIFICATION,
INVALIDPAGEHEIGHT,
NOBLOCKDEFINED,
INVALIDDELAYVALUE,
LEFTMARGINWOULDEXCEEDRIGHTMARGIN,
RIGHTMARINWOULDEXCEEDLEFTMARGIN,
INVALIDMARGIN,
SEARCHFAILED,
INVALIDTABWIDTH,
NOTHINGTOUNDO,
UNKNOWNCOMMAND);
type View is record
B : Buffer;
P : Pos;
GB : POS;
BS : Integer;
BE : Integer;
EX : Boolean;
Status_Callback : Boolean;
end record;
function Read_File
(Name : Unbounded_String; V : View) return Boolean;
end Utilities_Package;
|
package Opt38_Pkg is
procedure Test (I : Integer);
end Opt38_Pkg;
|
pragma License (Unrestricted);
-- runtime unit
package System.Unwind.Foreign is
pragma Preelaborate;
-- This is the substitute name of any exceptions propagated from any other
-- runtimes. (s-except.ads)
Foreign_Exception : exception
with Export,
Convention => Ada,
External_Name => "system__exceptions__foreign_exception";
end System.Unwind.Foreign;
|
with Ada.Characters.Latin_1;
package body afrl.cmasi.circle is
function getFullLmcpTypeName(this : Circle) return String is ("afrl.cmasi.circle.Circle");
function getLmcpTypeName(this : Circle) return String is ("Circle");
function getLmcpType(this : Circle) return UInt32_t is (CMASIEnum'Pos(CIRCLE_ENUM));
function getRadius(this : Circle'Class) return Float_t is (this.Radius);
procedure setRadius(this : out Circle'Class; Radius : in Float_t) is
begin
this.Radius := Radius;
end setRadius;
function getCenterPoint (this : Circle'Class) return Location3D_Acc is (this.CenterPoint);
procedure setCenterPoint(this : out Circle'Class; CenterPoint : in Location3D_Acc) is
begin
this.CenterPoint := CenterPoint;
end setCenterPoint;
function toString(this : Circle'Class; depth : Integer) return String is
begin
declare
depth_copy : Integer := depth;
UBS : Unbounded_String;
indent : Unbounded_String;
LF : Unbounded_String := To_Unbounded_String(String'(1 => Ada.Characters.Latin_1.LF));
begin
indent := To_Unbounded_String(String'(1 .. depth_copy*3 => ' '));
UBS := UBS & indent & "Object ( Circle ) {" & LF;
depth_copy := depth_copy + 1;
indent := To_Unbounded_String(String'(1 .. depth_copy*3 => ' '));
UBS := UBS & indent & "CenterPoint (Location3D)";
if(this.CenterPoint = null) then
UBS := UBS & " = null";
end if;
UBS := UBS & LF;
UBS := UBS & indent & "Radius (float) = " & To_Unbounded_String(this.Radius'Image) & LF;
depth_copy := depth_copy - 1;
return To_String(UBS);
end;
end toString;
end afrl.cmasi.circle;
|
with bmp_test_rgb24;
with bmp_test_indexed_1bit;
with bmp_test_indexed_2bits;
with bmp_test_indexed_4bits;
with bmp_test_indexed_8bits;
with bmp_test_rgb24_dma2d;
with bmp_test_indexed_1bit_dma2d;
with bmp_test_indexed_2bits_dma2d;
with bmp_test_indexed_4bits_dma2d;
with bmp_test_indexed_8bits_dma2d;
package body Test_Images is
----------
-- Draw --
----------
overriding procedure Draw
(This : in out Images_Window;
Ctx : in out Giza.Context.Class;
Force : Boolean := True)
is
X : Natural := 0;
Y : Natural := 0;
begin
Draw (Parent (This), Ctx, Force);
Ctx.Draw_Image (bmp_test_rgb24.Image, (X, Y));
X := X + bmp_test_rgb24.Image.Size.W;
Ctx.Draw_Image (bmp_test_rgb24_dma2d.Image.all, (X, Y));
X := 0;
Y := Y + bmp_test_rgb24_dma2d.Image.Size.H + 10;
Ctx.Draw_Image (bmp_test_indexed_8bits.Image, (X, Y));
X := X + bmp_test_indexed_8bits.Image.Size.W;
Ctx.Draw_Image (bmp_test_indexed_8bits_dma2d.Image.all, (X, Y));
X := 0;
Y := Y + bmp_test_indexed_8bits_dma2d.Image.Size.H + 10;
Ctx.Draw_Image (bmp_test_indexed_4bits.Image, (X, Y));
X := X + bmp_test_indexed_4bits.Image.Size.W;
Ctx.Draw_Image (bmp_test_indexed_4bits_dma2d.Image.all, (X, Y));
X := 0;
Y := Y + bmp_test_indexed_4bits_dma2d.Image.Size.H + 10;
Ctx.Draw_Image (bmp_test_indexed_2bits.Image, (X, Y));
X := X + bmp_test_indexed_2bits.Image.Size.W;
Ctx.Draw_Image (bmp_test_indexed_2bits_dma2d.Image.all, (X, Y));
X := 0;
Y := Y + bmp_test_indexed_2bits_dma2d.Image.Size.H + 10;
Ctx.Draw_Image (bmp_test_indexed_1bit.Image, (X, Y));
X := X + bmp_test_indexed_1bit.Image.Size.W;
Ctx.Draw_Image (bmp_test_indexed_1bit_dma2d.Image.all, (X, Y));
end Draw;
end Test_Images;
|
-- ----------------------------------------------------------------
-- text_read.adb
--
-- Sep/25/2011
--
-- ----------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure text_read is
Input : File_Type;
Line : String (1 .. 10_000);
Last : Natural;
file_text : String := Ada.Command_Line.Argument (1);
begin
Ada.Text_IO.Put_Line("*** 開始 ***");
Open (Input, In_File, file_text);
while not End_Of_File (Input) loop
Get_Line (Input,Line,Last);
Ada.Text_IO.Put_Line (Line (1 .. Last));
end loop;
Close (Input);
Ada.Text_IO.Put_Line("*** 終了 ***");
end text_read;
-- ----------------------------------------------------------------
|
with Datos;
use Datos;
function Media ( L : Lista ) return Float is
-- pre: Dada una lista, calcular la media de sus valores
-- post: La media de los valores de la lista Suma / longitud
numelementos : Natural;
acumulador : Float;
LCopia : Lista;
begin
numelementos := 0;
acumulador := 0.0;
LCopia := L;
while LCopia /= null loop
numelementos := numelementos+1;
acumulador := acumulador + Float(LCopia.all.info);
LCopia := LCopia.all.sig;
end loop;
return acumulador / Float(numelementos);
end Media;
|
--
-- 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.Containers.Vectors;
with Ada.Strings.Unbounded;
with Ada.Characters.Latin_1;
with Ada.Text_IO;
package body Macros is
function Is_Space (C : in Character) return Boolean;
-- True when C is a white space
use Ada.Strings.Unbounded;
package Macro_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Unbounded_String);
Macro_List : Macro_Vectors.Vector := Macro_Vectors.Empty_Vector;
procedure Append (Name : in String)
is
begin
Macro_List.Append (To_Unbounded_String (Name));
end Append;
procedure Preprocess (Buffer : in out String;
Success : out Boolean)
is
use Ada.Characters;
-- Preproc_Ifdef : constant String := "%ifdef";
-- Preproc_Ifndef : constant String := "%ifndef";
-- Preproc_Endif : constant String := "%endif";
I, J, N : Integer;
Exclude : Integer := 0;
Start : Integer := 0;
Lineno : Integer := 1;
Start_Lineno : Integer := 1;
begin
Success := False;
I := Buffer'First;
while Buffer (I) /= Latin_1.NUL loop
if Buffer (I) = Latin_1.LF then
Lineno := Lineno + 1;
end if;
if Buffer (I) /= '%' or (I > Buffer'First and then Buffer (I - 1) /= Latin_1.LF) then
goto Continue;
end if;
if Buffer (I .. I + 5) = "%endif" and Is_Space (Buffer (I + 6)) then
if Exclude /= 0 then
Exclude := Exclude - 1;
if Exclude = 0 then
for M in Start .. I - 1 loop
if Buffer (M) /= Latin_1.LF then
Buffer (M) := ' ';
end if;
end loop;
end if;
end if;
J := I;
while
Buffer (J) /= Latin_1.NUL and
Buffer (J) /= Latin_1.LF
loop
Buffer (J) := ' ';
J := J + 1;
end loop;
elsif
(Buffer (I .. I + 5) = "%ifdef" and Is_Space (Buffer (I + 6)))
or
(Buffer (I .. I + 6) = "%ifndef" and Is_Space (Buffer (I + 7)))
then
if Exclude = 0 then
J := I + 7;
while Is_Space (Buffer (J)) loop
J := J + 1;
end loop;
-- Find lenght of macro name
N := 0;
while
Buffer (J + N) /= Latin_1.NUL and
not Is_Space (Buffer (J + N))
loop
N := N + 1;
end loop;
-- Find macro name in list of appended macro names
Exclude := 1;
for Macro of Macro_List loop
if Buffer (J .. J + N) = Macro then
Exclude := 0;
exit;
end if;
end loop;
if Buffer (I + 3) = 'n' then
if Exclude = 0 then
Exclude := 1;
else
Exclude := 0;
end if;
end if;
if Exclude /= 0 then
Start := I;
Start_Lineno := Lineno;
end if;
else
Exclude := Exclude + 1;
end if;
J := I;
while
Buffer (J) /= Latin_1.NUL and
Buffer (J) /= Latin_1.LF
loop
Buffer (J) := ' ';
J := J + 1;
end loop;
end if;
<<Continue>>
I := I + 1;
end loop;
if Exclude /= 0 then
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"unterminated %%ifdef starting on line "
& Integer'Image (Start_Lineno));
Success := False;
return;
end if;
Success := True;
end Preprocess;
function Is_Space (C : in Character) return Boolean is
begin
return
C = Ada.Characters.Latin_1.Space or
C = Ada.Characters.Latin_1.HT or
C = Ada.Characters.Latin_1.LF;
end Is_Space;
end Macros;
|
pragma Warnings (Off);
pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__draw.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__draw.adb");
pragma Suppress (Overflow_Check);
package body ada_main is
E021 : Short_Integer; pragma Import (Ada, E021, "ada__real_time_E");
E087 : Short_Integer; pragma Import (Ada, E087, "system__tasking__protected_objects_E");
E091 : Short_Integer; pragma Import (Ada, E091, "system__tasking__protected_objects__multiprocessors_E");
E083 : Short_Integer; pragma Import (Ada, E083, "system__tasking__restricted__stages_E");
E013 : Short_Integer; pragma Import (Ada, E013, "bmp_fonts_E");
E143 : Short_Integer; pragma Import (Ada, E143, "cortex_m__cache_E");
E195 : Short_Integer; pragma Import (Ada, E195, "bitmap_color_conversion_E");
E149 : Short_Integer; pragma Import (Ada, E149, "hal__sdmmc_E");
E206 : Short_Integer; pragma Import (Ada, E206, "ft5336_E");
E212 : Short_Integer; pragma Import (Ada, E212, "hershey_fonts_E");
E210 : Short_Integer; pragma Import (Ada, E210, "bitmapped_drawing_E");
E169 : Short_Integer; pragma Import (Ada, E169, "ravenscar_time_E");
E147 : Short_Integer; pragma Import (Ada, E147, "sdmmc_init_E");
E197 : Short_Integer; pragma Import (Ada, E197, "soft_drawing_bitmap_E");
E193 : Short_Integer; pragma Import (Ada, E193, "memory_mapped_bitmap_E");
E100 : Short_Integer; pragma Import (Ada, E100, "stm32__adc_E");
E103 : Short_Integer; pragma Import (Ada, E103, "stm32__dac_E");
E109 : Short_Integer; pragma Import (Ada, E109, "stm32__dma__interrupts_E");
E178 : Short_Integer; pragma Import (Ada, E178, "stm32__dma2d_E");
E181 : Short_Integer; pragma Import (Ada, E181, "stm32__dma2d__interrupt_E");
E183 : Short_Integer; pragma Import (Ada, E183, "stm32__dma2d__polling_E");
E191 : Short_Integer; pragma Import (Ada, E191, "stm32__dma2d_bitmap_E");
E117 : Short_Integer; pragma Import (Ada, E117, "stm32__exti_E");
E187 : Short_Integer; pragma Import (Ada, E187, "stm32__fmc_E");
E123 : Short_Integer; pragma Import (Ada, E123, "stm32__i2c_E");
E134 : Short_Integer; pragma Import (Ada, E134, "stm32__power_control_E");
E113 : Short_Integer; pragma Import (Ada, E113, "stm32__rcc_E");
E131 : Short_Integer; pragma Import (Ada, E131, "stm32__rtc_E");
E157 : Short_Integer; pragma Import (Ada, E157, "stm32__spi_E");
E160 : Short_Integer; pragma Import (Ada, E160, "stm32__spi__dma_E");
E111 : Short_Integer; pragma Import (Ada, E111, "stm32__gpio_E");
E153 : Short_Integer; pragma Import (Ada, E153, "stm32__sdmmc_interrupt_E");
E127 : Short_Integer; pragma Import (Ada, E127, "stm32__i2s_E");
E115 : Short_Integer; pragma Import (Ada, E115, "stm32__syscfg_E");
E140 : Short_Integer; pragma Import (Ada, E140, "stm32__sdmmc_E");
E096 : Short_Integer; pragma Import (Ada, E096, "stm32__device_E");
E199 : Short_Integer; pragma Import (Ada, E199, "stm32__ltdc_E");
E165 : Short_Integer; pragma Import (Ada, E165, "stm32__sai_E");
E167 : Short_Integer; pragma Import (Ada, E167, "stm32__setup_E");
E172 : Short_Integer; pragma Import (Ada, E172, "wm8994_E");
E094 : Short_Integer; pragma Import (Ada, E094, "audio_E");
E204 : Short_Integer; pragma Import (Ada, E204, "touch_panel_ft5336_E");
E202 : Short_Integer; pragma Import (Ada, E202, "sdcard_E");
E185 : Short_Integer; pragma Import (Ada, E185, "stm32__sdram_E");
E176 : Short_Integer; pragma Import (Ada, E176, "framebuffer_ltdc_E");
E174 : Short_Integer; pragma Import (Ada, E174, "framebuffer_rk043fn48h_E");
E074 : Short_Integer; pragma Import (Ada, E074, "stm32__board_E");
E019 : Short_Integer; pragma Import (Ada, E019, "last_chance_handler_E");
E208 : Short_Integer; pragma Import (Ada, E208, "lcd_std_out_E");
E214 : Short_Integer; pragma Import (Ada, E214, "stm32__user_button_E");
procedure adainit is
procedure Start_Slave_CPUs;
pragma Import (C, Start_Slave_CPUs, "__gnat_start_slave_cpus");
begin
Ada.Real_Time'Elab_Body;
E021 := E021 + 1;
System.Tasking.Protected_Objects'Elab_Body;
E087 := E087 + 1;
System.Tasking.Protected_Objects.Multiprocessors'Elab_Body;
E091 := E091 + 1;
System.Tasking.Restricted.Stages'Elab_Body;
E083 := E083 + 1;
E013 := E013 + 1;
Cortex_M.Cache'Elab_Body;
E143 := E143 + 1;
E195 := E195 + 1;
HAL.SDMMC'ELAB_SPEC;
E149 := E149 + 1;
FT5336'ELAB_BODY;
E206 := E206 + 1;
E212 := E212 + 1;
E210 := E210 + 1;
Ravenscar_Time'Elab_Body;
E169 := E169 + 1;
E147 := E147 + 1;
Soft_Drawing_Bitmap'Elab_Body;
E197 := E197 + 1;
Memory_Mapped_Bitmap'Elab_Body;
E193 := E193 + 1;
STM32.ADC'ELAB_SPEC;
E100 := E100 + 1;
E103 := E103 + 1;
E109 := E109 + 1;
E178 := E178 + 1;
STM32.DMA2D.INTERRUPT'ELAB_BODY;
E181 := E181 + 1;
E183 := E183 + 1;
STM32.DMA2D_BITMAP'ELAB_SPEC;
STM32.DMA2D_BITMAP'ELAB_BODY;
E191 := E191 + 1;
E117 := E117 + 1;
E187 := E187 + 1;
STM32.I2C'ELAB_BODY;
E123 := E123 + 1;
E134 := E134 + 1;
E113 := E113 + 1;
STM32.RTC'ELAB_BODY;
E131 := E131 + 1;
STM32.SPI'ELAB_BODY;
E157 := E157 + 1;
STM32.SPI.DMA'ELAB_BODY;
E160 := E160 + 1;
STM32.GPIO'ELAB_BODY;
E111 := E111 + 1;
E153 := E153 + 1;
STM32.DEVICE'ELAB_SPEC;
E096 := E096 + 1;
STM32.SDMMC'ELAB_BODY;
E140 := E140 + 1;
STM32.I2S'ELAB_BODY;
E127 := E127 + 1;
E115 := E115 + 1;
STM32.LTDC'ELAB_BODY;
E199 := E199 + 1;
E165 := E165 + 1;
E167 := E167 + 1;
WM8994'ELAB_BODY;
E172 := E172 + 1;
Audio'Elab_Spec;
Framebuffer_Rk043fn48h'Elab_Body;
E174 := E174 + 1;
STM32.BOARD'ELAB_SPEC;
E074 := E074 + 1;
Sdcard'Elab_Body;
E202 := E202 + 1;
E185 := E185 + 1;
Framebuffer_Ltdc'Elab_Body;
E176 := E176 + 1;
Audio'Elab_Body;
E094 := E094 + 1;
Touch_Panel_Ft5336'Elab_Body;
E204 := E204 + 1;
E019 := E019 + 1;
Lcd_Std_Out'Elab_Body;
E208 := E208 + 1;
STM32.USER_BUTTON'ELAB_BODY;
E214 := E214 + 1;
Start_Slave_CPUs;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_draw");
procedure main is
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
adainit;
Ada_Main_Program;
end;
-- BEGIN Object file/option list
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/bmp_fonts.o
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/hershey_fonts.o
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/bitmapped_drawing.o
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/last_chance_handler.o
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/lcd_std_out.o
-- /home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/draw.o
-- -L/home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/
-- -L/home/gps/ada/adl/examples/shared/draw/obj/stm32f746disco/
-- -L/home/gps/ada/adl/examples/shared/common/
-- -L/home/gps/ada/adl/boards/stm32f746_discovery/lib/ravenscar-sfp-stm32f746disco/
-- -L/home/gps/ada/adl/arch/ARM/STM32/lib/stm32f7x/
-- -L/home/gps/ada/adl/hal/lib/
-- -L/home/gps/ada/adl/middleware/lib/
-- -L/home/gps/ada/adl/arch/ARM/cortex_m/lib/cortex-m7/
-- -L/home/gps/ada/adl/components/lib/
-- -L/usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f746disco/adalib/
-- -static
-- -lgnarl
-- -lgnat
-- END Object file/option list
end ada_main;
|
with Interfaces; use Interfaces;
package Types is
subtype Byte is Unsigned_8;
subtype Word is Unsigned_16;
subtype Address is Word range 0 .. 4095;
type Memory is array (Address) of Byte;
subtype Rom_Address is Word range 16#200# .. 16#FFF#;
type Rom is array (Rom_Address) of Byte;
type Registers is array (0 .. 15) of Byte;
-- Width: 64 -- Height: 32
type Screen_Array is array (0 .. 31, 0 .. 63) of Boolean;
type Keys_List is array (0 .. 15) of Boolean;
end Types;
|
with text_io, task_control;
use text_io, task_control;
procedure ptask is
-- y : duration := 0.0005;
package int_io is new integer_io (integer);
use int_io;
task looper is
end;
task body looper is
begin
for j in 1 .. 100 loop
put (j);
new_line;
end loop;
new_line;
put_line ("task integers complete");
new_line;
end;
task scooper is
end;
task body scooper is
begin
task_control.set_time_slice (0.001);
for k in 1..4 loop
for j in 'A'..'Z' loop
put (j);
new_line;
end loop;
new_line;
end loop;
put_line ("task letters complete");
new_line;
end;
begin -- ptask
task_control.pre_emption_on;
for x in 1000 ..1020 loop
-- task_control.set_time_slice (y);
-- y := y + y;
put(x);
new_line;
end loop;
put_line ("proc complete");
end ptask;
|
package OO_Privacy is
type Confidential_Stuff is tagged private;
subtype Password_Type is String(1 .. 8);
private
type Confidential_Stuff is tagged record
Password: Password_Type := "default!"; -- the "secret"
end record;
end OO_Privacy;
|
with Ada.Calendar;
with Ada.Strings.Unbounded;
package Utils is
type Local_Time is new Ada.Calendar.Time;
Timezone : Ada.Strings.Unbounded.Unbounded_String;
function Shift (S : String) return String;
function Unescape (S : String) return String;
procedure Warn (Text : String);
function Clean_Text (Source : String) return String;
function To_Time (Source : String) return Ada.Calendar.Time;
function To_String (N : Natural) return String;
function UTC_To_Local (T : Ada.Calendar.Time) return Local_Time;
function Get_Timezone return String;
end Utils;
|
package GStreamer is
pragma Linker_Options ("-lgstreamer-0.10");
pragma Linker_Options ("-lgobject-2.0");
pragma Linker_Options ("-lgmodule-2.0");
pragma Linker_Options ("-lgthread-2.0");
pragma Linker_Options ("-lglib-2.0");
pragma Linker_Options ("-lxml2");
end GStreamer;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Interpreter_Loop;
with Natools.S_Expressions.Templates.Generic_Discrete_Render;
with Natools.S_Expressions.Templates.Integers;
with Natools.Static_Maps.S_Expressions.Templates.Dates;
with Natools.Time_IO.RFC_3339;
package body Natools.S_Expressions.Templates.Dates is
package Commands renames Natools.Static_Maps.S_Expressions.Templates.Dates;
procedure Render_Day_Of_Week
is new Natools.S_Expressions.Templates.Generic_Discrete_Render
(Ada.Calendar.Formatting.Day_Name,
Ada.Calendar.Formatting.Day_Name'Image,
Ada.Calendar.Formatting."=");
procedure Append
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Value : in Split_Time;
Data : in Atom);
procedure Execute
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Value : in Split_Time;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class);
function Two_Digit_Image (Value : Integer) return Atom
is ((1 => Character'Pos ('0') + Octet (Value / 10),
2 => Character'Pos ('0') + Octet (Value mod 10)))
with Pre => Value in 0 .. 99;
function Four_Digit_Image (Value : Integer) return Atom
is ((1 => Character'Pos ('0') + Octet (Value / 1000),
2 => Character'Pos ('0') + Octet ((Value / 100) mod 10),
3 => Character'Pos ('0') + Octet ((Value / 10) mod 10),
4 => Character'Pos ('0') + Octet (Value mod 10)))
with Pre => Value in 0 .. 9999;
function Parse_Time_Offset
(Image : in String;
Date : in Ada.Calendar.Time)
return Ada.Calendar.Time_Zones.Time_Offset;
procedure Render_Triplet
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Part_1, Part_2, Part_3 : in Atom;
Template : in out Lockable.Descriptor'Class);
procedure Interpreter is new Interpreter_Loop
(Ada.Streams.Root_Stream_Type'Class, Split_Time, Execute, Append);
------------------------------
-- Local Helper Subprograms --
------------------------------
function Parse_Time_Offset
(Image : in String;
Date : in Ada.Calendar.Time)
return Ada.Calendar.Time_Zones.Time_Offset
is
function Value (C : Character)
return Ada.Calendar.Time_Zones.Time_Offset;
function Value (C : Character)
return Ada.Calendar.Time_Zones.Time_Offset is
begin
if C in '0' .. '9' then
return Ada.Calendar.Time_Zones.Time_Offset
(Character'Pos (C) - Character'Pos ('0'));
else
raise Constraint_Error with "Unknown time offset format";
end if;
end Value;
begin
if Image = "system" then
return Ada.Calendar.Time_Zones.UTC_Time_Offset (Date);
end if;
Abbreviation :
begin
return Ada.Calendar.Time_Zones.Time_Offset
(Static_Maps.S_Expressions.Templates.Dates.To_Time_Offset (Image));
exception
when Constraint_Error => null;
end Abbreviation;
Numeric :
declare
use type Ada.Calendar.Time_Zones.Time_Offset;
First : Integer := Image'First;
Length : Natural := Image'Length;
V : Ada.Calendar.Time_Zones.Time_Offset;
Negative : Boolean := False;
begin
if First in Image'Range and then Image (First) in '-' | '+' then
Negative := Image (First) = '-';
First := First + 1;
Length := Length - 1;
end if;
case Length is
when 1 =>
V := Value (Image (First)) * 60;
when 2 =>
V := Value (Image (First)) * 600
+ Value (Image (First + 1)) * 60;
when 4 =>
V := Value (Image (First)) * 600
+ Value (Image (First + 1)) * 60
+ Value (Image (First + 2)) * 10
+ Value (Image (First + 3));
when 5 =>
if Image (First + 2) in '0' .. '9' then
raise Constraint_Error with "Unknown time offset format";
end if;
V := Value (Image (First)) * 600
+ Value (Image (First + 1)) * 60
+ Value (Image (First + 3)) * 10
+ Value (Image (First + 4));
when others =>
raise Constraint_Error with "Unknown time offset format";
end case;
if Negative then
return -V;
else
return V;
end if;
end Numeric;
end Parse_Time_Offset;
procedure Render_Triplet
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Part_1, Part_2, Part_3 : in Atom;
Template : in out Lockable.Descriptor'Class) is
begin
Output.Write (Part_1);
if Template.Current_Event = Events.Add_Atom then
declare
Separator : constant Atom := Template.Current_Atom;
Event : Events.Event;
begin
Template.Next (Event);
Output.Write (Separator);
Output.Write (Part_2);
if Event = Events.Add_Atom then
Output.Write (Template.Current_Atom);
else
Output.Write (Separator);
end if;
end;
else
Output.Write (Part_2);
end if;
Output.Write (Part_3);
end Render_Triplet;
----------------------------
-- Interpreter Components --
----------------------------
procedure Append
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Value : in Split_Time;
Data : in Atom)
is
pragma Unreferenced (Value);
begin
Output.Write (Data);
end Append;
procedure Execute
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Value : in Split_Time;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
is
Format : Integers.Format;
begin
case Commands.Main (To_String (Name)) is
when Commands.Error =>
null;
when Commands.Big_Endian_Date =>
Render_Triplet
(Output,
Four_Digit_Image (Value.Year),
Two_Digit_Image (Value.Month),
Two_Digit_Image (Value.Day),
Arguments);
when Commands.Big_Endian_Time =>
Render_Triplet
(Output,
Two_Digit_Image (Value.Hour),
Two_Digit_Image (Value.Minute),
Two_Digit_Image (Value.Second),
Arguments);
when Commands.Day =>
Format.Set_Image (0, Null_Atom);
Integers.Render (Output, Format, Arguments, Value.Day);
when Commands.Day_Of_Week =>
Render_Day_Of_Week (Output, Arguments, Value.Day_Of_Week);
when Commands.Hour =>
Format.Set_Image (-1, Null_Atom);
Integers.Render (Output, Format, Arguments, Value.Hour);
when Commands.Little_Endian_Date =>
Render_Triplet
(Output,
Two_Digit_Image (Value.Day),
Two_Digit_Image (Value.Month),
Four_Digit_Image (Value.Year),
Arguments);
when Commands.Little_Endian_Time =>
Render_Triplet
(Output,
Two_Digit_Image (Value.Second),
Two_Digit_Image (Value.Minute),
Two_Digit_Image (Value.Hour),
Arguments);
when Commands.Minute =>
Format.Set_Image (-1, Null_Atom);
Integers.Render (Output, Format, Arguments, Value.Minute);
when Commands.Month =>
Format.Set_Image (0, Null_Atom);
Integers.Render (Output, Format, Arguments, Value.Month);
when Commands.Padded_Day =>
Format.Set_Image (0, Null_Atom);
Format.Set_Minimum_Width (2);
Format.Set_Left_Padding ((1 => Character'Pos ('0')));
Format.Set_Align (Integers.Right_Aligned);
Integers.Render (Output, Format, Arguments, Value.Day);
when Commands.Padded_Hour =>
Format.Set_Image (-1, Null_Atom);
Format.Set_Minimum_Width (2);
Format.Set_Left_Padding ((1 => Character'Pos ('0')));
Format.Set_Align (Integers.Right_Aligned);
Integers.Render (Output, Format, Arguments, Value.Hour);
when Commands.Padded_Minute =>
Format.Set_Image (-1, Null_Atom);
Format.Set_Minimum_Width (2);
Format.Set_Left_Padding ((1 => Character'Pos ('0')));
Format.Set_Align (Integers.Right_Aligned);
Integers.Render (Output, Format, Arguments, Value.Minute);
when Commands.Padded_Month =>
Format.Set_Image (0, Null_Atom);
Format.Set_Minimum_Width (2);
Format.Set_Left_Padding ((1 => Character'Pos ('0')));
Format.Set_Align (Integers.Right_Aligned);
Integers.Render (Output, Format, Arguments, Value.Month);
when Commands.Padded_Second =>
Format.Set_Image (-1, Null_Atom);
Format.Set_Minimum_Width (2);
Format.Set_Left_Padding ((1 => Character'Pos ('0')));
Format.Set_Align (Integers.Right_Aligned);
Integers.Render (Output, Format, Arguments, Value.Second);
when Commands.RFC_3339 =>
Output.Write (To_Atom
(Time_IO.RFC_3339.Image (Value.Source, Value.Time_Zone)));
when Commands.Second =>
Format.Set_Image (-1, Null_Atom);
Integers.Render (Output, Format, Arguments, Value.Second);
when Commands.With_Offset =>
if Arguments.Current_Event = Events.Add_Atom then
declare
use type Ada.Calendar.Time_Zones.Time_Offset;
New_Offset : Ada.Calendar.Time_Zones.Time_Offset;
begin
begin
New_Offset := Parse_Time_Offset
(S_Expressions.To_String (Arguments.Current_Atom),
Value.Source);
exception
when Constraint_Error => return;
end;
Arguments.Next;
if New_Offset = Value.Time_Zone then
Interpreter (Arguments, Output, Value);
else
Render (Output, Arguments, Value.Source, New_Offset);
end if;
end;
end if;
when Commands.Year =>
Integers.Render (Output, Arguments, Value.Year);
end case;
end Execute;
----------------------
-- Public Interface --
----------------------
function Split
(Value : Ada.Calendar.Time;
Time_Zone : Ada.Calendar.Time_Zones.Time_Offset)
return Split_Time
is
use type Ada.Calendar.Time_Zones.Time_Offset;
Zone_Offset : constant Ada.Calendar.Time_Zones.Time_Offset
:= Time_Zone - Ada.Calendar.Time_Zones.UTC_Time_Offset (Value);
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
Hour : Ada.Calendar.Formatting.Hour_Number;
Minute : Ada.Calendar.Formatting.Minute_Number;
Second : Ada.Calendar.Formatting.Second_Number;
Sub_Second : Ada.Calendar.Formatting.Second_Duration;
begin
Ada.Calendar.Formatting.Split
(Value,
Year, Month, Day,
Hour, Minute, Second,
Sub_Second,
Time_Zone);
return Split_Time'
(Source => Value,
Time_Zone => Time_Zone,
Year => Year,
Month => Month,
Day => Day,
Day_Of_Week => Ada.Calendar.Formatting.Day_Of_Week
(Ada.Calendar."+" (Value, 60 * Duration (Zone_Offset))),
Hour => Hour,
Minute => Minute,
Second => Second,
Sub_Second => Sub_Second);
end Split;
procedure Render
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Template : in out Lockable.Descriptor'Class;
Value : in Ada.Calendar.Time) is
begin
Render
(Output,
Template,
Value,
Ada.Calendar.Time_Zones.UTC_Time_Offset (Value));
end Render;
procedure Render
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Template : in out Lockable.Descriptor'Class;
Value : in Ada.Calendar.Time;
Time_Zone : Ada.Calendar.Time_Zones.Time_Offset) is
begin
Render (Output, Template, Split (Value, Time_Zone));
end Render;
procedure Render
(Output : in out Ada.Streams.Root_Stream_Type'Class;
Template : in out Lockable.Descriptor'Class;
Value : in Split_Time) is
begin
Interpreter (Template, Output, Value);
end Render;
end Natools.S_Expressions.Templates.Dates;
|
------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- SHA1 --
-- --
-- - "Reference" Implementation - --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018-2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Ensi Martini (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body Modular_Hashing.SHA1 is
pragma Assert (Stream_Element'Size = 8);
-- This implementation makes the assumption that a Stream_Element is 8 bits
-- wide. This is a safe assumption in most common applications. Making this
-- assumption greatly simplifies this reference implementation.
--
-- Internal Subprograms
--
------------------
-- Digest_Chunk --
------------------
-- This procedure is the internal digest that allows for a 512-bit block to
-- be processed without finishing the hash (padding)
--
-- This is the bulk of the SHA1 algorithm, missing only the addition of
-- message size with padding, which is handed by the Digest subprogram
procedure Digest_Chunk (Engine : in out SHA1_Engine) with Inline is
A, B, C, D, E, F, K, Temp : Unsigned_32;
Word_Sequence : array (1 .. 80) of Unsigned_32;
begin
-- Break the chunk into 16 32-bit words, assign to Word_Sequence
for I in 1 .. 16 loop
Word_Sequence(I) :=
Shift_Left(Value => Unsigned_32
(Engine.Buffer(Stream_Element_Offset((I * 4) - 3))),
Amount => 24)
+ Shift_Left(Value => Unsigned_32
(Engine.Buffer(Stream_Element_Offset((I * 4) - 2))),
Amount => 16)
+ Shift_Left(Value => Unsigned_32
(Engine.Buffer(Stream_Element_Offset((I * 4) - 1))),
Amount => 8)
+ Unsigned_32(Engine.Buffer(Stream_Element_Offset(I * 4)));
end loop;
-- Create the values for the rest of Word_Sequence
for I in 17 .. 80 loop
Word_Sequence(I) :=
Rotate_Left (Value =>
Word_Sequence(I - 3)
xor Word_Sequence(I - 8)
xor Word_Sequence(I - 14)
xor Word_Sequence(I - 16),
Amount => 1);
end loop;
A := Engine.H0;
B := Engine.H1;
C := Engine.H2;
D := Engine.H3;
E := Engine.H4;
declare
procedure Operations(Index : Integer) with Inline is
begin
Temp := Rotate_Left (Value => A, Amount => 5)
+ F + E + K + Word_Sequence(Index);
E := D;
D := C;
C := Rotate_Left (Value => B, Amount => 30);
B := A;
A := Temp;
end;
begin
-- The following loops are split-up to avoid persistent if-else
-- statements that is common in many reference implementations.
-- Inlining the operations takes up more code-space, but that is rarely
-- a concern in modern times...
for I in 1 .. 20 loop
F := (B and C) or ((not B) and D);
K := 16#5A827999#;
Operations (I);
end loop;
for I in 21 .. 40 loop
F := B xor C xor D;
K := 16#6ED9EBA1#;
Operations (I);
end loop;
for I in 41 .. 60 loop
F := (B and C) or (B and D) or (C and D);
K := 16#8F1BBCDC#;
Operations (I);
end loop;
for I in 61 .. 80 loop
F := B xor C xor D;
K := 16#CA62C1D6#;
Operations (I);
end loop;
end;
Engine.H0 := Engine.H0 + A;
Engine.H1 := Engine.H1 + B;
Engine.H2 := Engine.H2 + C;
Engine.H3 := Engine.H3 + D;
Engine.H4 := Engine.H4 + E;
Engine.Last_Element_Index := 0;
end Digest_Chunk;
--
-- SHA1_Hash
--
---------
-- "<" --
---------
function "<" (Left, Right: SHA1_Hash) return Boolean is
begin
-- Even though our numbers are split into arrays of Unsigned_32,
-- comparison operators can work on each section individually,
-- as the lower indices have more significance
for I in Message_Digest'Range loop
if Left.Digest(I) < Right.Digest(I) then
return True;
elsif Left.Digest(I) > Right.Digest(I) then
return False;
end if;
end loop;
-- The only way we get here is when Left = Right
return False;
end "<";
---------
-- ">" --
---------
function ">" (Left, Right: SHA1_Hash) return Boolean is
begin
-- Even though our numbers are split into arrays of Unsigned_32,
-- comparison operators can work on each section individually,
-- as the lower indices have more significance
for I in Message_Digest'Range loop
if Left.Digest(I) > Right.Digest(I) then
return True;
elsif Left.Digest(I) < Right.Digest(I) then
return False;
end if;
end loop;
-- The only way we get here is when Left = Right
return False;
end ">";
---------
-- "=" --
---------
function "=" (Left, Right: SHA1_Hash) return Boolean is
begin
for I in Message_Digest'Range loop
if Left.Digest(I) /= Right.Digest(I) then
return False;
end if;
end loop;
return True;
end "=";
------------
-- Binary --
------------
function Binary (Value: SHA1_Hash) return Hash_Binary_Value is
I: Positive;
Register: Unsigned_32;
begin
return Output: Hash_Binary_Value (1 .. SHA1_Hash_Bytes) do
I := Output'First;
for Chunk of reverse Value.Digest loop -- Value.Digest big-endian
Register := Chunk;
for J in 1 .. 4 loop -- Four bytes per digest chunk
Output(I) := Unsigned_8 (Register and 16#FF#);
Register := Shift_Right (Register, 8);
I := I + 1;
end loop;
end loop;
end return;
end Binary;
--
-- SHA1_Engine
--
-----------
-- Write --
-----------
overriding procedure Write (Stream : in out SHA1_Engine;
Item : in Stream_Element_Array)
is
Last_In: Stream_Element_Offset;
begin
-- Check for a null range of Item and discard
if Item'Length = 0 then
return;
end if;
Last_In := Item'First - 1;
-- Finally, we can go ahead and add the message length to the Engine now,
-- since there are early-ending code-paths below, and so we can avoid
-- duplicating code. The only way this can really go wrong is if the
-- entire message is larger than the Message_Size, which SHA1 limits to a
-- 64-bit signed integer. Therefore a message of 16 exabytes will cause
-- an invalid hash, due to a wrap-around of the Message_Size.
-- That's a risk we are willing to take.
Stream.Message_Length
:= Stream.Message_Length + (Stream_Element'Size * Item'Length);
-- Our buffer has a size of 512 (the size of a "chunk" of processing for
-- the SHA-1 algorithm).
-- Our write should be automated so that as soon as that buffer is full
-- (no matter how much of the Item array is written already), the chunk is
-- processed
-- In order to take advantage of any processor vector copy features, we
-- will explicitly copy Item in chunks that are either the full size of
-- Item, 64 elements, or the remaining space in the hash Buffer, whichever
-- is largest
while Last_In < Item'Last loop
declare
subtype Buffer_Slice is Stream_Element_Offset range
Stream.Last_Element_Index + 1 .. Stream.Buffer'Last;
Buffer_Slice_Length: Stream_Element_Offset
:= Buffer_Slice'Last - Buffer_Slice'First + 1;
subtype Item_Slice is Stream_Element_Offset range
Last_In + 1 .. Item'Last;
Item_Slice_Length: Stream_Element_Offset
:= Item_Slice'Last - Item_Slice'First + 1;
begin
if Buffer_Slice_Length > Item_Slice_Length then
-- We can fit the rest in the buffer, with space left-over
declare
-- Set-up a specific slice in the Buffer which can accommodate
-- the remaining elements of Item
subtype Target_Slice is Stream_Element_Offset range
Buffer_Slice'First .. Buffer_Slice'First +
(Item_Slice'Last - Item_Slice'First);
begin
-- Here is the block copy
Stream.Buffer(Target_Slice'Range):= Item (Item_Slice'Range);
Stream.Last_Element_Index := Target_Slice'Last;
end;
-- That's it, we've absorbed the entire Item, no need to waste
-- time updating Last_In.
return;
else
-- This means the buffer space is either equal to or smaller than
-- the remaining Item elements, this means we need process the
-- chunk (digest the buffer) no matter what
-- First step is to copy in as much of the remaining Item
-- elements as possible
declare
subtype Source_Slice is Stream_Element_Offset range
Item_Slice'First
.. Item_Slice'First + Buffer_Slice_Length - 1;
begin
-- Block copy
Stream.Buffer(Buffer_Slice'Range)
:= Item (Source_Slice'Range);
Stream.Last_Element_Index := Buffer_Slice'Last;
Last_In := Source_Slice'Last;
end;
-- Now we digest the currently full buffer
Digest_Chunk (Stream);
end if;
end;
end loop;
end Write;
-----------
-- Reset --
-----------
overriding procedure Reset (Engine : in out SHA1_Engine) is
begin
Engine.Last_Element_Index := 0;
Engine.Message_Length := 0;
Engine.H0 := H0_Initial;
Engine.H1 := H1_Initial;
Engine.H2 := H2_Initial;
Engine.H3 := H3_Initial;
Engine.H4 := H4_Initial;
end Reset;
------------
-- Digest --
------------
overriding function Digest (Engine : in out SHA1_Engine)
return Hash'Class is
-- The core of the message digest algorithm occurs in-line with stream
-- writes through the Digest_Chunk procedure. The role of this function
-- is to append the message size and padding, and then execute the final
-- Digest_Chunk before returning the digest.
-- We work with the data in the Buffer in chunks of 512 bits
-- Once we get to the last section that is < 512 bits, we append
-- the 64 bit length and padding 0's
-- In most cases, this 64 bit + padding will all be in the last section
-- of the buffer
-- We pad up until the 448th bit (56th byte) and then add the length
-- However, we must also keep in mind the fringe case where the data ends
-- at bit position 448 or later (byte 56 or later)
-- In that case, the approach to take is to pad the final chunk, then add
-- a new one that is ONLY padding and the 64 bit length
Message_Length_Spliced : Stream_Element_Array(1 .. 8);
Special_Case_Index : Stream_Element_Offset := 0;
begin
-- Splitting the 64-bit message length into array of bytes
for I in 1 .. 8 loop
Message_Length_Spliced(Stream_Element_Offset(I)) :=
Stream_Element
(Unsigned_8(Shift_Right(Value => Engine.Message_Length,
Amount => 8 * (8 - I)) and 16#ff#));
end loop;
-- This is a while loop but we use an exit condition to make sure that it
-- executes at least once (for the case of empty hash message)
loop
if Special_Case_Index /= 0 then
if Special_Case_Index = 1 then
Engine.Buffer(1) := 2#10000000#;
else
Engine.Buffer(1) := 2#00000000#;
end if;
Engine.Buffer(2 .. 56) := (others => 2#00000000#);
Engine.Buffer(57 .. 64) := Message_Length_Spliced;
Special_Case_Index := 0;
-- If there is less than 512 bits left in the Buffer
else
-- The case where one chunk will hold Buffer + padding + 64 bits
if Engine.Last_Element_Index < 56 then
-- Add the correct amount of padding
Engine.Buffer(Engine.Last_Element_Index + 1) := 2#10000000#;
Engine.Buffer(Engine.Last_Element_Index + 2 .. 56) :=
(others => 2#00000000#);
-- Finish it off with Message_Length
Engine.Buffer(57 .. 64) := Message_Length_Spliced;
-- The case where one chunk will hold Buffer + padding, and
-- another will hold padding + 64 bit message length
else
-- Put what we can of the padding in the current chunk
Engine.Buffer(Engine.Last_Element_Index + 1) := 2#10000000#;
Engine.Buffer(Engine.Last_Element_Index + 2 .. 64) :=
(others => 2#00000000#);
-- Save where we left off in the padding for the next chunk
Special_Case_Index := 65 - Engine.Last_Element_Index;
end if;
end if;
Digest_Chunk (Engine);
exit when Engine.Last_Element_Index = 0 and Special_Case_Index = 0;
end loop;
return Result: SHA1_Hash do
Result.Digest := (1 => Engine.H0,
2 => Engine.H1,
3 => Engine.H2,
4 => Engine.H3,
5 => Engine.H4);
Engine.Reset;
end return;
end Digest;
end Modular_Hashing.SHA1;
|
with Ada.Strings.Wide_Unbounded;
package Symbex.Lex is
type Lexer_t is private;
--
-- Token type.
--
type Token_Kind_t is
(Token_Quoted_String,
Token_Symbol,
Token_List_Open,
Token_List_Close,
Token_EOF);
type Line_Number_t is new Positive;
type Token_t is record
Is_Valid : Boolean;
Line_Number : Line_Number_t;
Kind : Token_Kind_t;
Text : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
end record;
--
-- Token value for incomplete or invalid tokens.
--
Invalid_Token : constant Token_t;
--
-- Lexer status value.
--
type Lexer_Status_t is
(Lexer_OK,
Lexer_Needs_More_Data,
Lexer_Error_Line_Overflow,
Lexer_Error_Out_Of_Memory,
Lexer_Error_Stream_Error,
Lexer_Error_Early_EOF);
--
-- Status values corresponding to error conditions.
--
subtype Lexer_Error_Status_t is Lexer_Status_t
range Lexer_Error_Line_Overflow .. Lexer_Status_t'Last;
--
-- Lexer is initialized?
--
function Initialized
(Lexer : in Lexer_t) return Boolean;
--
-- Initialize lexer state.
--
procedure Initialize_Lexer
(Lexer : out Lexer_t;
Status : out Lexer_Status_t);
-- pragma Postcondition
-- (((Status = Lexer_OK) and Initialized (Lexer)) or
-- ((Status /= Lexer_OK) and not Initialized (Lexer)));
--
-- Return token from Read_Item 'stream'.
--
type Stream_Status_t is
(Stream_OK,
Stream_EOF,
Stream_Error);
generic
with procedure Read_Item
(Item : out Wide_Character;
Status : out Stream_Status_t);
procedure Get_Token
(Lexer : in out Lexer_t;
Token : out Token_t;
Status : out Lexer_Status_t);
-- pragma Precondition (Initialized (Lexer));
-- pragma Postcondition
-- (((Status = Lexer_OK) and (Token /= Invalid_Token)) or
-- ((Status /= Lexer_OK) and (Token = Invalid_Token)));
private
package UBW_Strings renames Ada.Strings.Wide_Unbounded;
--
-- Lexer state machine.
--
type State_Stage_t is
(Inside_String,
Inside_Escape,
Inside_Comment);
type State_t is array (State_Stage_t) of Boolean;
type Input_Buffer_Position_t is (Current, Next);
type Input_Buffer_t is array (Input_Buffer_Position_t) of Wide_Character;
subtype Token_Buffer_t is UBW_Strings.Unbounded_Wide_String;
type Lexer_t is record
Inited : Boolean;
Current_Line : Line_Number_t;
Token_Buffer : Token_Buffer_t;
Input_Buffer : Input_Buffer_t;
State : State_t;
end record;
--
-- Token deferred.
--
Invalid_Token : constant Token_t :=
Token_t'(Is_Valid => False,
Line_Number => Line_Number_t'First,
Text => <>,
Kind => Token_Kind_t'First);
--
-- Character class.
--
type Character_Class_t is
(Comment_Delimiter,
Escape_Character,
Line_Break,
List_Close_Delimiter,
List_Open_Delimiter,
Ordinary_Text,
String_Delimiter,
Whitespace);
--
-- Utility subprograms.
--
procedure Set_State
(Lexer : in out Lexer_t;
State : in State_Stage_t);
pragma Precondition (not Lexer.State (State));
pragma Postcondition (Lexer.State (State));
procedure Unset_State
(Lexer : in out Lexer_t;
State : in State_Stage_t);
pragma Precondition (Lexer.State (State));
pragma Postcondition (not Lexer.State (State));
function State_Is_Set
(Lexer : in Lexer_t;
State : in State_Stage_t) return Boolean;
function Token_Is_Nonzero_Length
(Lexer : in Lexer_t) return Boolean;
procedure Complete_Token
(Lexer : in out Lexer_t;
Kind : in Token_Kind_t;
Token : out Token_t);
pragma Precondition (Token_Is_Nonzero_Length (Lexer));
-- pragma Postcondition
-- ((Token /= Invalid_Token) and (not Token_Is_Nonzero_Length (Lexer)));
end Symbex.Lex;
|
-- This package is intended to set up and tear down the test environment.
-- Once created by GNATtest, this package will never be overwritten
-- automatically. Contents of this package can be modified in any way
-- except for sections surrounded by a 'read only' marker.
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
with Config; use Config;
with Log; use Log;
package body Game.Test_Data is
procedure Set_Up(Gnattest_T: in out Test) is
pragma Unreferenced(Gnattest_T);
begin
if Data_Directory = To_Unbounded_String("../../bin/data/") then
return;
end if;
Data_Directory := To_Unbounded_String("../../bin/data/");
Save_Directory := To_Unbounded_String("../../bin/data/saves/");
Create_Path(To_String(Save_Directory));
Doc_Directory := To_Unbounded_String("../../bin/doc/");
Mods_Directory := To_Unbounded_String("../../bin/data/mods/");
Themes_Directory := To_Unbounded_String("../../bin/data/themes/");
Debug_Mode := EVERYTHING;
Start_Logging;
Load_Config;
declare
Message: constant String := Load_Game_Data;
begin
if Message'Length > 0 then
Put_Line("Can't load the game data. Reason: " & Message);
end if;
end;
New_Game_Settings.Player_Faction := To_Unbounded_String("POLEIS");
New_Game_Settings.Player_Career := To_Unbounded_String("general");
New_Game_Settings.Starting_Base := To_Unbounded_String("1");
New_Game;
end Set_Up;
procedure Tear_Down(Gnattest_T: in out Test) is
pragma Unreferenced(Gnattest_T);
begin
null;
end Tear_Down;
end Game.Test_Data;
|
with GESTE;
with GESTE.Grid;
pragma Style_Checks (Off);
package Game_Assets.character is
-- character
Width : constant := 2;
Height : constant := 4;
Tile_Width : constant := 16;
Tile_Height : constant := 16;
-- Down1
package Down1 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 243, 244, 245, 246),
( 247, 248, 249, 250)) ;
end Down1;
-- Down2
package Down2 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 251, 252, 253, 254),
( 255, 256, 257, 258)) ;
end Down2;
-- Down3
package Down3 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 259, 260, 261, 262),
( 263, 264, 265, 266)) ;
end Down3;
-- Left1
package Left1 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 267, 268, 269, 270),
( 271, 272, 273, 274)) ;
end Left1;
-- Left2
package Left2 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 275, 276, 277, 278),
( 279, 280, 281, 282)) ;
end Left2;
-- Left3
package Left3 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 283, 284, 285, 286),
( 287, 288, 289, 290)) ;
end Left3;
-- Right1
package Right1 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 291, 292, 293, 294),
( 295, 296, 297, 298)) ;
end Right1;
-- Right2
package Right2 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 299, 300, 301, 302),
( 303, 304, 305, 306)) ;
end Right2;
-- Right3
package Right3 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 307, 308, 309, 310),
( 311, 312, 313, 314)) ;
end Right3;
-- Up1
package Up1 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 315, 316, 317, 318),
( 319, 320, 321, 322)) ;
end Up1;
-- Up2
package Up2 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 323, 324, 325, 326),
( 327, 328, 329, 330)) ;
end Up2;
-- Up3
package Up3 is
Width : constant := 2;
Height : constant := 2;
Data : aliased GESTE.Grid.Grid_Data :=
(( 331, 332, 333, 334),
( 335, 336, 337, 338)) ;
end Up3;
end Game_Assets.character;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Characters.Conversions;
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Wide_Wide_Text_IO;
with LLVM.Core;
with Program.Compilations;
with Program.Error_Listeners;
with Program.Plain_Contexts;
with Program.Storage_Pools.Instance;
pragma Unreferenced (Program.Storage_Pools.Instance);
with Lace.LLVM_Contexts;
procedure Lace.Run is
type Error_Listener is new Program.Error_Listeners.Error_Listener
with null record;
Ctx : aliased Program.Plain_Contexts.Context;
Errors : aliased Error_Listener;
Context : Lace.LLVM_Contexts.LLVM_Context;
Done : Integer;
begin
Ada.Wide_Wide_Text_IO.Put_Line ("🎇 Hello!");
Ctx.Initialize (Errors'Unchecked_Access);
for J in 1 .. Ada.Command_Line.Argument_Count loop
declare
Arg : constant Wide_Wide_String :=
Ada.Characters.Conversions.To_Wide_Wide_String
(Ada.Command_Line.Argument (J));
begin
if Arg'Length > 2 and then Arg (1 .. 2) = "-I" then
Ctx.Add_Search_Directory (Arg (3 .. Arg'Last));
else
Ctx.Parse_File (Arg);
end if;
end;
end loop;
Ctx.Complete_Analysis;
Context.Context := LLVM.Core.Context_Create;
Context.Builder := LLVM.Core.Create_Builder_In_Context (Context.Context);
for Cursor in Ctx.Compilation_Unit_Bodies.Each_Unit loop
Context.Module := LLVM.Core.Module_Create_With_Name_In_Context
(Ada.Characters.Conversions.To_String
(Cursor.Unit.Compilation.Text_Name),
Context.Context);
-- For each body calculate a dummy property Done. As side effect it will
-- build LLVM representation in the Context.Module
Done := Context.LLVM_Int.Get_Property
(Cursor.Unit.Unit_Declaration, Lace.LLVM_Contexts.Done);
Ada.Text_IO.Put ("; Done=");
Ada.Text_IO.Put_Line (Done'Image);
-- Output LLVM code:
Ada.Text_IO.Put_Line (LLVM.Core.Print_Module_To_String (Context.Module));
end loop;
end Lace.Run;
|
------------------------------------------------------------------------------
-- --
-- FLORIST (FSU Implementation of POSIX.5) COMPONENTS --
-- --
-- P O S I X . P R O C E S S _ P R I M I T I V E S --
-- .Extensions --
-- --
-- B o d y --
-- --
-- --
-- Copyright (C) 1996-1997 Florida State University --
-- Copyright (C) 1998-2006 AdaCore --
-- Copyright (C) 2017 JSA Research & Innovation --
-- --
-- This file is a component of FLORIST, an implementation of an Ada API --
-- for the POSIX OS services, for use with the GNAT Ada compiler and --
-- the FSU Gnu Ada Runtime Library (GNARL). The interface is intended --
-- to be close to that specified in IEEE STD 1003.5: 1990 and IEEE STD --
-- 1003.5b: 1996. --
-- --
-- FLORIST 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. FLORIST 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 GNARL; see --
-- file COPYING. If not, write to the Free Software Foundation, 59 --
-- Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
------------------------------------------------------------------------------
with Ada.Directories;
with POSIX.Implementation,
POSIX.Unsafe_Process_Primitives,
Unchecked_Conversion;
package body POSIX.Process_Primitives.Extensions is
use POSIX.C,
POSIX.Implementation,
POSIX.Process_Identification;
C_File_Mode : constant array (POSIX.IO.File_Mode) of Bits :=
(POSIX.IO.Read_Only => O_RDONLY,
POSIX.IO.Write_Only => O_WRONLY,
POSIX.IO.Read_Write => O_RDWR);
-----------------------------
-- Unchecked Conversions --
-----------------------------
function To_int is new Unchecked_Conversion (Bits, int);
function To_String_List_Ptr is
new Unchecked_Conversion (POSIX_String_List, String_List_Ptr);
function To_Process_ID is new
Unchecked_Conversion (pid_t, Process_ID);
function To_pid_t is new
Unchecked_Conversion (Process_ID, pid_t);
-------------------------
-- Local Subprograms --
-------------------------
procedure Execute_Template (Template : Process_Template);
procedure Void (Ignore : int);
pragma Inline (Void);
procedure Void (Ignore : int) is
pragma Unreferenced (Ignore);
begin
null;
end Void;
function sigemptyset (set : sigset_t_ptr) return int;
pragma Import (C, sigemptyset, sigemptyset_LINKNAME);
function sigaddset (set : sigset_t_ptr; sig : POSIX.Signals.Signal)
return int;
pragma Import (C, sigaddset, sigaddset_LINKNAME);
function pthread_sigmask
(how : int;
set : sigset_t_ptr;
oset : sigset_t_ptr) return int;
pragma Import (C, pthread_sigmask, pthread_sigmask_LINKNAME);
procedure Check_Fatal (Result : int);
-- See comments in Execute_Template, below.
procedure Check_Fatal (Result : int) is
begin
if Result = -1 then
Exit_Process (Failed_Creation_Exit);
end if;
end Check_Fatal;
function getuid return uid_t;
pragma Import (C, getuid, getuid_LINKNAME);
function setuid (uid : uid_t) return int;
pragma Import (C, setuid, setuid_LINKNAME);
function getgid return gid_t;
pragma Import (C, getgid, getgid_LINKNAME);
function setgid (gid : gid_t) return int;
pragma Import (C, setgid, setgid_LINKNAME);
function close (fildes : int) return int;
pragma Import (C, close, close_LINKNAME);
function open (path : char_ptr; oflag : int) return int;
pragma Import (C, open, open_LINKNAME);
function dup2 (fildes, fildes2 : int) return int;
pragma Import (C, dup2, dup2_LINKNAME);
procedure Execute_Template (Template : Process_Template) is
FD1, FD2 : int;
Cur : FD_Set_Ptr := Template.FD_Set;
New_Mask, Old_Mask : aliased sigset_t;
begin
if not Template.Keep_Effective_IDs then
-- See note below why we do not call operations from
-- POSIX_Process_Identification, since they may raise
-- exceptions, and we worry about our ability to handle
-- them.
Check_Fatal (setuid (getuid));
Check_Fatal (setgid (getgid));
end if;
-- We cannot use signal masking operations from
-- POSIX.Signals, since they are implemented as
-- virtual operations, relative to the Ada task's
-- view of the signal interface. We normally keep
-- most signals masked in all tasks except the designated
-- signal handler threads, so that we can safely use
-- sigwait. During this situation, we have just forked
-- and we hope|expect there are no other threads active
-- in the new (child) process. Under these conditions
-- (only) it should be safe to use the raw signal masking
-- operations. In earlier versions, we used the almost-raw
-- versions, from System.Interrupt_Management.Operations.
-- These had the advantage that the Ada RTS has already
-- taken care of mapping to any nonstandard functions,
-- such as the Solaris 2.x thr_sigmask, versus the
-- POSIX.1c pthread_sigmask. However, more recent versions
-- of Unix operating systems do support the standard,
-- and in posi-signals.gpb we have already used some of
-- the raw C interfaces. In the current version, we have
-- gone over to completely avoiding calls to the Ada tasking
-- runtime system.
-- If an exception is raised during this time, the tasking
-- runtime system's data structures may "lie" about there
-- being other tasks active. This could prevent
-- orderly shutdown of the process. Hence, we use
-- Check_Fatal instead of the usual Check, and generally
-- try to avoid calling anything that could raise an
-- exception.
-- .... ????
-- The code below may not be robust against exceptions
-- that occur between fork and exec calls. There may be
-- a possibility of deadlock, if the fork occurred while some
-- other task is holding an RTS-internal lock that we need to
-- process exceptions.
-- The present approach is to avoid exceptions, by calling the
-- "raw" C interfaces below, and to replace the soft-links that are
-- used to set up exception-handling frames to use the nontasking
-- versions, since we may not be able to avoid those routines being
-- called. The soft links are switched inside the version of Fork
-- that we import from POSIX.Unsafe_Process_Primitives.
while Cur /= null loop
case Cur.Action is
when Close =>
Check_Fatal (close (int (Cur.FD)));
when Open =>
FD1 := open (Cur.File_Name (Cur.File_Name'First)'Unchecked_Access,
To_int (Option_Set (Cur.File_Options).Option
or C_File_Mode (Cur.File_Mode)));
if FD1 = -1 then
Exit_Process (Failed_Creation_Exit);
end if;
-- FD2 := dup2 (FD1, int (Cur.FD)); should be enough for the
-- following if/else statement. However, we have a mulfunction
-- under Linux when the two arguments are the same. The following
-- code is a workaround.
if FD1 /= int (Cur.FD) then
FD2 := dup2 (FD1, int (Cur.FD));
else
FD2 := FD1;
end if;
if FD2 = -1 then
Exit_Process (Failed_Creation_Exit);
end if;
when Duplicate =>
FD2 := dup2 (int (Cur.Dup_From), int (Cur.FD));
if FD2 = -1 then
Exit_Process (Failed_Creation_Exit);
end if;
end case;
Cur := Cur.Next;
end loop;
Void (sigemptyset (New_Mask'Unchecked_Access));
for Sig in 1 .. POSIX.Signals.Signal'Last loop
if POSIX.Signals.Is_Member (Template.Sig_Set, Sig) then
Void (sigaddset (New_Mask'Unchecked_Access, Sig));
end if;
end loop;
Void (pthread_sigmask (SIG_SETMASK, New_Mask'Unchecked_Access,
Old_Mask'Unchecked_Access));
-- ???? is pthread_sigmask OK after a fork?
-- sigprocmask is not safe in a multithreaded process, but after
-- the fork() call we are effectively in a single-threaded process,
-- so it might be better to use sigprocmask?
-- Void (sigprocmask (SIG_SETMASK, New_Mask'Unchecked_Access, null));
exception when others =>
Exit_Process (Failed_Creation_Exit);
-- Since this may not work, we have tried to avoid raising
-- any exceptions. However, in case we have missed something
-- and an exception is raised, we leave the handler here,
-- on the off-chance it might work.
end Execute_Template;
procedure Validate (Template : Process_Template);
procedure Validate (Template : Process_Template) is
begin
if Template.Is_Closed then
Raise_POSIX_Error (Invalid_Argument);
end if;
end Validate;
---------------------
-- Start_Process --
---------------------
function execvp
(file : char_ptr;
argv : char_ptr_ptr) return int;
pragma Import (C, execvp, execvp_LINKNAME);
function UFork return POSIX.Process_Identification.Process_ID
renames POSIX.Unsafe_Process_Primitives.Fork;
----------------------------
-- Start_Process_Search --
----------------------------
procedure Start_Process_Search
(Child : out POSIX.Process_Identification.Process_ID;
Filename : in POSIX.Filename;
Working_Directory : in String;
Template : in Process_Template;
Arg_List : in POSIX.POSIX_String_List :=
POSIX.Empty_String_List)
is
pid : pid_t;
Result : int;
pragma Unreferenced (Result);
Filename_With_NUL : POSIX_String := Filename & NUL;
Arg : String_List_Ptr := To_String_List_Ptr (Arg_List);
begin
if Arg = null then
Arg := Null_String_List_Ptr;
end if;
Validate (Template);
pid := To_pid_t (UFork); Check (int (pid));
if pid = 0 then -- child process
Ada.Directories.Set_Directory (Working_Directory);
Execute_Template (Template);
Result := execvp (Filename_With_NUL
(Filename_With_NUL'First)'Unchecked_Access, Arg.Char (1)'Access);
Exit_Process (Failed_Creation_Exit);
else
Child := To_Process_ID (pid);
end if;
end Start_Process_Search;
end POSIX.Process_Primitives.Extensions;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . G R A P H S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2018-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Compiler_Unit_Warning;
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
with GNAT.Lists; use GNAT.Lists;
with GNAT.Sets; use GNAT.Sets;
package GNAT.Graphs is
---------------
-- Component --
---------------
-- The following type denotes a strongly connected component handle
-- (referred to as simply "component") in a graph.
type Component_Id is new Natural;
No_Component : constant Component_Id := Component_Id'First;
function Hash_Component (Comp : Component_Id) return Bucket_Range_Type;
-- Map component Comp into the range of buckets
function Present (Comp : Component_Id) return Boolean;
-- Determine whether component Comp exists
---------------------
-- Directed_Graphs --
---------------------
-- The following package offers a directed graph abstraction with the
-- following characteristics:
--
-- * Dynamic resizing based on number of vertices and edges
-- * Creation of multiple instances, of different sizes
-- * Discovery of strongly connected components
-- * Iterable attributes
--
-- The following use pattern must be employed when operating this graph:
--
-- Graph : Directed_Graph := Create (<some size>, <some size>);
--
-- <various operations>
--
-- Destroy (Graph);
--
-- The destruction of the graph reclaims all storage occupied by it.
generic
--------------
-- Vertices --
--------------
type Vertex_Id is private;
-- The handle of a vertex
No_Vertex : Vertex_Id;
-- An indicator for a nonexistent vertex
with function Hash_Vertex (V : Vertex_Id) return Bucket_Range_Type;
-- Map vertex V into the range of buckets
with function Same_Vertex
(Left : Vertex_Id;
Right : Vertex_Id) return Boolean;
-- Compare vertex Left to vertex Right for identity
-----------
-- Edges --
-----------
type Edge_Id is private;
-- The handle of an edge
No_Edge : Edge_Id;
-- An indicator for a nonexistent edge
with function Hash_Edge (E : Edge_Id) return Bucket_Range_Type;
-- Map edge E into the range of buckets
with function Same_Edge
(Left : Edge_Id;
Right : Edge_Id) return Boolean;
-- Compare edge Left to edge Right for identity
package Directed_Graphs is
-- The following exceptions are raised when an attempt is made to add
-- the same edge or vertex in a graph.
Duplicate_Edge : exception;
Duplicate_Vertex : exception;
-- The following exceptions are raised when an attempt is made to delete
-- or reference a nonexistent component, edge, or vertex in a graph.
Missing_Component : exception;
Missing_Edge : exception;
Missing_Vertex : exception;
----------------------
-- Graph operations --
----------------------
-- The following type denotes a graph handle. Each instance must be
-- created using routine Create.
type Directed_Graph is private;
Nil : constant Directed_Graph;
procedure Add_Edge
(G : Directed_Graph;
E : Edge_Id;
Source : Vertex_Id;
Destination : Vertex_Id);
-- Add edge E to graph G which links vertex source Source and desination
-- vertex Destination. The edge is "owned" by vertex Source. This action
-- raises the following exceptions:
--
-- * Duplicate_Edge, when the edge is already present in the graph
--
-- * Iterated, when the graph has an outstanding edge iterator
--
-- * Missing_Vertex, when either the source or desination are not
-- present in the graph.
procedure Add_Vertex
(G : Directed_Graph;
V : Vertex_Id);
-- Add vertex V to graph G. This action raises the following exceptions:
--
-- * Duplicate_Vertex, when the vertex is already present in the graph
--
-- * Iterated, when the graph has an outstanding vertex iterator
function Component
(G : Directed_Graph;
V : Vertex_Id) return Component_Id;
-- Obtain the component where vertex V of graph G resides. This action
-- raises the following exceptions:
--
-- * Missing_Vertex, when the vertex is not present in the graph
function Contains_Component
(G : Directed_Graph;
Comp : Component_Id) return Boolean;
-- Determine whether graph G contains component Comp
function Contains_Edge
(G : Directed_Graph;
E : Edge_Id) return Boolean;
-- Determine whether graph G contains edge E
function Contains_Vertex
(G : Directed_Graph;
V : Vertex_Id) return Boolean;
-- Determine whether graph G contains vertex V
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive) return Directed_Graph;
-- Create a new graph with vertex capacity Initial_Vertices and edge
-- capacity Initial_Edges. This routine must be called at the start of
-- a graph's lifetime.
procedure Delete_Edge
(G : Directed_Graph;
E : Edge_Id);
-- Delete edge E from graph G. This action raises these exceptions:
--
-- * Iterated, when the graph has an outstanding edge iterator
--
-- * Missing_Edge, when the edge is not present in the graph
--
-- * Missing_Vertex, when the source vertex that "owns" the edge is
-- not present in the graph.
function Destination_Vertex
(G : Directed_Graph;
E : Edge_Id) return Vertex_Id;
-- Obtain the destination vertex of edge E of graph G. This action
-- raises the following exceptions:
--
-- * Missing_Edge, when the edge is not present in the graph
procedure Destroy (G : in out Directed_Graph);
-- Destroy the contents of graph G, rendering it unusable. This routine
-- must be called at the end of a graph's lifetime. This action raises
-- the following exceptions:
--
-- * Iterated, if the graph has any outstanding iterator
procedure Find_Components (G : Directed_Graph);
-- Find all components of graph G. This action raises the following
-- exceptions:
--
-- * Iterated, when the components or vertices of the graph have an
-- outstanding iterator.
function Is_Empty (G : Directed_Graph) return Boolean;
-- Determine whether graph G is empty
function Number_Of_Component_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Natural;
-- Obtain the total number of vertices of component Comp of graph G
function Number_Of_Components (G : Directed_Graph) return Natural;
-- Obtain the total number of components of graph G
function Number_Of_Edges (G : Directed_Graph) return Natural;
-- Obtain the total number of edges of graph G
function Number_Of_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Natural;
-- Obtain the total number of outgoing edges of vertex V of graph G
function Number_Of_Vertices (G : Directed_Graph) return Natural;
-- Obtain the total number of vertices of graph G
function Present (G : Directed_Graph) return Boolean;
-- Determine whether graph G exists
function Source_Vertex
(G : Directed_Graph;
E : Edge_Id) return Vertex_Id;
-- Obtain the source vertex that "owns" edge E of graph G. This action
-- raises the following exceptions:
--
-- * Missing_Edge, when the edge is not present in the graph
-------------------------
-- Iterator operations --
-------------------------
-- The following types represent iterators over various attributes of a
-- graph. Each iterator locks all mutation operations of its associated
-- attribute, and unlocks them once it is exhausted. The iterators must
-- be used with the following pattern:
--
-- Iter : Iterate_XXX (Graph);
-- while Has_Next (Iter) loop
-- Next (Iter, Element);
-- end loop;
--
-- It is possible to advance the iterators by using Next only, however
-- this risks raising Iterator_Exhausted.
-- The following type represents an iterator over all edges of a graph
type All_Edge_Iterator is private;
function Has_Next (Iter : All_Edge_Iterator) return Boolean;
-- Determine whether iterator Iter has more edges to examine
function Iterate_All_Edges (G : Directed_Graph) return All_Edge_Iterator;
-- Obtain an iterator over all edges of graph G
procedure Next
(Iter : in out All_Edge_Iterator;
E : out Edge_Id);
-- Return the current edge referenced by iterator Iter and advance to
-- the next available edge. This action raises the following exceptions:
--
-- * Iterator_Exhausted, when the iterator has been exhausted and
-- further attempts are made to advance it.
-- The following type represents an iterator over all vertices of a
-- graph.
type All_Vertex_Iterator is private;
function Has_Next (Iter : All_Vertex_Iterator) return Boolean;
-- Determine whether iterator Iter has more vertices to examine
function Iterate_All_Vertices
(G : Directed_Graph) return All_Vertex_Iterator;
-- Obtain an iterator over all vertices of graph G
procedure Next
(Iter : in out All_Vertex_Iterator;
V : out Vertex_Id);
-- Return the current vertex referenced by iterator Iter and advance
-- to the next available vertex. This action raises the following
-- exceptions:
--
-- * Iterator_Exhausted, when the iterator has been exhausted and
-- further attempts are made to advance it.
-- The following type represents an iterator over all components of a
-- graph.
type Component_Iterator is private;
function Has_Next (Iter : Component_Iterator) return Boolean;
-- Determine whether iterator Iter has more components to examine
function Iterate_Components
(G : Directed_Graph) return Component_Iterator;
-- Obtain an iterator over all components of graph G
procedure Next
(Iter : in out Component_Iterator;
Comp : out Component_Id);
-- Return the current component referenced by iterator Iter and advance
-- to the next component. This action raises the following exceptions:
--
-- * Iterator_Exhausted, when the iterator has been exhausted and
-- further attempts are made to advance it.
-- The following type prepresents an iterator over all vertices of a
-- component.
type Component_Vertex_Iterator is private;
function Has_Next (Iter : Component_Vertex_Iterator) return Boolean;
-- Determine whether iterator Iter has more vertices to examine
function Iterate_Component_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Component_Vertex_Iterator;
-- Obtain an iterator over all vertices that comprise component Comp of
-- graph G.
procedure Next
(Iter : in out Component_Vertex_Iterator;
V : out Vertex_Id);
-- Return the current vertex referenced by iterator Iter and advance to
-- the next vertex. This action raises the following exceptions:
--
-- * Iterator_Exhausted, when the iterator has been exhausted and
-- further attempts are made to advance it.
-- The following type represents an iterator over all outgoing edges of
-- a vertex.
type Outgoing_Edge_Iterator is private;
function Has_Next (Iter : Outgoing_Edge_Iterator) return Boolean;
-- Determine whether iterator Iter has more outgoing edges to examine
function Iterate_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Outgoing_Edge_Iterator;
-- Obtain an iterator over all the outgoing edges "owned" by vertex V of
-- graph G.
procedure Next
(Iter : in out Outgoing_Edge_Iterator;
E : out Edge_Id);
-- Return the current outgoing edge referenced by iterator Iter and
-- advance to the next available outgoing edge. This action raises the
-- following exceptions:
--
-- * Iterator_Exhausted, when the iterator has been exhausted and
-- further attempts are made to advance it.
private
pragma Unreferenced (No_Edge);
--------------
-- Edge_Map --
--------------
type Edge_Attributes is record
Destination : Vertex_Id := No_Vertex;
-- The target of a directed edge
Source : Vertex_Id := No_Vertex;
-- The origin of a directed edge. The source vertex "owns" the edge.
end record;
No_Edge_Attributes : constant Edge_Attributes :=
(Destination => No_Vertex,
Source => No_Vertex);
procedure Destroy_Edge_Attributes (Attrs : in out Edge_Attributes);
-- Destroy the contents of attributes Attrs
package Edge_Map is new Dynamic_Hash_Tables
(Key_Type => Edge_Id,
Value_Type => Edge_Attributes,
No_Value => No_Edge_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => Same_Edge,
Destroy_Value => Destroy_Edge_Attributes,
Hash => Hash_Edge);
--------------
-- Edge_Set --
--------------
package Edge_Set is new Membership_Sets
(Element_Type => Edge_Id,
"=" => "=",
Hash => Hash_Edge);
-----------------
-- Vertex_List --
-----------------
procedure Destroy_Vertex (V : in out Vertex_Id);
-- Destroy the contents of a vertex
package Vertex_List is new Doubly_Linked_Lists
(Element_Type => Vertex_Id,
"=" => Same_Vertex,
Destroy_Element => Destroy_Vertex);
----------------
-- Vertex_Map --
----------------
type Vertex_Attributes is record
Component : Component_Id := No_Component;
-- The component where a vertex lives
Outgoing_Edges : Edge_Set.Membership_Set := Edge_Set.Nil;
-- The set of edges that extend out from a vertex
end record;
No_Vertex_Attributes : constant Vertex_Attributes :=
(Component => No_Component,
Outgoing_Edges => Edge_Set.Nil);
procedure Destroy_Vertex_Attributes (Attrs : in out Vertex_Attributes);
-- Destroy the contents of attributes Attrs
package Vertex_Map is new Dynamic_Hash_Tables
(Key_Type => Vertex_Id,
Value_Type => Vertex_Attributes,
No_Value => No_Vertex_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => Same_Vertex,
Destroy_Value => Destroy_Vertex_Attributes,
Hash => Hash_Vertex);
-------------------
-- Component_Map --
-------------------
type Component_Attributes is record
Vertices : Vertex_List.Doubly_Linked_List := Vertex_List.Nil;
end record;
No_Component_Attributes : constant Component_Attributes :=
(Vertices => Vertex_List.Nil);
procedure Destroy_Component_Attributes
(Attrs : in out Component_Attributes);
-- Destroy the contents of attributes Attrs
package Component_Map is new Dynamic_Hash_Tables
(Key_Type => Component_Id,
Value_Type => Component_Attributes,
No_Value => No_Component_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => "=",
Destroy_Value => Destroy_Component_Attributes,
Hash => Hash_Component);
-----------
-- Graph --
-----------
type Directed_Graph_Attributes is record
All_Edges : Edge_Map.Dynamic_Hash_Table := Edge_Map.Nil;
-- The map of edge -> edge attributes for all edges in the graph
All_Vertices : Vertex_Map.Dynamic_Hash_Table := Vertex_Map.Nil;
-- The map of vertex -> vertex attributes for all vertices in the
-- graph.
Components : Component_Map.Dynamic_Hash_Table := Component_Map.Nil;
-- The map of component -> component attributes for all components
-- in the graph.
end record;
type Directed_Graph is access Directed_Graph_Attributes;
Nil : constant Directed_Graph := null;
---------------
-- Iterators --
---------------
type All_Edge_Iterator is new Edge_Map.Iterator;
type All_Vertex_Iterator is new Vertex_Map.Iterator;
type Component_Iterator is new Component_Map.Iterator;
type Component_Vertex_Iterator is new Vertex_List.Iterator;
type Outgoing_Edge_Iterator is new Edge_Set.Iterator;
end Directed_Graphs;
private
First_Component : constant Component_Id := No_Component + 1;
end GNAT.Graphs;
|
----------------------------------------
-- Copyright (C) 2019 Dmitriy Shadrin --
-- All rights reserved. --
----------------------------------------
with Pal;
with Logging_Message;
with ConfigTree;
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
package Sinks is
use all type Logging_Message.LogMessage;
package LogsVector is new Ada.Containers.Vectors (Pal.uint32_t, Logging_Message.LogMessage);
type LVectorPtr is access all LogsVector.Vector;
package LogsSP is new Pal.Smart_Ptr (TypeName => LogsVector.Vector, SharedObject => LVectorPtr);
subtype LogMessages is LogsSP.Shared_Ptr;
type ESinkType is ( CONSOLE_SINK, FILE_SINK );
for ESinkType'Size use Pal.uint8_t'Size;
type Sink is limited private;
function Channel (self : access Sink) return Logging_Message.LogChannel
with inline, pre => self /= null;
procedure WriteLogs (self : access Sink; logs : in LogMessages)
with pre => self /= null;
procedure Close (self : access Sink)
with pre => self /= null;
procedure MakeSink (self : out Sink; name : in String; cfg : in ConfigTree.NodePtr)
with pre => not ConfigTree.IsNull (cfg) and then cfg.GetName = "sink";
activeSinksCounter : aliased Pal.uint32_t := 0;
-----------------------------------------------------------------------------
task type SinkOutputer is
entry Write (logs : in LogMessages;
file : Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.Null_Unbounded_String);
entry Start (tag : ESinkType;
sev : Logging_Message.ESeverity;
ch : Logging_Message.LogChannel);
entry Stop;
end SinkOutputer;
type SinkOutputerPtr is access SinkOutputer;
private
type Sink is limited
record
SinkType : ESinkType;
severity : Logging_Message.ESeverity;
channel : Logging_Message.LogChannel;
template : Ada.Strings.Unbounded.Unbounded_String;
prefix : Ada.Strings.Unbounded.Unbounded_String;
suffix : Ada.Strings.Unbounded.Unbounded_String;
filename : Ada.Strings.Unbounded.Unbounded_String;
open_by_demand : Pal.bool;
handler : SinkOutputerPtr;
end record;
function MakeFilename (self : in out Sink) return Ada.Strings.Unbounded.Unbounded_String;
end Sinks;
|
--------------------------------------------------------------
--
-- This is a highlevel binding to the lm-sensors interface
--
---------------------------------------------------------------
with Ada.Strings.Unbounded;
private with Ada.Finalization;
private with Interfaces.C;
package Sensors is
Binding_Version : constant String := "3.5.0";
type Instance (<>) is tagged limited private;
function Get_Instance (Config_Path : String := "") return Instance;
type Bus_Id is record
Sensor_Type : Natural;
Nr : Natural;
end record;
type Chip_Name is tagged record
Prefix : Ada.Strings.Unbounded.Unbounded_String;
Bus : Bus_Id;
Addr : Integer;
Path : Ada.Strings.Unbounded.Unbounded_String;
end record ;
type Chips_Cursor (<>) is private;
type Chips_Iterator (<>) is tagged limited private with
Iterable => (First => First_Cursor,
Next => Advance,
Has_Element => Cursor_Has_Element,
Element => Get_Element);
function First_Cursor (Cont : Chips_Iterator) return Chips_Cursor;
function Advance (Cont : Chips_Iterator; Position : Chips_Cursor) return Chips_Cursor;
function Cursor_Has_Element (Cont : Chips_Iterator; Position : Chips_Cursor) return Boolean;
function Get_Element (Cont : Chips_Iterator; Position : Chips_Cursor) return Chip_Name'Class;
type Feature_Type is (FEATURE_IN,
FEATURE_FAN,
FEATURE_TEMP,
FEATURE_POWER,
FEATURE_ENERGY,
FEATURE_CURR,
FEATURE_HUMIDITY,
FEATURE_MAX_MAIN,
FEATURE_VID,
FEATURE_INTRUSION,
FEATURE_MAX_OTHER,
FEATURE_BEEP_ENABLE,
FEATURE_MAX,
FEATURE_UNKNOWN);
type Feature is record
Name : Ada.Strings.Unbounded.Unbounded_String;
Number : Natural;
Kind : Feature_Type;
First_Subfeature : Natural;
end record;
function Detected_Chips (Self : Instance) return Chips_Iterator'Class;
Sensors_Error : exception ;
function Version return String;
private
type Chips_Cursor (Ref : not null access Chips_Iterator) is record
I : aliased Interfaces.C.Int := 0;
end record;
type Instance is new Ada.Finalization.Limited_Controlled with record
null;
end record;
procedure Finalize (Object : in out Instance);
function Error_Image (Code : Interfaces.C.Int) return String;
type Chips_Iterator is new Ada.Finalization.Limited_Controlled with record
null;
end record;
end Sensors;
|
with
openGL.Palette;
package openGL.Light
--
-- Models a light.
--
is
type Item is tagged private;
type Items is array (Positive range <>) of Item;
--------------
--- Attributes
--
type Id_t is new Natural;
type Kind_t is (Diffuse, Direct);
null_Id : constant Id_t;
function Id (Self : in Item) return light.Id_t;
procedure Id_is (Self : in out Item; Now : in light.Id_t);
function Kind (Self : in Item) return light.Kind_t;
procedure Kind_is (Self : in out Item; Now : in light.Kind_t);
function is_On (Self : in Item) return Boolean;
procedure is_On (Self : in out Item; Now : in Boolean := True);
function Site (Self : in Item) return openGL.Site;
procedure Site_is (Self : in out Item; Now : in openGL.Site);
function Color (Self : in Item) return Color;
function Attenuation (Self : in Item) return Real;
function ambient_Coefficient (Self : in Item) return Real;
function cone_Angle (Self : in Item) return Degrees;
function cone_Direction (Self : in Item) return Vector_3;
procedure Color_is (Self : in out Item; Now : in openGL.Color);
procedure Attenuation_is (Self : in out Item; Now : in Real);
procedure ambient_Coefficient_is (Self : in out Item; Now : in Real);
procedure cone_Angle_is (Self : in out Item; Now : in Degrees);
procedure cone_Direction_is (Self : in out Item; Now : in Vector_3);
private
null_Id : constant Id_t := Id_t'First;
type Item is tagged
record
Id : light.Id_t := null_Id;
Kind : light.Kind_t := Direct;
On : Boolean := True;
Site : openGL.Site := (0.0, 0.0, 1.0); -- The GL default.
Color : openGL.Color := Palette.White;
Attenuation : Real := 0.1;
ambient_Coefficient : Real := 0.1;
cone_Angle : Degrees := 2.0;
cone_Direction : Vector_3 := (0.0, 0.0, -1.0);
end record;
end openGL.Light;
|
with Ada.Integer_Text_IO;
with Ada.Numerics.Elementary_Functions;
-- Copyright 2021 Melwyn Francis Carlo
procedure A044 is
use Ada.Integer_Text_IO;
use Ada.Numerics.Elementary_Functions;
Max_N : constant Integer := 5E3;
Min_Pd : Integer := 1E7;
P1, P2, P1pp2, P1mp2 : Integer;
Sqrt_term : Float;
begin
for I in 1 .. Max_N loop
P1 := Integer (Float'Floor (0.5E0 * Float (I)
* ((3.0E0 * Float (I)) - 1.0E0)));
for J in (I + 1) .. Max_N loop
P2 := Integer (Float'Floor ((0.5E0 * Float (J)
* ((3.0E0 * Float (J)) - 1.0E0))));
P1pp2 := P1 + P2;
Sqrt_term := Sqrt (1.0E0 + (24.0E0 * Float (P1pp2)));
if Sqrt_term = Float'Floor (Sqrt_term) then
if ((Integer (Sqrt_term) + 1) mod 6) = 0 then
P1mp2 := P2 - P1;
Sqrt_term := Sqrt (1.0E0 + (24.0E0 * Float (P1mp2)));
if Sqrt_term = Float'Floor (Sqrt_term) then
if ((Integer (Sqrt_term) + 1) mod 6) = 0 then
if P1mp2 < Min_Pd then
Min_Pd := P1mp2;
end if;
end if;
end if;
end if;
end if;
end loop;
end loop;
Put (Min_Pd, Width => 0);
end A044;
|
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Tk.Labelframe is
function Create
(Path_Name: Tk_Path_String; Options: Label_Frame_Create_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) return Tk_Label_Frame is
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "background", Value => Options.Background,
Options_String => Options_String);
Option_Image
(Name => "borderwidth", Value => Options.Border_Width,
Options_String => Options_String);
Option_Image
(Name => "class", Value => Options.Class,
Options_String => Options_String);
Option_Image
(Name => "colormap", Value => Options.Color_Map,
Options_String => Options_String);
Option_Image
(Name => "container", Value => Options.Container,
Options_String => Options_String);
Option_Image
(Name => "cursor", Value => Options.Cursor,
Options_String => Options_String);
Option_Image
(Name => "height", Value => Options.Height,
Options_String => Options_String);
Option_Image
(Name => "highlightbackground", Value => Options.Highlight_Background,
Options_String => Options_String);
Option_Image
(Name => "highlightcolot", Value => Options.Highlight_Color,
Options_String => Options_String);
Option_Image
(Name => "highlighthickness", Value => Options.Highlight_Thickness,
Options_String => Options_String);
Option_Image
(Name => "labelwidget", Value => Options.Label_Widget,
Options_String => Options_String);
Option_Image
(Name => "padx", Value => Options.Pad_X,
Options_String => Options_String);
Option_Image
(Name => "pady", Value => Options.Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "relief", Value => Options.Relief,
Options_String => Options_String);
Option_Image
(Name => "takefocus", Value => Options.Take_Focus,
Options_String => Options_String);
Option_Image
(Name => "text", Value => Options.Text,
Options_String => Options_String);
Option_Image
(Name => "visual", Value => Options.Visual,
Options_String => Options_String);
Option_Image
(Name => "width", Value => Options.Width,
Options_String => Options_String);
Option_Image
(Name => "labelanchor", Value => Options.Label_Anchor,
Options_String => Options_String);
Tcl_Eval
(Tcl_Script =>
"labelframe " & Path_Name & " " &
To_String(Source => Options_String),
Interpreter => Interpreter);
return Get_Widget(Path_Name => Path_Name, Interpreter => Interpreter);
end Create;
procedure Create
(Frame_Widget: out Tk_Label_Frame; Path_Name: Tk_Path_String;
Options: Label_Frame_Create_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) is
begin
Frame_Widget :=
Create
(Path_Name => Path_Name, Options => Options,
Interpreter => Interpreter);
end Create;
function Get_Options
(Frame_Widget: Tk_Label_Frame) return Label_Frame_Create_Options is
begin
return
Options: Label_Frame_Create_Options :=
Label_Frame_Create_Options'
(Class => Null_Tcl_String, Color_Map => Null_Tcl_String,
Container => NONE, Visual => Null_Tcl_String, others => <>)
do
Options.Background :=
Option_Value(Widgt => Frame_Widget, Name => "background");
Options.Border_Width :=
Option_Value(Widgt => Frame_Widget, Name => "borderwidth");
Options.Class := Option_Value(Widgt => Frame_Widget, Name => "class");
Options.Color_Map :=
Option_Value(Widgt => Frame_Widget, Name => "colormap");
Options.Container :=
Option_Value(Widgt => Frame_Widget, Name => "container");
Options.Cursor :=
Option_Value(Widgt => Frame_Widget, Name => "cursor");
Options.Height :=
Option_Value(Widgt => Frame_Widget, Name => "height");
Options.Highlight_Background :=
Option_Value(Widgt => Frame_Widget, Name => "highlightbackground");
Options.Highlight_Color :=
Option_Value(Widgt => Frame_Widget, Name => "highlightcolor");
Options.Highlight_Thickness :=
Option_Value(Widgt => Frame_Widget, Name => "highlightthickness");
Options.Label_Anchor :=
Option_Value(Widgt => Frame_Widget, Name => "labelanchor");
Options.Label_Widget :=
Option_Value(Widgt => Frame_Widget, Name => "labelwidget");
Options.Pad_X := Option_Value(Widgt => Frame_Widget, Name => "padx");
Options.Pad_Y := Option_Value(Widgt => Frame_Widget, Name => "pady");
Options.Relief :=
Option_Value(Widgt => Frame_Widget, Name => "relief");
Options.Take_Focus :=
Option_Value(Widgt => Frame_Widget, Name => "takefocus");
Options.Text := Option_Value(Widgt => Frame_Widget, Name => "text");
Options.Visual :=
Option_Value(Widgt => Frame_Widget, Name => "visual");
Options.Width := Option_Value(Widgt => Frame_Widget, Name => "width");
end return;
end Get_Options;
overriding procedure Configure
(Frame_Widget: Tk_Label_Frame; Options: Label_Frame_Options) is
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "background", Value => Options.Background,
Options_String => Options_String);
Option_Image
(Name => "borderwidth", Value => Options.Border_Width,
Options_String => Options_String);
Option_Image
(Name => "cursor", Value => Options.Cursor,
Options_String => Options_String);
Option_Image
(Name => "height", Value => Options.Height,
Options_String => Options_String);
Option_Image
(Name => "highlightbackground", Value => Options.Highlight_Background,
Options_String => Options_String);
Option_Image
(Name => "highlightcolot", Value => Options.Highlight_Color,
Options_String => Options_String);
Option_Image
(Name => "highlighthickness", Value => Options.Highlight_Thickness,
Options_String => Options_String);
Option_Image
(Name => "labelwidget", Value => Options.Label_Widget,
Options_String => Options_String);
Option_Image
(Name => "padx", Value => Options.Pad_X,
Options_String => Options_String);
Option_Image
(Name => "pady", Value => Options.Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "relief", Value => Options.Relief,
Options_String => Options_String);
Option_Image
(Name => "takefocus", Value => Options.Take_Focus,
Options_String => Options_String);
Option_Image
(Name => "text", Value => Options.Text,
Options_String => Options_String);
Option_Image
(Name => "width", Value => Options.Width,
Options_String => Options_String);
Option_Image
(Name => "labelanchor", Value => Options.Label_Anchor,
Options_String => Options_String);
Execute_Widget_Command
(Widgt => Frame_Widget, Command_Name => "configure",
Options => To_String(Source => Options_String));
end Configure;
end Tk.Labelframe;
|
-- -----------------------------------------------------------------------------
-- smk, the smart make
-- © 2018 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 Ada.Directories;
separate (Smk.Main)
-- --------------------------------------------------------------------------
function Must_Be_Run (Command : Run_Files.Command_Lines;
Previous_Run : in out Run_Files.Run_Lists.Map)
return Boolean
is
-- -----------------------------------------------------------------------
procedure Put_Explanation (Text : in String) is
use Smk.Run_Files;
begin
if Explain then
IO.Put_Line ("run " & (+Command) & " " & Text);
end if;
end Put_Explanation;
use Run_Files;
-- -----------------------------------------------------------------------
function A_Target_Is_Missing (Targets : in Run_Files.File_Lists.Map)
return Boolean is
use Ada.Directories;
use Run_Files.File_Lists;
begin
for T in Targets.Iterate loop
declare
Name : constant String := (+Key (T));
begin
if not Exists (+(Key (T))) then
Put_Explanation ("because " & Name & " is missing");
return True;
end if;
end;
end loop;
return False;
end A_Target_Is_Missing;
-- --------------------------------------------------------------------------
function A_Source_Is_Updated (Sources : in File_Lists.Map) return Boolean is
use Ada.Directories;
use Run_Files.File_Lists;
begin
for S in Sources.Iterate loop
declare
use Ada.Calendar;
Name : constant String := Full_Name (+Key (S));
File_TT : constant Time := Modification_Time (Name);
Last_Run_TT : constant Time := Element (S);
begin
if File_TT /= Last_Run_TT then
Put_Explanation ("because " & Name & " (" & IO.Image (File_TT)
& ") has been updated since last run ("
& IO.Image (Last_Run_TT) & ")");
return True;
end if;
end;
end loop;
return False;
end A_Source_Is_Updated;
use Run_Files.Run_Lists;
C : Run_Files.Run_Lists.Cursor;
begin
-- -----------------------------------------------------------------------
if Always_Make then
-- don't even ask, run it!
Put_Explanation ("because -a option is set");
return True;
end if;
C := Previous_Run.Find (Command);
if C = No_Element then
-- never run command
Put_Explanation ("because it was not run before");
return True;
else
return
A_Target_Is_Missing (Run_Files.Run_Lists.Element (C).Targets) or else
A_Source_Is_Updated (Run_Files.Run_Lists.Element (C).Sources);
end if;
end Must_Be_Run;
|
generic
type Real is digits <>;
package Generic_Quaternions is
type Quaternion is record
A, B, C, D : Real;
end record;
function "abs" (Left : Quaternion) return Real;
function Conj (Left : Quaternion) return Quaternion;
function "-" (Left : Quaternion) return Quaternion;
function "+" (Left, Right : Quaternion) return Quaternion;
function "-" (Left, Right : Quaternion) return Quaternion;
function "*" (Left : Quaternion; Right : Real) return Quaternion;
function "*" (Left : Real; Right : Quaternion) return Quaternion;
function "*" (Left, Right : Quaternion) return Quaternion;
function Image (Left : Quaternion) return String;
end Generic_Quaternions;
|
with Ada.Command_Line;
with Ada.Text_IO;
with Code_Count; use Code_Count;
-- CC
procedure Cc is
CM : Code_Count.CodeMate;
TM : Code_Count.TotalCodeMate;
begin
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line("command use: ./cc <file 1> <file 1>");
else
for cac in 1 .. Ada.Command_Line.Argument_Count loop
Code_Count.Read(
Ada.Command_Line.Argument(cac),
CM,
TM);
Ada.Text_IO.Put_Line("File Name: " & Ada.Command_Line.Argument(cac));
Code_Count.Print_To_File_Info(CM);
end loop;
Ada.Text_IO.New_Line(1);
Code_Count.Print_To_AllFile_Info(TM);
end if;
end Cc; |
-----------------------------------------------------------------------
-- gif2ada -- Read a GIF image and write an Ada package with it for UI.Images
-- Copyright (C) 2018 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 Interfaces;
with Ada.Text_IO;
with Ada.Streams.Stream_IO;
with Ada.Command_Line;
with Ada.Calendar;
with GID;
procedure Gif2ada is
use Interfaces;
Image : GID.Image_descriptor;
begin
if Ada.Command_Line.Argument_Count /= 2 then
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"Usage: gif2ada <package-name> <file>");
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"Generate an Ada package that contains an GIF image");
Ada.Command_Line.Set_Exit_Status (2);
return;
end if;
declare
subtype Primary_color_range is Unsigned_8;
procedure Get_Color (Red, Green, Blue : Interfaces.Unsigned_8);
procedure Set_X_Y (X, Y : in Natural) is null;
procedure Put_Pixel (Red, Green, Blue : Primary_color_range;
Alpha : Primary_color_range) is null;
procedure Feedback (Percents : Natural) is null;
procedure Raw_Byte (B : in Interfaces.Unsigned_8);
Name : constant String := Ada.Command_Line.Argument (1);
Path : constant String := Ada.Command_Line.Argument (2);
File : Ada.Streams.Stream_IO.File_Type;
Color_Count : Natural := 0;
Need_Sep : Boolean := False;
Need_Line : Boolean := False;
Count : Natural := 0;
procedure Raw_Byte (B : in Interfaces.Unsigned_8) is
begin
if Need_Sep then
Ada.Text_IO.Put (",");
end if;
if Need_Line then
Need_Line := False;
Ada.Text_IO.New_Line;
Ada.Text_IO.Set_Col (8);
end if;
Need_Sep := True;
Ada.Text_IO.Put (Natural'Image (Natural (B)));
Count := Count + 1;
Need_Line := (Count mod 8) = 0;
end Raw_Byte;
procedure Load_Image is
new GID.Load_image_contents (Primary_color_range, Set_X_Y,
Put_Pixel, Raw_Byte, Feedback, GID.fast);
procedure Get_Color (Red, Green, Blue : Interfaces.Unsigned_8) is
Red_Image : constant String := Unsigned_8'Image (Red);
begin
if Color_Count > 0 then
Ada.Text_IO.Put (",");
end if;
if Color_Count mod 4 = 3 then
Ada.Text_IO.New_Line;
Ada.Text_IO.Set_Col (9);
else
Ada.Text_IO.Put (" ");
end if;
Color_Count := Color_Count + 1;
Ada.Text_IO.Put ("(");
Ada.Text_IO.Put (Red_Image (Red_Image'First + 1 .. Red_Image'Last));
Ada.Text_IO.Put (",");
Ada.Text_IO.Put (Unsigned_8'Image (Green));
Ada.Text_IO.Put (",");
Ada.Text_IO.Put (Unsigned_8'Image (Blue));
Ada.Text_IO.Put (")");
end Get_Color;
procedure Write_Palette is
new GID.Get_palette (Get_Color);
Next_Frame : Ada.Calendar.Day_Duration := 0.0;
begin
Ada.Streams.Stream_IO.Open (File, Ada.Streams.Stream_IO.In_File, Path);
GID.Load_image_header (Image, Ada.Streams.Stream_IO.Stream (File).all);
Ada.Text_IO.Put_Line ("with UI.Images;");
Ada.Text_IO.Put_Line ("package " & Name & " is");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (" ");
Ada.Text_IO.Put_Line ("Descriptor : constant UI.Images.Image_Descriptor;");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("private");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" Palette : aliased constant UI.Images.Color_Array := (");
Ada.Text_IO.Set_Col (8);
Write_Palette (Image);
Ada.Text_IO.Put_Line (" );");
Ada.Text_IO.Put_Line (" -- " & Natural'Image (Color_Count) & " colors");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" Data : aliased constant UI.Images.Bitmap_Array := (");
Ada.Text_IO.Put (" ");
Load_Image (Image, Next_Frame);
Ada.Streams.Stream_IO.Close (File);
Ada.Text_IO.Put_Line (" );");
Ada.Text_IO.Put_Line (" -- " & Natural'Image (Count) & " bytes");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" Descriptor : constant UI.Images.Image_Descriptor :=");
Ada.Text_IO.Put (" (Width =>");
Ada.Text_IO.Put (Positive'Image (GID.Pixel_width (Image)));
Ada.Text_IO.Put_Line (",");
Ada.Text_IO.Put (" Height =>");
Ada.Text_IO.Put (Positive'Image (GID.Pixel_height (Image)));
Ada.Text_IO.Put_Line (",");
Ada.Text_IO.Put_Line (" Palette => Palette'Access,");
Ada.Text_IO.Put_Line (" Bitmap => Data'Access);");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("end " & Name & ";");
end;
end Gif2ada;
|
package body Tkmrpc.Contexts.esa
is
pragma Warnings
(Off, "* already use-visible through previous use type clause");
use type Types.esa_id_type;
use type Types.ae_id_type;
use type Types.ea_id_type;
use type Types.sp_id_type;
pragma Warnings
(On, "* already use-visible through previous use type clause");
type esa_FSM_Type is record
State : esa_State_Type;
ae_id : Types.ae_id_type;
ea_id : Types.ea_id_type;
sp_id : Types.sp_id_type;
end record;
-- ESP SA Context
Null_esa_FSM : constant esa_FSM_Type
:= esa_FSM_Type'
(State => clean,
ae_id => Types.ae_id_type'First,
ea_id => Types.ea_id_type'First,
sp_id => Types.sp_id_type'First);
type Context_Array_Type is
array (Types.esa_id_type) of esa_FSM_Type;
Context_Array : Context_Array_Type := Context_Array_Type'
(others => (Null_esa_FSM));
-------------------------------------------------------------------------
function Get_State
(Id : Types.esa_id_type)
return esa_State_Type
is
begin
return Context_Array (Id).State;
end Get_State;
-------------------------------------------------------------------------
function Has_ae_id
(Id : Types.esa_id_type;
ae_id : Types.ae_id_type)
return Boolean
is (Context_Array (Id).ae_id = ae_id);
-------------------------------------------------------------------------
function Has_ea_id
(Id : Types.esa_id_type;
ea_id : Types.ea_id_type)
return Boolean
is (Context_Array (Id).ea_id = ea_id);
-------------------------------------------------------------------------
function Has_sp_id
(Id : Types.esa_id_type;
sp_id : Types.sp_id_type)
return Boolean
is (Context_Array (Id).sp_id = sp_id);
-------------------------------------------------------------------------
function Has_State
(Id : Types.esa_id_type;
State : esa_State_Type)
return Boolean
is (Context_Array (Id).State = State);
-------------------------------------------------------------------------
pragma Warnings
(Off, "condition can only be False if invalid values present");
function Is_Valid (Id : Types.esa_id_type) return Boolean
is (Context_Array'First <= Id and Id <= Context_Array'Last);
pragma Warnings
(On, "condition can only be False if invalid values present");
-------------------------------------------------------------------------
procedure create
(Id : Types.esa_id_type;
ae_id : Types.ae_id_type;
ea_id : Types.ea_id_type;
sp_id : Types.sp_id_type)
is
begin
Context_Array (Id).ae_id := ae_id;
Context_Array (Id).ea_id := ea_id;
Context_Array (Id).sp_id := sp_id;
Context_Array (Id).State := active;
end create;
-------------------------------------------------------------------------
procedure invalidate
(Id : Types.esa_id_type)
is
begin
Context_Array (Id).State := invalid;
end invalidate;
-------------------------------------------------------------------------
procedure reset
(Id : Types.esa_id_type)
is
begin
Context_Array (Id).ae_id := Types.ae_id_type'First;
Context_Array (Id).ea_id := Types.ea_id_type'First;
Context_Array (Id).sp_id := Types.sp_id_type'First;
Context_Array (Id).State := clean;
end reset;
-------------------------------------------------------------------------
procedure select_sa
(Id : Types.esa_id_type)
is
begin
Context_Array (Id).State := selected;
end select_sa;
-------------------------------------------------------------------------
procedure unselect_sa
(Id : Types.esa_id_type)
is
begin
Context_Array (Id).State := active;
end unselect_sa;
end Tkmrpc.Contexts.esa;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, 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$
------------------------------------------------------------------------------
with League.Base_Codecs;
with League.Stream_Element_Vectors;
with League.Strings;
procedure Base64_Test is
type Test_Data is record
Source : League.Stream_Element_Vectors.Stream_Element_Vector;
Encoded : League.Strings.Universal_String;
end record;
procedure Do_Test (Data : Test_Data);
Test_1 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'))),
League.Strings.To_Universal_String ("SA=="));
Test_2 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'),
1 => Character'Pos ('e'))),
League.Strings.To_Universal_String ("SGU="));
Test_3 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'),
1 => Character'Pos ('e'),
2 => Character'Pos ('l'))),
League.Strings.To_Universal_String ("SGVs"));
Test_4 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'),
1 => Character'Pos ('e'),
2 => Character'Pos ('l'),
3 => Character'Pos ('l'))),
League.Strings.To_Universal_String ("SGVsbA=="));
Test_5 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'),
1 => Character'Pos ('e'),
2 => Character'Pos ('l'),
3 => Character'Pos ('l'),
4 => Character'Pos ('o'))),
League.Strings.To_Universal_String ("SGVsbG8="));
Test_6 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => Character'Pos ('H'),
1 => Character'Pos ('e'),
2 => Character'Pos ('l'),
3 => Character'Pos ('l'),
4 => Character'Pos ('o'),
5 => Character'Pos (ASCII.NUL))),
League.Strings.To_Universal_String ("SGVsbG8A"));
Test_7 : constant Test_Data
:= (League.Stream_Element_Vectors.To_Stream_Element_Vector
((0 => 16#FF#,
1 => 16#FF#,
2 => 16#FF#,
3 => 16#FF#)),
League.Strings.To_Universal_String ("/////w=="));
-------------
-- Do_Test --
-------------
procedure Do_Test (Data : Test_Data) is
use type League.Stream_Element_Vectors.Stream_Element_Vector;
use type League.Strings.Universal_String;
X : constant League.Strings.Universal_String
:= League.Base_Codecs.To_Base_64 (Data.Source);
Y : constant League.Stream_Element_Vectors.Stream_Element_Vector
:= League.Base_Codecs.From_Base_64 (X);
begin
if Data.Encoded /= X then
raise Program_Error;
end if;
if Data.Source /= Y then
raise Program_Error;
end if;
end Do_Test;
begin
Do_Test (Test_1);
Do_Test (Test_2);
Do_Test (Test_3);
Do_Test (Test_4);
Do_Test (Test_5);
Do_Test (Test_6);
Do_Test (Test_7);
end Base64_Test;
|
-- -*- Mode: Ada -*-
-- Filename : multiboot.adb
-- Description : Provides access to the multiboot information from GRUB
-- Legacy and GRUB 2.
-- Author : Luke A. Guest
-- Created On : Sat Jun 16 12:27:30 2012
-- Licence : See LICENCE in the root directory.
with System.Address_To_Access_Conversions;
with Ada.Unchecked_Conversion;
package body Multiboot is
function Get_Symbols_Variant return Symbols_Variant is
begin
if Info.Flags.Symbol_Table and not Info.Flags.Section_Header_Table then
return Aout;
elsif not Info.Flags.Symbol_Table and
Info.Flags.Section_Header_Table
then
return ELF;
else
raise Program_Error;
end if;
end Get_Symbols_Variant;
-- This forward declaration is to keep GNAT happy.
function Unsigned_32_To_Entry_Access
(Addr : Unsigned_32) return Memory_Map_Entry_Access;
function To_Address is new Ada.Unchecked_Conversion
(Source => Unsigned_32,
Target => System.Address);
function To_Unsigned_32 is new Ada.Unchecked_Conversion
(Source => System.Address,
Target => Unsigned_32);
package Convert is new System.Address_To_Access_Conversions
(Object => Memory_Map_Entry_Access);
function To_Entry_Access is new Ada.Unchecked_Conversion
(Source => Convert.Object_Pointer,
Target => Memory_Map_Entry_Access);
function To_Object_Pointer is new Ada.Unchecked_Conversion
(Source => Memory_Map_Entry_Access,
Target => Convert.Object_Pointer);
function Unsigned_32_To_Entry_Access
(Addr : Unsigned_32) return Memory_Map_Entry_Access is
begin
return To_Entry_Access (Convert.To_Pointer
(To_Address (Addr)));
end Unsigned_32_To_Entry_Access;
function First_Memory_Map_Entry return Memory_Map_Entry_Access is
begin
if not Info.Flags.BIOS_Memory_Map then
return null;
end if;
if Info.Memory_Map.Addr = 0 then
return null;
end if;
return Unsigned_32_To_Entry_Access (Info.Memory_Map.Addr);
end First_Memory_Map_Entry;
function Next_Memory_Map_Entry
(Current : Memory_Map_Entry_Access) return Memory_Map_Entry_Access is
Current_Addr : constant Unsigned_32 := To_Unsigned_32
(Convert.To_Address
(To_Object_Pointer (Current)));
Next_Addr : Unsigned_32 := Unsigned_32'First;
begin
if Current_Addr >= Info.Memory_Map.Addr + Info.Memory_Map.Length then
return null;
end if;
Next_Addr := Current_Addr + Current.Size +
(Unsigned_32'Size / System.Storage_Unit);
return Unsigned_32_To_Entry_Access (Next_Addr);
end Next_Memory_Map_Entry;
package APM_Table_Convert is new System.Address_To_Access_Conversions
(Object => APM_Table_Access);
function To_APM_Table_Access is new Ada.Unchecked_Conversion
(Source => APM_Table_Convert.Object_Pointer,
Target => APM_Table_Access);
function Get_APM_Table return APM_Table_Access is
begin
if not Info.Flags.APM_Table then
return null;
end if;
return To_APM_Table_Access
(APM_Table_Convert.To_Pointer (Info.APM));
end Get_APM_Table;
end Multiboot;
|
with Interfaces;
with Offmt_Lib.Fmt_Data.Unsigned_Generic;
package Offmt_Lib.Fmt_Data.Unsigned_16
is new Offmt_Lib.Fmt_Data.Unsigned_Generic (Interfaces.Unsigned_16);
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with GNAT.Regpat;
package body CLIC.Config.Info is
----------
-- List --
----------
function List (This : CLIC.Config.Instance;
Filter : String := ".*";
Show_Origin : Boolean := False)
return AAA.Strings.Vector
is
Result : AAA.Strings.Vector;
begin
for Key of List_Keys (This, Filter) loop
declare
Val : constant Config_Value := This.Config_Map (+Key);
Line : Unbounded_String;
begin
if Show_Origin then
Line := Val.Origin & ": ";
end if;
Append (Line, Key & "=");
Append (Line, Image (Val.Value));
Result.Append (To_String (Line));
end;
end loop;
return Result;
end List;
---------------
-- List_Keys --
---------------
function List_Keys (This : CLIC.Config.Instance;
Filter : String := ".*")
return AAA.Strings.Vector
is
use GNAT.Regpat;
Re : constant Pattern_Matcher := Compile (Filter);
Result : AAA.Strings.Vector;
begin
for C in This.Config_Map.Iterate loop
declare
Key : constant String := To_String (Config_Maps.Key (C));
begin
if Match (Re, Key) then
Result.Append (Key);
end if;
end;
end loop;
return Result;
end List_Keys;
end CLIC.Config.Info;
|
-----------------------------------------------------------------------
-- awa-tags-modules -- Module awa-tags
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Applications;
with ADO;
with ADO.Sessions;
with Util.Strings.Vectors;
with AWA.Modules;
-- == Integration ==
-- The <tt>Tag_Module</tt> manages the tags associated with entities. It provides operations
-- that are used by the tag beans together with the <tt>awa:tagList</tt> and
-- <tt>awa:tagCloud</tt> components to manage the tags.
-- An instance of the <tt>Tag_Module</tt> must be declared and registered in the AWA application.
-- The module instance can be defined as follows:
--
-- type Application is new AWA.Applications.Application with record
-- Tag_Module : aliased AWA.Votes.Modules.Tag_Module;
-- end record;
--
-- And registered in the `Initialize_Modules` procedure by using:
--
-- Register (App => App.Self.all'Access,
-- Name => AWA.Tags.Modules.NAME,
-- URI => "tags",
-- Module => App.Tag_Module'Access);
package AWA.Tags.Modules is
-- The name under which the module is registered.
NAME : constant String := "tags";
-- ------------------------------
-- Module awa-tags
-- ------------------------------
type Tag_Module is new AWA.Modules.Module with private;
type Tag_Module_Access is access all Tag_Module'Class;
-- Initialize the tags module.
overriding
procedure Initialize (Plugin : in out Tag_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the tags module.
function Get_Tag_Module return Tag_Module_Access;
-- Add a tag on the database entity referenced by <tt>Id</tt> in the table identified
-- by <tt>Entity_Type</tt>. The permission represented by <tt>Permission</tt> is checked
-- to make sure the current user can add the tag. If the permission is granted, the
-- tag represented by <tt>Tag</tt> is associated with the said database entity.
procedure Add_Tag (Model : in Tag_Module;
Id : in ADO.Identifier;
Entity_Type : in String;
Permission : in String;
Tag : in String);
-- Remove the tag identified by <tt>Tag</tt> and associated with the database entity
-- referenced by <tt>Id</tt> in the table identified by <tt>Entity_Type</tt>.
-- The permission represented by <tt>Permission</tt> is checked to make sure the current user
-- can remove the tag.
procedure Remove_Tag (Model : in Tag_Module;
Id : in ADO.Identifier;
Entity_Type : in String;
Permission : in String;
Tag : in String);
-- Remove the tags defined by the <tt>Deleted</tt> tag list and add the tags defined
-- in the <tt>Added</tt> tag list. The tags are associated with the database entity
-- referenced by <tt>Id</tt> in the table identified by <tt>Entity_Type</tt>.
-- The permission represented by <tt>Permission</tt> is checked to make sure the current user
-- can remove or add the tag.
procedure Update_Tags (Model : in Tag_Module;
Id : in ADO.Identifier;
Entity_Type : in String;
Permission : in String;
Added : in Util.Strings.Vectors.Vector;
Deleted : in Util.Strings.Vectors.Vector);
-- Find the tag identifier associated with the given tag.
-- Return NO_IDENTIFIER if there is no such tag.
procedure Find_Tag_Id (Session : in out ADO.Sessions.Session'Class;
Tag : in String;
Result : out ADO.Identifier);
private
type Tag_Module is new AWA.Modules.Module with null record;
end AWA.Tags.Modules;
|
separate(Formatter.Get)
procedure Format_Real(Data : in Contents;
In_The_String : in out String;
Location : in out Natural;
Width : in Natural := 0;
Precision : in Natural := 0;
Exponent : in Natural := 0;
Fill_With_Zeros : in Boolean := False) is
-- ++
--
-- FUNCTIONAL DESCRIPTION:
--
-- Formats real number according to specified parameters.
--
-- FORMAL PARAMETERS:
--
-- Data:
-- The input real number in a variant record.
--
-- In_The_String:
-- The output string where the formatted real number is placed.
--
-- Location:
-- The position of the formatted real number in the output string.
--
-- Width:
-- The output formatted real number field width.
--
-- Precision:
-- The number of decimal positions.
--
-- Exponent:
-- The number of exponent positions.
--
-- Fill_With_Zeros:
-- Logical (Boolean) flag specifying the formatted real number is to be
-- padded with leading zeros.
--
-- DESIGN:
--
-- Format the real number directly into the output string using Float or
-- Double-Float IO Put procedure.
--
-- --
-- Local variable(s)
Field_Width : Natural;
begin
-- Determine output field width
if Width > 0 then
Field_Width := Width; -- Set to specified width
else
Field_Width := Get.Default_Width;
end if;
if Data.Class = Float_Type then -- Correct data type
-- Convert to string
FIO.Put(ITEM => Data.Float_Value,
AFT => Precision,
EXP => Exponent,
TO => In_The_String(Location..Location + Field_Width - 1));
if Left_Justify then
In_The_String(Location..Location + Field_Width - 1) :=
Get.Left_Justified(In_The_String(Location..Location + Field_Width-1));
end if;
if Fill_With_Zeros then
In_The_String(Location..Location + Field_Width - 1) :=
Get.Zero_Fill(In_The_String(Location..Location + Field_Width-1));
end if;
-- Update next output position
Location := Location + Field_Width;
elsif Data.Class = DP_Float_Type then -- Correct data type
-- Format directly to output string
DFIO.Put(ITEM => Data.DP_Float_Value,
AFT => Precision,
EXP => Exponent,
TO => In_The_String(Location..Location + Field_Width - 1));
if Left_Justify then
In_The_String(Location..Location + Field_Width - 1) :=
Get.Left_Justified(In_The_String(Location..Location + Field_Width-1));
end if;
if Fill_With_Zeros then
In_The_String(Location..Location + Field_Width - 1) :=
Get.Zero_Fill(In_The_String(Location..Location + Field_Width-1));
end if;
Location := Location + Field_Width;
else -- Not correct data type to convert
Format_Error(In_The_String, Location, Field_Width);
end if;
exception
when others =>
Format_Error(In_The_String, Location, Get.Default_Width);
end Format_Real;
|
--
--
--
generic
type Index_Type is (<>);
package Sets is
type Set_Type is private;
Null_Set : constant Set_Type;
procedure Set_Range (First : in Index_Type;
Last : in Index_Type);
-- All sets will be of size N
-- Set the set size
function Set_New return Set_Type;
-- Allocate a new set
-- A new set for element 0..N
procedure Set_Free (Set : in out Set_Type);
-- Deallocate a set
function Set_Add (Set : in out Set_Type;
Item : in Index_Type) return Boolean;
-- Add a new element to the set. Return True if the element was added
-- and FALSE if it was already there.
function Set_Union (Set_1 : in out Set_Type;
Set_2 : in out Set_Type) return Boolean;
-- Add every element of s2 to s1. Return TRUE if s1 changes.
-- A <- A U B, thru element N
function Set_Find (Set : in Set_Type;
Item : in Index_Type) return Boolean;
-- True if Item is in set Set.
function First_Index return Index_Type;
function Last_Index return Index_Type;
private
type Set_Array is array (Index_Type range <>) of Boolean;
type Set_Type is access Set_Array;
Null_Set : constant Set_Type := null;
end Sets;
|
with Interfaces;
package Tkmrpc.Results is
type Result_Type is new Interfaces.Unsigned_64;
Ok : constant Result_Type := 16#0000000000000000#;
Invalid_Operation : constant Result_Type := 16#0000000000000101#;
Invalid_Id : constant Result_Type := 16#0000000000000102#;
Invalid_State : constant Result_Type := 16#0000000000000103#;
Invalid_Parameter : constant Result_Type := 16#0000000000000104#;
Random_Failure : constant Result_Type := 16#0000000000000201#;
Sign_Failure : constant Result_Type := 16#0000000000000202#;
Aborted : constant Result_Type := 16#0000000000000301#;
Math_Error : constant Result_Type := 16#0000000000000401#;
end Tkmrpc.Results;
|
pragma Ada_2012;
pragma Style_Checks (Off);
pragma Warnings ("U");
with Interfaces.C; use Interfaces.C;
with arm_math_types_h;
with sys_ustdint_h;
package complex_math_functions_h is
procedure arm_cmplx_conj_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:58
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_f32";
procedure arm_cmplx_conj_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:69
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_q31";
procedure arm_cmplx_conj_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:81
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_q15";
procedure arm_cmplx_mag_squared_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:93
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_f32";
procedure arm_cmplx_mag_squared_f64
(pSrc : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:105
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_f64";
procedure arm_cmplx_mag_squared_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:117
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_q31";
procedure arm_cmplx_mag_squared_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:129
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_q15";
procedure arm_cmplx_mag_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:141
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_f32";
procedure arm_cmplx_mag_f64
(pSrc : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:153
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_f64";
procedure arm_cmplx_mag_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:165
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_q31";
procedure arm_cmplx_mag_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:177
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_q15";
procedure arm_cmplx_mag_fast_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:188
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_fast_q15";
procedure arm_cmplx_dot_prod_q15
(pSrcA : access arm_math_types_h.q15_t;
pSrcB : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.q31_t;
imagResult : access arm_math_types_h.q31_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:202
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_q15";
procedure arm_cmplx_dot_prod_q31
(pSrcA : access arm_math_types_h.q31_t;
pSrcB : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.q63_t;
imagResult : access arm_math_types_h.q63_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:218
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_q31";
procedure arm_cmplx_dot_prod_f32
(pSrcA : access arm_math_types_h.float32_t;
pSrcB : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.float32_t;
imagResult : access arm_math_types_h.float32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:234
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_f32";
procedure arm_cmplx_mult_real_q15
(pSrcCmplx : access arm_math_types_h.q15_t;
pSrcReal : access arm_math_types_h.q15_t;
pCmplxDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:249
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_q15";
procedure arm_cmplx_mult_real_q31
(pSrcCmplx : access arm_math_types_h.q31_t;
pSrcReal : access arm_math_types_h.q31_t;
pCmplxDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:263
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_q31";
procedure arm_cmplx_mult_real_f32
(pSrcCmplx : access arm_math_types_h.float32_t;
pSrcReal : access arm_math_types_h.float32_t;
pCmplxDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:277
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_f32";
procedure arm_cmplx_mult_cmplx_q15
(pSrcA : access arm_math_types_h.q15_t;
pSrcB : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:290
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_q15";
procedure arm_cmplx_mult_cmplx_q31
(pSrcA : access arm_math_types_h.q31_t;
pSrcB : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:304
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_q31";
procedure arm_cmplx_mult_cmplx_f32
(pSrcA : access arm_math_types_h.float32_t;
pSrcB : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:318
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_f32";
procedure arm_cmplx_mult_cmplx_f64
(pSrcA : access arm_math_types_h.float64_t;
pSrcB : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:333
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_f64";
end complex_math_functions_h;
|
with Ada.Numerics.Float_Random;
with RandInt;
with Logger;
with External; use External;
with Receiver;
package Node is
package RAF renames Ada.Numerics.Float_Random;
package LOG renames Logger;
package RAD renames RandInt;
package REC renames Receiver;
type NodeObj;
type pNodeObj is access NodeObj;
type Array_pNodeObj is array (Positive range <>) of pNodeObj;
type pArray_pNodeObj is access Array_pNodeObj;
type Message is record
content: Natural;
health: Natural;
end record;
type pMessage is access Message;
procedure SleepForSomeTime(maxSleep: Natural; intervals: Natural := 1);
task type NodeTask(
self: pNodeObj;
maxSleep: Natural;
logger: LOG.pLoggerReceiver;
isLast: Boolean;
receiver: REC.pReceiverTask
) is
entry SendMessage(message: in pMessage);
entry SetupTrap;
entry Stop;
end NodeTask;
type pNodeTask is access NodeTask;
-- NodeStash sort of simulates what a `chan` in Golang would do
task type NodeStash(
self: pNodeObj
) is
entry SendMessage(message: in pMessage);
entry Stop;
end NodeStash;
type pNodeStash is access NodeStash;
type NodeObj is record
id: Natural;
neighbours: pArray_pNodeObj;
nodeTask: pNodeTask;
nodeStash: pNodeStash;
end record;
-- grim reaper kills given node
task type NodeTaskGrimReaper(node: pNodeObj);
type pNodeTaskGrimReaper is access NodeTaskGrimReaper;
type Array_pNodeTaskGrimReaper is array (Positive range <>) of pNodeTaskGrimReaper;
type pArray_pNodeTaskGrimReaper is access Array_pNodeTaskGrimReaper;
end Node;
|
with Lv; use Lv;
with Lv.Style;
with Lv.Area;
package Lv.Objx.Cont is
subtype Instance is Obj_T;
type Layout_T is
(Layout_Off,
Layout_Center,
Layout_Col_L, -- Column left align
Layout_Col_M, -- Column middle align
Layout_Col_R, -- Column right align
Layout_Row_T, -- Row top align
Layout_Row_M, -- Row middle align
Layout_Row_B, -- Row bottom align
Layout_Pretty, -- Put as many object as possible in row and begin a new row
Layout_Grid); -- Align same-sized object into a grid
-- Create a container objects
-- @param par pointer to an object, it will be the parent of the new container
-- @param copy pointer to a container object, if not NULL then the new object will be copied from it
-- @return pointer to the created container
function Create (Parent : Obj_T; Copy : Obj_T) return Instance;
----------------------
-- Setter functions --
----------------------
-- Set a layout on a container
-- @param self pointer to a container object
-- @param layout a layout from 'lv_cont_layout_t'
procedure Set_Layout (Self : Instance; Layout : Layout_T);
-- Enable the horizontal or vertical fit.
-- The container size will be set to involve the children horizontally or vertically.
-- @param self pointer to a container object
-- @param hor_en true: enable the horizontal fit
-- @param ver_en true: enable the vertical fit
procedure Set_Fit (Self : Instance; Hor_En : U_Bool; Ver_En : U_Bool);
-- Set the style of a container
-- @param self pointer to a container object
-- @param style pointer to the new style
procedure Set_Style (Self : Instance; Style : access Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the layout of a container
-- @param self pointer to container object
-- @return the layout from 'lv_cont_layout_t'
function Layout (Self : Instance) return Layout_T;
-- Get horizontal fit enable attribute of a container
-- @param self pointer to a container object
-- @return true: horizontal fit is enabled; false: disabled
function Hor_Fit (Self : Instance) return U_Bool;
-- Get vertical fit enable attribute of a container
-- @param self pointer to a container object
-- @return true: vertical fit is enabled; false: disabled
function Ver_Fit (Self : Instance) return U_Bool;
-- Get that width reduced by the horizontal padding. Useful if a layout is used.
-- @param self pointer to a container object
-- @return the width which still fits into the container
function Fit_Width (Self : Instance) return Lv.Area.Coord_T;
-- Get that height reduced by the vertical padding. Useful if a layout is used.
-- @param self pointer to a container object
-- @return the height which still fits into the container
function Fit_Height (Self : Instance) return Lv.Area.Coord_T;
-- Get the style of a container
-- @param self pointer to a container object
-- @return pointer to the container's style
function Style (Self : Instance) return access Lv.Style.Style;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_cont_create");
pragma Import (C, Set_Layout, "lv_cont_set_layout");
pragma Import (C, Set_Fit, "lv_cont_set_fit");
pragma Import (C, Set_Style, "lv_cont_set_style_inline");
pragma Import (C, Layout, "lv_cont_get_layout");
pragma Import (C, Hor_Fit, "lv_cont_get_hor_fit");
pragma Import (C, Ver_Fit, "lv_cont_get_ver_fit");
pragma Import (C, Fit_Width, "lv_cont_get_fit_width");
pragma Import (C, Fit_Height, "lv_cont_get_fit_height");
pragma Import (C, Style, "lv_cont_get_style_inline");
for Layout_T'Size use 8;
for Layout_T use (Layout_Off => 0,
Layout_Center => 1,
Layout_Col_L => 2,
Layout_Col_M => 3,
Layout_Col_R => 4,
Layout_Row_T => 5,
Layout_Row_M => 6,
Layout_Row_B => 7,
Layout_Pretty => 8,
Layout_Grid => 9);
end Lv.Objx.Cont;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with League.JSON.Values;
package body Hello_World is
function "+" (Text : Wide_Wide_String)
return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
function "-" (Text : Wide_Wide_String)
return League.JSON.Values.JSON_Value is
(League.JSON.Values.To_JSON_Value (+Text));
--------------------
-- Create_Session --
--------------------
overriding procedure Create_Session
(Self : aliased in out Kernel;
Session_Id : Positive;
Result : out Jupyter.Kernels.Session_Access)
is
Object : constant Session_Access := new Session;
begin
Result := Jupyter.Kernels.Session_Access (Object);
Self.Map.Insert (Session_Id, Object);
end Create_Session;
-------------
-- Execute --
-------------
overriding procedure Execute
(Self : aliased in out Session;
IO_Pub : not null Jupyter.Kernels.IO_Pub_Access;
Execution_Counter : Positive;
Code : League.Strings.Universal_String;
Silent : Boolean;
User_Expressions : League.JSON.Objects.JSON_Object;
Allow_Stdin : Boolean;
Stop_On_Error : Boolean;
Expression_Values : out League.JSON.Objects.JSON_Object;
Error : in out Jupyter.Kernels.Execution_Error)
is
pragma Unreferenced (Execution_Counter, User_Expressions, Allow_Stdin,
Stop_On_Error, Expression_Values, Error, Self);
Data : League.JSON.Objects.JSON_Object;
Meta : League.JSON.Objects.JSON_Object;
begin
Expression_Values := League.JSON.Objects.Empty_JSON_Object;
if not Silent then
Data.Insert (+"text/plain", League.JSON.Values.To_JSON_Value (Code));
IO_Pub.Execute_Result
(Data => Data,
Metadata => Meta,
Transient => League.JSON.Objects.Empty_JSON_Object);
end if;
end Execute;
-----------------
-- Get_Session --
-----------------
overriding function Get_Session
(Self : aliased in out Kernel;
Session_Id : Positive) return Jupyter.Kernels.Session_Access
is
Result : constant Session_Access := Self.Map (Session_Id);
begin
return Jupyter.Kernels.Session_Access (Result);
end Get_Session;
-----------------
-- Kernel_Info --
-----------------
overriding procedure Kernel_Info
(Self : aliased in out Kernel;
Result : out League.JSON.Objects.JSON_Object)
is
pragma Unreferenced (Self);
Language : League.JSON.Objects.JSON_Object;
begin
Language.Insert (+"name", -"Hello World");
Language.Insert (+"version", -"2012");
Language.Insert (+"mimetype", -"text/x-ada");
Language.Insert (+"file_extension", -".adb");
Language.Insert (+"pygments_lexer", -"ada");
Language.Insert (+"codemirror_mode", -"ada");
Result.Insert (+"protocol_version", -"5.3");
Result.Insert (+"implementation", -"dummy");
Result.Insert (+"implementation_version", -"0.1.0");
Result.Insert (+"language_info", Language.To_JSON_Value);
Result.Insert (+"banner", -"Some banner.");
Result.Insert (+"status", -"ok");
end Kernel_Info;
end Hello_World;
|
package Atomic6_Pkg is
type Int is new Integer;
pragma Atomic (Int);
Counter1 : Int;
Counter2 : Int;
Timer1 : Integer;
pragma Atomic (Timer1);
Timer2 : Integer;
pragma Atomic (Timer2);
type Arr1 is array (1..8) of Int;
Counter : Arr1;
type Arr2 is array (1..8) of Integer;
pragma Atomic_Components (Arr2);
Timer : Arr2;
type R is record
Counter1 : Int;
Timer1 : Integer;
pragma Atomic (Timer1);
Counter2 : Int;
Timer2 : Integer;
pragma Atomic (Timer2);
Dummy : Integer;
end record;
type Int_Ptr is access all Int;
end Atomic6_Pkg;
|
with SDL;
with SDL.Log;
with SDL.Timers;
procedure Timers is
function Ticks return String is
(SDL.Timers.Milliseconds'Image (SDL.Timers.Ticks));
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
SDL.Log.Put_Debug ("Ticks: " & Ticks);
SDL.Timers.Wait_Delay (200);
SDL.Log.Put_Debug ("After Wait_Delay, ticks: " & Ticks);
end Timers;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with System;
with Ada.Unchecked_Conversion;
package body GBA.BIOS.Extended_Interface is
procedure Register_RAM_Reset
( Clear_External_WRAM
, Clear_Internal_WRAM
, Clear_Palette
, Clear_VRAM
, Clear_OAM
, Reset_SIO_Registers
, Reset_Sound_Registers
, Reset_Other_Registers
: Boolean := False)
is
Flags : Register_RAM_Reset_Flags :=
( Clear_External_WRAM
, Clear_Internal_WRAM
, Clear_Palette
, Clear_VRAM
, Clear_OAM
, Reset_SIO_Registers
, Reset_Sound_Registers
, Reset_Other_Registers
);
begin
Register_RAM_Reset (Flags);
end;
type Div_Mod_Result is
record
Quotient, Remainder : Integer;
end record
with Size => 64;
function Conv is new Ada.Unchecked_Conversion (Long_Long_Integer, Div_Mod_Result);
function Divide (Num, Denom : Integer) return Integer is
( Conv (Div_Mod (Num, Denom)).Quotient );
function Remainder (Num, Denom : Integer) return Integer is
( Conv (Div_Mod (Num, Denom)).Remainder );
procedure Div_Mod (Num, Denom : Integer; Quotient, Remainder : out Integer) is
Result : constant Div_Mod_Result := Conv (Div_Mod (Num, Denom));
begin
Quotient := Result.Quotient;
Remainder := Result.Remainder;
end;
procedure Cpu_Set
( Source, Dest : Address;
Unit_Count : Cpu_Set_Unit_Count;
Mode : Cpu_Set_Mode;
Unit_Size : Cpu_Set_Unit_Size) is
Config : constant Cpu_Set_Config :=
( Unit_Count => Unit_Count
, Copy_Mode => Mode
, Unit_Size => Unit_Size
);
begin
Cpu_Set (Source, Dest, Config);
end;
procedure Cpu_Fast_Set
( Source, Dest : Address;
Word_Count : Cpu_Set_Unit_Count;
Mode : Cpu_Set_Mode) is
Config : constant Cpu_Set_Config :=
( Unit_Count => Word_Count
, Copy_Mode => Mode
, Unit_Size => Word -- not used by cpu_fast_set
);
begin
Cpu_Fast_Set (Source, Dest, Config);
end;
procedure Wait_For_Interrupt (Wait_For : Interrupt_Flags) is
begin
Wait_For_Interrupt (True, Wait_For);
end;
--
-- Affine set
--
procedure Affine_Set
( Parameters : Affine_Parameters;
Transform : out Affine_Transform_Matrix ) is
begin
Affine_Set
( Parameters'Address
, Transform'Address
, Count => 1
, Stride => 2
);
end;
procedure Affine_Set
( Parameters : Affine_Parameters;
Transform : OBJ_Affine_Transform_Index ) is
begin
Affine_Set
( Parameters'Address
, Affine_Transform_Address (Transform)
, Count => 1
, Stride => 8
);
end;
procedure Affine_Set_Ext
( Parameters : Affine_Parameters_Ext;
Transform : out BG_Transform_Info ) is
begin
Affine_Set_Ext (Parameters'Address, Transform'Address, 1);
end;
procedure Affine_Set (Parameters : OBJ_Affine_Parameter_Array) is
Begin_Address : constant Address := Affine_Transform_Address (Parameters'First);
begin
Affine_Set
( Parameters'Address
, Begin_Address
, Count => Parameters'Length
, Stride => 8
);
end;
procedure Affine_Set_Ext (Parameters : BG_Affine_Parameter_Ext_Array) is
Begin_Address : constant Address := Affine_Transform_Address (Parameters'First);
begin
Affine_Set_Ext
( Parameters'Address
, Begin_Address
, Count => Parameters'Length
);
end;
procedure Affine_Set
( Parameters : Affine_Parameter_Array;
Transforms : out Affine_Transform_Array ) is
pragma Assert (Parameters'Length = Transforms'Length);
begin
Affine_Set
( Parameters'Address
, Transforms'Address
, Count => Parameters'Length
, Stride => 2
);
end;
procedure Affine_Set_Ext
( Parameters : Affine_Parameter_Ext_Array;
Transforms : out BG_Transform_Info_Array ) is
pragma Assert (Parameters'Length = Transforms'Length);
begin
Affine_Set_Ext
( Parameters'Address
, Transforms'Address
, Count => Parameters'Length
);
end;
end GBA.BIOS.Extended_Interface; |
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ M E C H --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1996-1997 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 used to establish calling mechanisms
-- The reason we separate this off into its own package is that it is
-- entirely possible that it may need some target specific specialization.
with Types; use Types;
package Sem_Mech is
-------------------------------------------------
-- Definitions for Parameter Mechanism Control --
-------------------------------------------------
-- For parameters passed to subprograms, and for function return values,
-- as passing mechanism is defined. The entity attribute Mechanism returns
-- an indication of the mechanism, and Set_Mechanism can be used to set
-- the mechanism. At the program level, there are three ways to explicitly
-- set the mechanism:
-- An Import_xxx or Export_xxx pragma (where xxx is Function, Procedure,
-- or Valued_Procedure) can explicitly set the mechanism for either a
-- parameter or a function return value. A mechanism explicitly set by
-- such a pragma overrides the effect of C_Pass_By_Copy described below.
-- If convention C_Pass_By_Copy is set for a record, and the record type
-- is used as the formal type of a subprogram with a foreign convention,
-- then the mechanism is set to By_Copy.
-- If a pragma C_Pass_By_Copy applies, and a record type has Convention
-- C, and the record type is used as the formal type of a subprogram
-- with a foreign convention, then the mechanism is set to use By_Copy
-- if the size of the record is sufficiently small (as determined by
-- the value of the parameter to pragma C_Pass_By_Copy).
-- The subtype Mechanism_Type (declared in Types) is used to describe
-- the mechanism to be used. The following special values of this type
-- specify the mechanism, as follows.
Default_Mechanism : constant Mechanism_Type := 0;
-- The default setting indicates that the backend will choose the proper
-- default mechanism. This depends on the convention of the subprogram
-- involved, and is generally target dependent. In the compiler, the
-- backend chooses the mechanism in this case in accordance with any
-- requirements imposed by the ABI. Note that Default is never used for
-- record types on foreign convention subprograms, since By_Reference
-- is forced for such types unless one of the above described approaches
-- is used to explicitly force By_Copy.
By_Copy : constant Mechanism_Type := -1;
-- Passing by copy is forced. The exact meaning of By_Copy (e.g. whether
-- at a low level the value is passed in registers, or the value is copied
-- and a pointer is passed), is determined by the backend in accordance
-- with requirements imposed by the ABI. Note that in the extended import
-- and export pragma mechanisms, this is called Value, rather than Copy.
By_Reference : constant Mechanism_Type := -2;
-- Passing by reference is forced. This is always equivalent to passing
-- a simple pointer in the case of subprograms with a foreign convention.
-- For unconstrained arrays passed to foreign convention subprograms, the
-- address of the first element of the array is passed. For convention
-- Ada, the result is logically to pass a reference, but the precise
-- mechanism (e.g. to pass bounds of unconstrained types and other needed
-- special information) is determined by the backend in accordance with
-- requirements imposed by the ABI as interpreted for Ada.
By_Descriptor : constant Mechanism_Type := -3;
By_Descriptor_UBS : constant Mechanism_Type := -4;
By_Descriptor_UBSB : constant Mechanism_Type := -5;
By_Descriptor_UBA : constant Mechanism_Type := -6;
By_Descriptor_S : constant Mechanism_Type := -7;
By_Descriptor_SB : constant Mechanism_Type := -8;
By_Descriptor_A : constant Mechanism_Type := -9;
By_Descriptor_NCA : constant Mechanism_Type := -10;
-- These values are used only in OpenVMS ports of GNAT. Pass by descriptor
-- is forced, as described in the OpenVMS ABI. The suffix indicates the
-- descriptor type:
--
-- UBS unaligned bit string
-- UBSB aligned bit string with arbitrary bounds
-- UBA unaligned bit array
-- S string, also a scalar or access type parameter
-- SB string with arbitrary bounds
-- A contiguous array
-- NCA non-contiguous array
--
-- Note: the form with no suffix is used if the Import/Export pragma
-- uses the simple form of the mechanism name where no descriptor
-- type is supplied. In this case the back end assigns a descriptor
-- type based on the Ada type in accordance with the OpenVMS ABI.
subtype Descriptor_Codes is Mechanism_Type
range By_Descriptor_NCA .. By_Descriptor;
-- Subtype including all descriptor mechanisms
-- All the above special values are non-positive. Positive values for
-- Mechanism_Type values have a special meaning. They are used only in
-- the case of records, as a result of the use of the C_Pass_By_Copy
-- pragma, and the meaning is that if the size of the record is known
-- at compile time and does not exceed the mechanism type value, then
-- By_Copy passing is forced, otherwise By_Reference is forced.
----------------------
-- Global Variables --
----------------------
Default_C_Record_Mechanism : Mechanism_Type := By_Reference;
-- This value is the default mechanism used for C convention records
-- in foreign-convention subprograms if no mechanism is otherwise
-- specified. This value is modified appropriately by the occurrence
-- of a C_Pass_By_Copy configuration pragma.
-----------------
-- Subprograms --
-----------------
procedure Set_Mechanisms (E : Entity_Id);
-- E is a subprogram or subprogram type that has been frozen, so the
-- convention of the subprogram and all its formal types and result
-- type in the case of a function are established. The function of
-- this call is to set mechanism values for formals and for the
-- function return if they have not already been explicitly set by
-- a use of an extended Import or Export pragma. The idea is to set
-- mechanism values whereever the semantics is dictated by either
-- requirements or implementation advice in the RM, and to leave
-- the mechanism set to Default if there is no requirement, so that
-- the back-end is free to choose the most efficient method.
procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
-- Mech is a parameter passing mechanism (see Import_Function syntax
-- for MECHANISM_NAME). This routine checks that the mechanism argument
-- has the right form, and if not issues an error message. If the
-- argument has the right form then the Mechanism field of Ent is
-- set appropriately. It also performs some error checks. Note that
-- the mechanism name has not been analyzed (and cannot indeed be
-- analyzed, since it is semantic nonsense), so we get it in the
-- exact form created by the parser.
procedure Set_Mechanism_With_Checks
(Ent : Entity_Id;
Mech : Mechanism_Type;
Enod : Node_Id);
-- Sets the mechanism of Ent to the given Mech value, after first checking
-- that the request makes sense. If it does not make sense, a warning is
-- posted on node Enod, and the Mechanism of Ent is unchanged.
end Sem_Mech;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure RungeKutta is
type Floaty is digits 15;
type Floaty_Array is array (Natural range <>) of Floaty;
package FIO is new Ada.Text_IO.Float_IO(Floaty); use FIO;
type Derivative is access function(t, y : Floaty) return Floaty;
package Math is new Ada.Numerics.Generic_Elementary_Functions (Floaty);
function calc_err (t, calc : Floaty) return Floaty;
procedure Runge (yp_func : Derivative; t, y : in out Floaty_Array;
dt : Floaty) is
dy1, dy2, dy3, dy4 : Floaty;
begin
for n in t'First .. t'Last-1 loop
dy1 := dt * yp_func(t(n), y(n));
dy2 := dt * yp_func(t(n) + dt / 2.0, y(n) + dy1 / 2.0);
dy3 := dt * yp_func(t(n) + dt / 2.0, y(n) + dy2 / 2.0);
dy4 := dt * yp_func(t(n) + dt, y(n) + dy3);
t(n+1) := t(n) + dt;
y(n+1) := y(n) + (dy1 + 2.0 * (dy2 + dy3) + dy4) / 6.0;
end loop;
end Runge;
procedure Print (t, y : Floaty_Array; modnum : Positive) is begin
for i in t'Range loop
if i mod modnum = 0 then
Put("y("); Put (t(i), Exp=>0, Fore=>0, Aft=>1);
Put(") = "); Put (y(i), Exp=>0, Fore=>0, Aft=>8);
Put(" Error:"); Put (calc_err(t(i),y(i)), Aft=>5);
New_Line;
end if;
end loop;
end Print;
function yprime (t, y : Floaty) return Floaty is begin
return t * Math.Sqrt (y);
end yprime;
function calc_err (t, calc : Floaty) return Floaty is
actual : constant Floaty := (t**2 + 4.0)**2 / 16.0;
begin return abs(actual-calc);
end calc_err;
dt : constant Floaty := 0.10;
N : constant Positive := 100;
t_arr, y_arr : Floaty_Array(0 .. N);
begin
t_arr(0) := 0.0;
y_arr(0) := 1.0;
Runge (yprime'Access, t_arr, y_arr, dt);
Print (t_arr, y_arr, 10);
end RungeKutta;
|
with DDS.Typed_DataWriter_Generic;
with DDS.Typed_DataReader_Generic;
with DDS.Entity_Impl;
with DDS.Topic;
with DDS.DomainParticipant;
with DDS.Subscriber;
with DDS.Publisher;
with DDS.Request_Reply.impl;
private with RTIDDS.Low_Level.ndds_connext_c_connext_c_requester_h;
generic
with package Request_DataWriters is new DDS.Typed_DataWriter_Generic (<>);
with package Reply_DataReaders is new DDS.Typed_DataReader_Generic (<>);
package DDS.Request_Reply.Request_Generic is
type Ref (<>) is limited new Dds.Request_Reply.impl.Ref and Dds.Request_Reply.Ref with private;
type Ref_Access is access all Ref'Class;
function Create (Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String) return Ref_Access;
function Create (Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Datawriter_Qos : DDS.DataWriterQoS := DDS.Publisher.DATAWRITER_QOS_DEFAULT;
Datareader_Qos : DDS.DataReaderQoS := DDS.Subscriber.DATAREADER_QOS_DEFAULT;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access) return Ref_Access;
function Create (Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Qos_Library_Name : DDS.String;
Qos_Profile_Name : DDS.String) return Ref_Access;
function Create (Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Request_Topic_Name : DDS.String;
Reply_Topic_Name : DDS.String;
Qos_Library_Name : DDS.String;
Qos_Profile_Name : DDS.String;
Publisher : DDS.Publisher.Ref_Access := null;
Subscriber : DDS.Subscriber.Ref_Access := null) return Ref_Access;
procedure Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type);
function Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type) return Reply_DataReaders.Container;
function Send_Request
(Self : not null access Ref;
Request : Request_DataWriters.Treats.Data_Type) return Reply_DataReaders.Container;
function Send_Request
(Self : not null access Ref;
Request : Request_DataWriters.Treats.Data_Type) return Reply_DataReaders.Treats.Data_Type;
function Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T := DURATION_INFINITE) return Reply_DataReaders.Container;
procedure Send_Request
(Self : not null access Ref;
Request : access Request_DataWriters.Treats.Data_Type;
Request_Info : DDS.WriteParams_T);
function Receive_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Info_Seq : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Receive_Reply
(Self : not null access Ref;
Timeout : DDS.Duration_T) return Reply_DataReaders.Container;
function Receive_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Receive_Replies
(Self : not null access Ref;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T) return Reply_DataReaders.Container;
function Receive_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : Duration) return DDS.ReturnCode_T;
function Receive_Replies
(Self : not null access Ref;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : Duration) return Reply_DataReaders.Container;
function Take_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Take_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Take_Reply_For_Related_Request
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS.ReturnCode_T;
function Take_Replies_For_Related_Request
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS.ReturnCode_T;
function Take_Replies_For_Related_Request
(Self : not null access Ref;
Related_Request_Info : not null access DDS.SampleIdentity_T) return Reply_DataReaders.Container;
function Read_Reply
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Read_Replies
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T) return DDS.ReturnCode_T;
function Read_Replies
(Self : not null access Ref;
Min_Reply_Count : DDS.Natural;
Max_Reply_Count : DDS.Long;
Timeout : DDS.Duration_T) return Reply_DataReaders.Container'Class;
function Read_Reply_For_Related_Request
(Self : not null access Ref;
Replies : aliased Reply_DataReaders.Treats.Data_Type;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS.ReturnCode_T;
function Read_Replies_For_Related_Request
(Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : not null access DDS.SampleInfo_Seq.Sequence;
Related_Request_Info : not null access DDS.SampleIdentity_T) return DDS.ReturnCode_T;
function Read_Replies_For_Related_Request
(Self : not null access Ref;
Related_Request_Info : not null access DDS.SampleIdentity_T) return Reply_DataReaders.Container'Class;
procedure Return_Loan (Self : not null access Ref;
Replies : not null Reply_DataReaders.Treats.Data_Sequences.Sequence_Access;
Sample_Info : DDS.SampleInfo_Seq.Sequence_Access);
procedure Delete (This : in out Ref);
procedure Wait_For_Replies
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : DDS.Duration_T);
procedure Wait_For_Replies
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : Duration);
procedure Wait_For_Replies
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : Ada.Real_Time.Time_Span);
procedure Wait_For_Replies_For_Related_Reques
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : DDS.Duration_T;
Related_Request_Id : access DDS.SampleIdentity_T);
procedure Wait_For_Replies_For_Related_Reques
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : Duration;
Related_Request_Id : access DDS.SampleIdentity_T);
procedure Wait_For_Replies_For_Related_Reques
(This : in out Ref;
Min_Count : Dds.Long;
Max_Wait : Ada.Real_Time.Time_Span;
Related_Request_Id : access DDS.SampleIdentity_T);
function Get_Request_DataWriter (Self : not null access Ref) return Request_DataWriters.Ref_Access;
function Get_Reply_DataReader (Self : not null access Ref) return Reply_DataReaders.Ref_Access;
private
type Request_Params is new RTIDDS.Low_Level.Ndds_Connext_C_Connext_C_Requester_H.RTI_Connext_RequesterParams;
function Create (Participant : not null DDS.DomainParticipant.Ref_Access;
Params : in Request_Params) return Ref_Access;
type Ref is limited new Dds.Request_Reply.Impl.Ref and Dds.Request_Reply.Ref with record
Request_Topic : DDS.Topic.Ref_Access;
Reply_Topic : DDS.Topic.Ref_Access;
Request_DataWriter : Request_DataWriters.Ref_Access;
Reply_DataReader : Reply_DataReaders.Ref_Access;
end record;
end Dds.Request_Reply.Request_Generic;
|
with Memory.RAM; use Memory.RAM;
with Memory.SPM; use Memory.SPM;
package body Test.SPM is
procedure Run_Tests is
ram : constant RAM_Pointer := Create_RAM(latency => 100,
word_size => 8);
spm : SPM_Pointer := Create_SPM(ram, 1024, 1);
begin
Check(Get_Time(spm.all) = 0);
Check(Get_Writes(spm.all) = 0);
Check(Get_Cost(spm.all) = 1);
Read(spm.all, 0, 1);
Check(Get_Time(spm.all) = 1);
Check(Get_Writes(spm.all) = 0);
Read(spm.all, 1024 - 8, 8);
Check(Get_Time(spm.all) = 2);
Check(Get_Writes(spm.all) = 0);
Read(spm.all, 1024, 4);
Check(Get_Time(spm.all) = 102);
Check(Get_Writes(spm.all) = 0);
Read(spm.all, 1023, 2);
Check(Get_Time(spm.all) = 202);
Check(Get_Writes(spm.all) = 0);
Write(spm.all, 1024, 1);
Check(Get_Time(spm.all) = 302);
Check(Get_Writes(spm.all) = 1);
Write(spm.all, 8, 1);
Check(Get_Time(spm.all) = 303);
Check(Get_Writes(spm.all) = 1);
Write(spm.all, 8192, 16);
Check(Get_Time(spm.all) = 503);
Check(Get_Writes(spm.all) = 2);
Destroy(Memory_Pointer(spm));
end Run_Tests;
end Test.SPM;
|
-----------------------------------------------------------------------
-- ado-drivers-tests -- Unit tests for database drivers
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with ADO.Drivers.Connections;
package body ADO.Drivers.Tests is
use ADO.Drivers.Connections;
package Caller is new Util.Test_Caller (Test, "ADO.Drivers");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Drivers.Get_Config",
Test_Get_Config'Access);
Caller.Add_Test (Suite, "Test ADO.Drivers.Get_Driver",
Test_Get_Driver'Access);
Caller.Add_Test (Suite, "Test ADO.Drivers.Get_Driver_Index",
Test_Get_Driver_Index'Access);
Caller.Add_Test (Suite, "Test ADO.Drivers.Get_Driver",
Test_Load_Invalid_Driver'Access);
end Add_Tests;
-- ------------------------------
-- Test the Get_Config operation.
-- ------------------------------
procedure Test_Get_Config (T : in out Test) is
begin
T.Assert (ADO.Drivers.Get_Config ("test.database")'Length > 0,
"The Get_Config operation returned no value for the test database");
end Test_Get_Config;
-- ------------------------------
-- Test the Get_Driver operation.
-- ------------------------------
procedure Test_Get_Driver (T : in out Test) is
Mysql_Driver : constant Driver_Access := ADO.Drivers.Connections.Get_Driver ("mysql");
Sqlite_Driver : constant Driver_Access := ADO.Drivers.Connections.Get_Driver ("sqlite");
begin
T.Assert (Mysql_Driver /= null or Sqlite_Driver /= null,
"No database driver was found!");
end Test_Get_Driver;
-- ------------------------------
-- Test loading some invalid database driver.
-- ------------------------------
procedure Test_Load_Invalid_Driver (T : in out Test) is
Invalid_Driver : constant Driver_Access := ADO.Drivers.Connections.Get_Driver ("invalid");
begin
T.Assert (Invalid_Driver = null,
"The Get_Driver operation must return null for invalid drivers");
end Test_Load_Invalid_Driver;
-- ------------------------------
-- Test the Get_Driver_Index operation.
-- ------------------------------
procedure Test_Get_Driver_Index (T : in out Test) is
Mysql_Driver : constant Driver_Access := ADO.Drivers.Connections.Get_Driver ("mysql");
Sqlite_Driver : constant Driver_Access := ADO.Drivers.Connections.Get_Driver ("sqlite");
begin
if Mysql_Driver /= null then
T.Assert (Mysql_Driver.Get_Driver_Index > 0, "The driver index must be positive");
end if;
if Sqlite_Driver /= null then
T.Assert (Sqlite_Driver.Get_Driver_Index > 0, "The driver index must be positive");
end if;
if Mysql_Driver /= null and Sqlite_Driver /= null then
T.Assert (Mysql_Driver.Get_Driver_Index /= Sqlite_Driver.Get_Driver_Index,
"Two drivers must have different driver indexes");
end if;
end Test_Get_Driver_Index;
end ADO.Drivers.Tests;
|
with Cairo;
with Cairo.Image_Surface; use Cairo.Image_Surface;
package Screen_Parameters is
subtype Width is Natural range 0 .. 799;
subtype Height is Natural range 0 .. 479;
subtype Color is ARGB32_Data;
end Screen_Parameters;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- N M A K E --
-- --
-- S p e c --
-- --
-- Generated by xnmake revision 1.2 using --
-- sinfo.ads revision 1.6 --
-- nmake.adt revision 1.1 --
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram order checking, since the routines here are
-- generated automatically in order.
with Nlists; use Nlists;
with Types; use Types;
with Uintp; use Uintp;
with Urealp; use Urealp;
package Nmake is
-- This package contains a set of routines used to construct tree nodes
-- using a functional style. There is one routine for each node type defined
-- in Sinfo with the general interface:
-- function Make_xxx (Sloc : Source_Ptr,
-- Field_Name_1 : Field_Name_1_Type [:= default]
-- Field_Name_2 : Field_Name_2_Type [:= default]
-- ...)
-- return Node_Id
-- Only syntactic fields are included (i.e. fields marked as "-Sem" or "-Lib"
-- in the Sinfo spec are excluded). In addition, the following four syntactic
-- fields are excluded:
-- Prev_Ids
-- More_Ids
-- Comes_From_Source
-- Paren_Count
-- since they are very rarely set in expanded code. If they need to be set,
-- to other than the default values (False, False, False, zero), then the
-- appropriate Set_xxx procedures must be used on the returned value.
-- Default values are provided only for flag fields (where the default is
-- False), and for optional fields. An optional field is one where the
-- comment line describing the field contains the string "(set to xxx if".
-- For such fields, a default value of xxx is provided."
-- Warning: since calls to Make_xxx routines are normal function calls, the
-- arguments can be evaluated in any order. This means that at most one such
-- argument can have side effects (e.g. be a call to a parse routine).
function Make_Unused_At_Start (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Unused_At_Start);
function Make_Unused_At_End (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Unused_At_End);
function Make_Identifier (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id;
pragma Inline (Make_Identifier);
function Make_Integer_Literal (Sloc : Source_Ptr;
Intval : Uint)
return Node_Id;
pragma Inline (Make_Integer_Literal);
function Make_Real_Literal (Sloc : Source_Ptr;
Realval : Ureal)
return Node_Id;
pragma Inline (Make_Real_Literal);
function Make_Character_Literal (Sloc : Source_Ptr;
Chars : Name_Id;
Char_Literal_Value : Char_Code)
return Node_Id;
pragma Inline (Make_Character_Literal);
function Make_String_Literal (Sloc : Source_Ptr;
Strval : String_Id)
return Node_Id;
pragma Inline (Make_String_Literal);
function Make_Pragma (Sloc : Source_Ptr;
Chars : Name_Id;
Pragma_Argument_Associations : List_Id := No_List;
Debug_Statement : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Pragma);
function Make_Pragma_Argument_Association (Sloc : Source_Ptr;
Chars : Name_Id := No_Name;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Pragma_Argument_Association);
function Make_Defining_Identifier (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id;
pragma Inline (Make_Defining_Identifier);
function Make_Full_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Type_Definition : Node_Id)
return Node_Id;
pragma Inline (Make_Full_Type_Declaration);
function Make_Subtype_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Subtype_Indication : Node_Id)
return Node_Id;
pragma Inline (Make_Subtype_Declaration);
function Make_Subtype_Indication (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Constraint : Node_Id)
return Node_Id;
pragma Inline (Make_Subtype_Indication);
function Make_Object_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Aliased_Present : Boolean := False;
Constant_Present : Boolean := False;
Object_Definition : Node_Id;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Object_Declaration);
function Make_Number_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Number_Declaration);
function Make_Derived_Type_Definition (Sloc : Source_Ptr;
Abstract_Present : Boolean := False;
Subtype_Indication : Node_Id;
Record_Extension_Part : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Derived_Type_Definition);
function Make_Range_Constraint (Sloc : Source_Ptr;
Range_Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Range_Constraint);
function Make_Range (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id;
Includes_Infinities : Boolean := False)
return Node_Id;
pragma Inline (Make_Range);
function Make_Enumeration_Type_Definition (Sloc : Source_Ptr;
Literals : List_Id)
return Node_Id;
pragma Inline (Make_Enumeration_Type_Definition);
function Make_Defining_Character_Literal (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id;
pragma Inline (Make_Defining_Character_Literal);
function Make_Signed_Integer_Type_Definition (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id)
return Node_Id;
pragma Inline (Make_Signed_Integer_Type_Definition);
function Make_Modular_Type_Definition (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Modular_Type_Definition);
function Make_Floating_Point_Definition (Sloc : Source_Ptr;
Digits_Expression : Node_Id;
Real_Range_Specification : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Floating_Point_Definition);
function Make_Real_Range_Specification (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id)
return Node_Id;
pragma Inline (Make_Real_Range_Specification);
function Make_Ordinary_Fixed_Point_Definition (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Real_Range_Specification : Node_Id)
return Node_Id;
pragma Inline (Make_Ordinary_Fixed_Point_Definition);
function Make_Decimal_Fixed_Point_Definition (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Digits_Expression : Node_Id;
Real_Range_Specification : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Decimal_Fixed_Point_Definition);
function Make_Digits_Constraint (Sloc : Source_Ptr;
Digits_Expression : Node_Id;
Range_Constraint : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Digits_Constraint);
function Make_Unconstrained_Array_Definition (Sloc : Source_Ptr;
Subtype_Marks : List_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id;
pragma Inline (Make_Unconstrained_Array_Definition);
function Make_Constrained_Array_Definition (Sloc : Source_Ptr;
Discrete_Subtype_Definitions : List_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id;
pragma Inline (Make_Constrained_Array_Definition);
function Make_Discriminant_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Type : Node_Id;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Discriminant_Specification);
function Make_Index_Or_Discriminant_Constraint (Sloc : Source_Ptr;
Constraints : List_Id)
return Node_Id;
pragma Inline (Make_Index_Or_Discriminant_Constraint);
function Make_Discriminant_Association (Sloc : Source_Ptr;
Selector_Names : List_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Discriminant_Association);
function Make_Record_Definition (Sloc : Source_Ptr;
End_Label : Node_Id := Empty;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False;
Component_List : Node_Id;
Null_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Record_Definition);
function Make_Component_List (Sloc : Source_Ptr;
Component_Items : List_Id;
Variant_Part : Node_Id := Empty;
Null_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Component_List);
function Make_Component_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Component_Declaration);
function Make_Variant_Part (Sloc : Source_Ptr;
Name : Node_Id;
Variants : List_Id)
return Node_Id;
pragma Inline (Make_Variant_Part);
function Make_Variant (Sloc : Source_Ptr;
Discrete_Choices : List_Id;
Component_List : Node_Id)
return Node_Id;
pragma Inline (Make_Variant);
function Make_Others_Choice (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Others_Choice);
function Make_Access_To_Object_Definition (Sloc : Source_Ptr;
All_Present : Boolean := False;
Subtype_Indication : Node_Id;
Constant_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Access_To_Object_Definition);
function Make_Access_Function_Definition (Sloc : Source_Ptr;
Protected_Present : Boolean := False;
Parameter_Specifications : List_Id := No_List;
Subtype_Mark : Node_Id)
return Node_Id;
pragma Inline (Make_Access_Function_Definition);
function Make_Access_Procedure_Definition (Sloc : Source_Ptr;
Protected_Present : Boolean := False;
Parameter_Specifications : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Access_Procedure_Definition);
function Make_Access_Definition (Sloc : Source_Ptr;
Subtype_Mark : Node_Id)
return Node_Id;
pragma Inline (Make_Access_Definition);
function Make_Incomplete_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Incomplete_Type_Declaration);
function Make_Explicit_Dereference (Sloc : Source_Ptr;
Prefix : Node_Id)
return Node_Id;
pragma Inline (Make_Explicit_Dereference);
function Make_Indexed_Component (Sloc : Source_Ptr;
Prefix : Node_Id;
Expressions : List_Id)
return Node_Id;
pragma Inline (Make_Indexed_Component);
function Make_Slice (Sloc : Source_Ptr;
Prefix : Node_Id;
Discrete_Range : Node_Id)
return Node_Id;
pragma Inline (Make_Slice);
function Make_Selected_Component (Sloc : Source_Ptr;
Prefix : Node_Id;
Selector_Name : Node_Id)
return Node_Id;
pragma Inline (Make_Selected_Component);
function Make_Attribute_Reference (Sloc : Source_Ptr;
Prefix : Node_Id;
Attribute_Name : Name_Id;
Expressions : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Attribute_Reference);
function Make_Aggregate (Sloc : Source_Ptr;
Expressions : List_Id := No_List;
Component_Associations : List_Id := No_List;
Null_Record_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Aggregate);
function Make_Component_Association (Sloc : Source_Ptr;
Choices : List_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Component_Association);
function Make_Extension_Aggregate (Sloc : Source_Ptr;
Ancestor_Part : Node_Id;
Expressions : List_Id := No_List;
Component_Associations : List_Id := No_List;
Null_Record_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Extension_Aggregate);
function Make_Null (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Null);
function Make_And_Then (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_And_Then);
function Make_Or_Else (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Or_Else);
function Make_In (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_In);
function Make_Not_In (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Not_In);
function Make_Op_And (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_And);
function Make_Op_Or (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Or);
function Make_Op_Xor (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Xor);
function Make_Op_Eq (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Eq);
function Make_Op_Ne (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Ne);
function Make_Op_Lt (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Lt);
function Make_Op_Le (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Le);
function Make_Op_Gt (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Gt);
function Make_Op_Ge (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Ge);
function Make_Op_Add (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Add);
function Make_Op_Subtract (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Subtract);
function Make_Op_Concat (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Concat);
function Make_Op_Multiply (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Multiply);
function Make_Op_Divide (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Divide);
function Make_Op_Mod (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Mod);
function Make_Op_Rem (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Rem);
function Make_Op_Expon (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Expon);
function Make_Op_Plus (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Plus);
function Make_Op_Minus (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Minus);
function Make_Op_Abs (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Abs);
function Make_Op_Not (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Not);
function Make_Type_Conversion (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Type_Conversion);
function Make_Qualified_Expression (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Qualified_Expression);
function Make_Allocator (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Allocator);
function Make_Null_Statement (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Null_Statement);
function Make_Label (Sloc : Source_Ptr;
Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Label);
function Make_Assignment_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Assignment_Statement);
function Make_If_Statement (Sloc : Source_Ptr;
Condition : Node_Id;
Then_Statements : List_Id;
Elsif_Parts : List_Id := No_List;
Else_Statements : List_Id := No_List;
End_Span : Uint := No_Uint)
return Node_Id;
pragma Inline (Make_If_Statement);
function Make_Elsif_Part (Sloc : Source_Ptr;
Condition : Node_Id;
Then_Statements : List_Id)
return Node_Id;
pragma Inline (Make_Elsif_Part);
function Make_Case_Statement (Sloc : Source_Ptr;
Expression : Node_Id;
Alternatives : List_Id;
End_Span : Uint := No_Uint)
return Node_Id;
pragma Inline (Make_Case_Statement);
function Make_Case_Statement_Alternative (Sloc : Source_Ptr;
Discrete_Choices : List_Id;
Statements : List_Id)
return Node_Id;
pragma Inline (Make_Case_Statement_Alternative);
function Make_Loop_Statement (Sloc : Source_Ptr;
Identifier : Node_Id := Empty;
Iteration_Scheme : Node_Id := Empty;
Statements : List_Id;
End_Label : Node_Id;
Has_Created_Identifier : Boolean := False)
return Node_Id;
pragma Inline (Make_Loop_Statement);
function Make_Iteration_Scheme (Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Loop_Parameter_Specification : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Iteration_Scheme);
function Make_Loop_Parameter_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Reverse_Present : Boolean := False;
Discrete_Subtype_Definition : Node_Id)
return Node_Id;
pragma Inline (Make_Loop_Parameter_Specification);
function Make_Block_Statement (Sloc : Source_Ptr;
Identifier : Node_Id := Empty;
Declarations : List_Id := No_List;
Handled_Statement_Sequence : Node_Id;
Has_Created_Identifier : Boolean := False;
Is_Task_Allocation_Block : Boolean := False;
Is_Asynchronous_Call_Block : Boolean := False)
return Node_Id;
pragma Inline (Make_Block_Statement);
function Make_Exit_Statement (Sloc : Source_Ptr;
Name : Node_Id := Empty;
Condition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Exit_Statement);
function Make_Goto_Statement (Sloc : Source_Ptr;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Goto_Statement);
function Make_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id;
pragma Inline (Make_Subprogram_Declaration);
function Make_Abstract_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id;
pragma Inline (Make_Abstract_Subprogram_Declaration);
function Make_Function_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Parameter_Specifications : List_Id := No_List;
Subtype_Mark : Node_Id)
return Node_Id;
pragma Inline (Make_Function_Specification);
function Make_Procedure_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Parameter_Specifications : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Procedure_Specification);
function Make_Designator (Sloc : Source_Ptr;
Name : Node_Id;
Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Designator);
function Make_Defining_Program_Unit_Name (Sloc : Source_Ptr;
Name : Node_Id;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Defining_Program_Unit_Name);
function Make_Operator_Symbol (Sloc : Source_Ptr;
Chars : Name_Id;
Strval : String_Id)
return Node_Id;
pragma Inline (Make_Operator_Symbol);
function Make_Defining_Operator_Symbol (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id;
pragma Inline (Make_Defining_Operator_Symbol);
function Make_Parameter_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
In_Present : Boolean := False;
Out_Present : Boolean := False;
Parameter_Type : Node_Id;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Parameter_Specification);
function Make_Subprogram_Body (Sloc : Source_Ptr;
Specification : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id;
Bad_Is_Detected : Boolean := False)
return Node_Id;
pragma Inline (Make_Subprogram_Body);
function Make_Procedure_Call_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Procedure_Call_Statement);
function Make_Function_Call (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Function_Call);
function Make_Parameter_Association (Sloc : Source_Ptr;
Selector_Name : Node_Id;
Explicit_Actual_Parameter : Node_Id)
return Node_Id;
pragma Inline (Make_Parameter_Association);
function Make_Return_Statement (Sloc : Source_Ptr;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Return_Statement);
function Make_Package_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id;
pragma Inline (Make_Package_Declaration);
function Make_Package_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id;
pragma Inline (Make_Package_Specification);
function Make_Package_Body (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Package_Body);
function Make_Private_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Private_Type_Declaration);
function Make_Private_Extension_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False;
Abstract_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id;
pragma Inline (Make_Private_Extension_Declaration);
function Make_Use_Package_Clause (Sloc : Source_Ptr;
Names : List_Id)
return Node_Id;
pragma Inline (Make_Use_Package_Clause);
function Make_Use_Type_Clause (Sloc : Source_Ptr;
Subtype_Marks : List_Id)
return Node_Id;
pragma Inline (Make_Use_Type_Clause);
function Make_Object_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Subtype_Mark : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Object_Renaming_Declaration);
function Make_Exception_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Exception_Renaming_Declaration);
function Make_Package_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Package_Renaming_Declaration);
function Make_Subprogram_Renaming_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Subprogram_Renaming_Declaration);
function Make_Generic_Package_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Generic_Package_Renaming_Declaration);
function Make_Generic_Procedure_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Generic_Procedure_Renaming_Declaration);
function Make_Generic_Function_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id;
pragma Inline (Make_Generic_Function_Renaming_Declaration);
function Make_Task_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Task_Definition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Task_Type_Declaration);
function Make_Single_Task_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Task_Definition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Single_Task_Declaration);
function Make_Task_Definition (Sloc : Source_Ptr;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id;
pragma Inline (Make_Task_Definition);
function Make_Task_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id)
return Node_Id;
pragma Inline (Make_Task_Body);
function Make_Protected_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Protected_Definition : Node_Id)
return Node_Id;
pragma Inline (Make_Protected_Type_Declaration);
function Make_Single_Protected_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Protected_Definition : Node_Id)
return Node_Id;
pragma Inline (Make_Single_Protected_Declaration);
function Make_Protected_Definition (Sloc : Source_Ptr;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id;
pragma Inline (Make_Protected_Definition);
function Make_Protected_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Declarations : List_Id;
End_Label : Node_Id)
return Node_Id;
pragma Inline (Make_Protected_Body);
function Make_Entry_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discrete_Subtype_Definition : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Entry_Declaration);
function Make_Accept_Statement (Sloc : Source_Ptr;
Entry_Direct_Name : Node_Id;
Entry_Index : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List;
Handled_Statement_Sequence : Node_Id;
Declarations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Accept_Statement);
function Make_Entry_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Entry_Body_Formal_Part : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id)
return Node_Id;
pragma Inline (Make_Entry_Body);
function Make_Entry_Body_Formal_Part (Sloc : Source_Ptr;
Entry_Index_Specification : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List;
Condition : Node_Id)
return Node_Id;
pragma Inline (Make_Entry_Body_Formal_Part);
function Make_Entry_Index_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discrete_Subtype_Definition : Node_Id)
return Node_Id;
pragma Inline (Make_Entry_Index_Specification);
function Make_Entry_Call_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Entry_Call_Statement);
function Make_Requeue_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Abort_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Requeue_Statement);
function Make_Delay_Until_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Delay_Until_Statement);
function Make_Delay_Relative_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Delay_Relative_Statement);
function Make_Selective_Accept (Sloc : Source_Ptr;
Select_Alternatives : List_Id;
Else_Statements : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Selective_Accept);
function Make_Accept_Alternative (Sloc : Source_Ptr;
Accept_Statement : Node_Id;
Condition : Node_Id := Empty;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Accept_Alternative);
function Make_Delay_Alternative (Sloc : Source_Ptr;
Delay_Statement : Node_Id;
Condition : Node_Id := Empty;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Delay_Alternative);
function Make_Terminate_Alternative (Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Pragmas_Before : List_Id := No_List;
Pragmas_After : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Terminate_Alternative);
function Make_Timed_Entry_Call (Sloc : Source_Ptr;
Entry_Call_Alternative : Node_Id;
Delay_Alternative : Node_Id)
return Node_Id;
pragma Inline (Make_Timed_Entry_Call);
function Make_Entry_Call_Alternative (Sloc : Source_Ptr;
Entry_Call_Statement : Node_Id;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Entry_Call_Alternative);
function Make_Conditional_Entry_Call (Sloc : Source_Ptr;
Entry_Call_Alternative : Node_Id;
Else_Statements : List_Id)
return Node_Id;
pragma Inline (Make_Conditional_Entry_Call);
function Make_Asynchronous_Select (Sloc : Source_Ptr;
Triggering_Alternative : Node_Id;
Abortable_Part : Node_Id)
return Node_Id;
pragma Inline (Make_Asynchronous_Select);
function Make_Triggering_Alternative (Sloc : Source_Ptr;
Triggering_Statement : Node_Id;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Triggering_Alternative);
function Make_Abortable_Part (Sloc : Source_Ptr;
Statements : List_Id)
return Node_Id;
pragma Inline (Make_Abortable_Part);
function Make_Abort_Statement (Sloc : Source_Ptr;
Names : List_Id)
return Node_Id;
pragma Inline (Make_Abort_Statement);
function Make_Compilation_Unit (Sloc : Source_Ptr;
Context_Items : List_Id;
Private_Present : Boolean := False;
Unit : Node_Id;
Aux_Decls_Node : Node_Id)
return Node_Id;
pragma Inline (Make_Compilation_Unit);
function Make_Compilation_Unit_Aux (Sloc : Source_Ptr;
Declarations : List_Id := No_List;
Actions : List_Id := No_List;
Pragmas_After : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Compilation_Unit_Aux);
function Make_With_Clause (Sloc : Source_Ptr;
Name : Node_Id;
First_Name : Boolean := True;
Last_Name : Boolean := True)
return Node_Id;
pragma Inline (Make_With_Clause);
function Make_With_Type_Clause (Sloc : Source_Ptr;
Name : Node_Id;
Tagged_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_With_Type_Clause);
function Make_Subprogram_Body_Stub (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id;
pragma Inline (Make_Subprogram_Body_Stub);
function Make_Package_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Package_Body_Stub);
function Make_Task_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Task_Body_Stub);
function Make_Protected_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Protected_Body_Stub);
function Make_Subunit (Sloc : Source_Ptr;
Name : Node_Id;
Proper_Body : Node_Id)
return Node_Id;
pragma Inline (Make_Subunit);
function Make_Exception_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Exception_Declaration);
function Make_Handled_Sequence_Of_Statements (Sloc : Source_Ptr;
Statements : List_Id;
End_Label : Node_Id := Empty;
Exception_Handlers : List_Id := No_List;
At_End_Proc : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Handled_Sequence_Of_Statements);
function Make_Exception_Handler (Sloc : Source_Ptr;
Choice_Parameter : Node_Id := Empty;
Exception_Choices : List_Id;
Statements : List_Id)
return Node_Id;
pragma Inline (Make_Exception_Handler);
function Make_Raise_Statement (Sloc : Source_Ptr;
Name : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Raise_Statement);
function Make_Generic_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Generic_Formal_Declarations : List_Id)
return Node_Id;
pragma Inline (Make_Generic_Subprogram_Declaration);
function Make_Generic_Package_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Generic_Formal_Declarations : List_Id)
return Node_Id;
pragma Inline (Make_Generic_Package_Declaration);
function Make_Package_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Package_Instantiation);
function Make_Procedure_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Procedure_Instantiation);
function Make_Function_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Function_Instantiation);
function Make_Generic_Association (Sloc : Source_Ptr;
Selector_Name : Node_Id := Empty;
Explicit_Generic_Actual_Parameter : Node_Id)
return Node_Id;
pragma Inline (Make_Generic_Association);
function Make_Formal_Object_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
In_Present : Boolean := False;
Out_Present : Boolean := False;
Subtype_Mark : Node_Id;
Expression : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Formal_Object_Declaration);
function Make_Formal_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Formal_Type_Definition : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Formal_Type_Declaration);
function Make_Formal_Private_Type_Definition (Sloc : Source_Ptr;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Formal_Private_Type_Definition);
function Make_Formal_Derived_Type_Definition (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Private_Present : Boolean := False;
Abstract_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Formal_Derived_Type_Definition);
function Make_Formal_Discrete_Type_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Discrete_Type_Definition);
function Make_Formal_Signed_Integer_Type_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Signed_Integer_Type_Definition);
function Make_Formal_Modular_Type_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Modular_Type_Definition);
function Make_Formal_Floating_Point_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Floating_Point_Definition);
function Make_Formal_Ordinary_Fixed_Point_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Ordinary_Fixed_Point_Definition);
function Make_Formal_Decimal_Fixed_Point_Definition (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Formal_Decimal_Fixed_Point_Definition);
function Make_Formal_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Default_Name : Node_Id := Empty;
Box_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Formal_Subprogram_Declaration);
function Make_Formal_Package_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List;
Box_Present : Boolean := False)
return Node_Id;
pragma Inline (Make_Formal_Package_Declaration);
function Make_Attribute_Definition_Clause (Sloc : Source_Ptr;
Name : Node_Id;
Chars : Name_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Attribute_Definition_Clause);
function Make_Enumeration_Representation_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Array_Aggregate : Node_Id)
return Node_Id;
pragma Inline (Make_Enumeration_Representation_Clause);
function Make_Record_Representation_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Mod_Clause : Node_Id := Empty;
Component_Clauses : List_Id)
return Node_Id;
pragma Inline (Make_Record_Representation_Clause);
function Make_Component_Clause (Sloc : Source_Ptr;
Component_Name : Node_Id;
Position : Node_Id;
First_Bit : Node_Id;
Last_Bit : Node_Id)
return Node_Id;
pragma Inline (Make_Component_Clause);
function Make_Code_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Code_Statement);
function Make_Op_Rotate_Left (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Rotate_Left);
function Make_Op_Rotate_Right (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Rotate_Right);
function Make_Op_Shift_Left (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Shift_Left);
function Make_Op_Shift_Right_Arithmetic (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Shift_Right_Arithmetic);
function Make_Op_Shift_Right (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id;
pragma Inline (Make_Op_Shift_Right);
function Make_Delta_Constraint (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Range_Constraint : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Delta_Constraint);
function Make_At_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_At_Clause);
function Make_Mod_Clause (Sloc : Source_Ptr;
Expression : Node_Id;
Pragmas_Before : List_Id)
return Node_Id;
pragma Inline (Make_Mod_Clause);
function Make_Conditional_Expression (Sloc : Source_Ptr;
Expressions : List_Id)
return Node_Id;
pragma Inline (Make_Conditional_Expression);
function Make_Expanded_Name (Sloc : Source_Ptr;
Chars : Name_Id;
Prefix : Node_Id;
Selector_Name : Node_Id)
return Node_Id;
pragma Inline (Make_Expanded_Name);
function Make_Free_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Free_Statement);
function Make_Freeze_Entity (Sloc : Source_Ptr;
Actions : List_Id := No_List)
return Node_Id;
pragma Inline (Make_Freeze_Entity);
function Make_Implicit_Label_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Implicit_Label_Declaration);
function Make_Itype_Reference (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Itype_Reference);
function Make_Raise_Constraint_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Raise_Constraint_Error);
function Make_Raise_Program_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Raise_Program_Error);
function Make_Raise_Storage_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id;
pragma Inline (Make_Raise_Storage_Error);
function Make_Reference (Sloc : Source_Ptr;
Prefix : Node_Id)
return Node_Id;
pragma Inline (Make_Reference);
function Make_Subprogram_Info (Sloc : Source_Ptr;
Identifier : Node_Id)
return Node_Id;
pragma Inline (Make_Subprogram_Info);
function Make_Unchecked_Expression (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Unchecked_Expression);
function Make_Unchecked_Type_Conversion (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id;
pragma Inline (Make_Unchecked_Type_Conversion);
function Make_Validate_Unchecked_Conversion (Sloc : Source_Ptr)
return Node_Id;
pragma Inline (Make_Validate_Unchecked_Conversion);
end Nmake;
|
with Ada.Text_IO; use Ada.Text_IO;
with Oriented; use Oriented;
--with Ada.Unchecked_Deallocation;
procedure Oriented_Test is
Void_Obj : Object;
Obj2 : Object;
Obj_A : Object_Access;
Obj_A2 : Object_Access;
X : aliased Integer;
X_Ref : access Integer;
X1_Ref : access Integer;
Y_Ref : not null access Integer := X'Access;
procedure Change_Int (I : not null access Integer) is
begin
I.all := 1999;
end Change_Int;
--procedure Free_Object is new Ada.Unchecked_Deallocation
-- (Object => Object, Name => Object_Access);
begin
Void_Obj.Initialize (10);
-- Obj2 := Void_Obj; -- no, because limited
Obj_A := NewObj;
Obj_A2 := Obj_A; -- not a good idea
Put_Line (Integer'Image (Void_Obj.Get_Item_Id));
--Free_Object (Obj_A); -- ok
Put_Line ("Before");
if Obj_A /= null then
Put_Line ("Not null");
end if;
Free (Obj_A);
if Obj_A = null then
Put_Line ("Null");
end if;
if Obj_A2 /= null then
Put_Line ("Ops");
end if;
X_Ref := X'Access;
X1_Ref := X_Ref;
X := 2018;
Put_Line (Integer'Image (X_Ref.all));
Put_Line (Integer'Image (X1_Ref.all));
Y_Ref.all := 2016;
Put_Line (Integer'Image (X));
Put_Line (Integer'Image (Y_Ref.all));
Change_Int (X1_Ref);
X1_Ref := null;
-- The compiler warns us and a Constraint_Error
-- exception will be raised at runtime
--Change_Int (X1_Ref);
if X1_Ref = null then -- condition is always true!
Put_Line ("X1_Ref is really null, duh!");
end if;
X1_Ref := new Integer'(2011);
Put_Line (Integer'Image (X1_Ref.all));
Change_Int (X1_Ref);
Put_Line (Integer'Image (X1_Ref.all));
-- Y_Ref := null; -- can't do this
end Oriented_Test;
|
-- generic_list.adb -*- Ada -*-
--
-- This package defines a generic list and list iterator.
--
-- Author: Eric Gustafson
-- Date: 25 August 1998
--
-- ------------------------------------------------------------
--
-- $Revision$
--
-- $Log$
-- ------------------------------------------------------------
package body Generic_List is
-- ----- List_Type Methods ---------------------------------
procedure List_Add( List : in out List_Type;
Element : in Element_Type ) is
begin
if List.Num_Elements = List.List'Last then
declare
New_List : Element_Array_Access
:= new Element_Array(1..List.List'Last+3);
begin
New_List(List.List'Range) := List.List.all;
-- Deallocate list.list access
List.List := New_List;
end;
end if;
List.Num_Elements := List.Num_Elements + 1;
List.List(List.Num_Elements) := Element;
end List_Add;
-- ---------------------------------------------------------
function List_New_Iterator( List : in List_Type )
return List_Iterator_Type is
List_Iterator : List_Iterator_Type;
begin
List_Iterator.List := List.List;
List_Iterator.Num_Elements := List.Num_Elements;
return List_Iterator;
end List_New_Iterator;
-- ----- List_Iterator_Type Methods ------------------------
function Is_Next( List_Iterator : in List_Iterator_Type )
return Boolean is
begin
if List_Iterator.Index <= List_Iterator.Num_Elements then
return True;
else
return False;
end if;
end Is_Next;
-- ---------------------------------------------------------
procedure Get_Next( List_Iterator : in out List_Iterator_Type;
Next_Element : out Element_Type ) is
begin
if not Is_Next( List_Iterator ) then
raise Iterator_Bound_Error;
end if;
Next_Element := List_Iterator.List(List_Iterator.Index);
List_Iterator.Index := List_Iterator.Index + 1;
end Get_Next;
end Generic_List;
|
-- Copyright 2016 Steven Stewart-Gallus
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-- implied. See the License for the specific language governing
-- permissions and limitations under the License.
with Interfaces.C;
with Interfaces.C.Strings;
with Libc.Stdlib.GNU;
with Libc.Stdlib;
package body Linted.Env with
Spark_Mode => Off is
package C renames Interfaces.C;
package C_Strings renames Interfaces.C.Strings;
use type C_Strings.chars_ptr;
protected Env_Lock is
function Lock_Set
(Name : String;
Value : String;
Overwrite : Boolean) return Errors.Error;
function Lock_Get (Name : String) return String;
end Env_Lock;
procedure Set
(Name : String;
Value : String;
Overwrite : Boolean;
Err : out Errors.Error)
is
begin
Err := Env_Lock.Lock_Set (Name, Value, Overwrite);
end Set;
function Get (Name : String) return String is (Env_Lock.Lock_Get (Name));
protected body Env_Lock is
function Lock_Set
(Name : String;
Value : String;
Overwrite : Boolean) return Errors.Error
is
N : C.char_array := C.To_C (Name);
V : C.char_array := C.To_C (Value);
begin
return Errors.Error
(Libc.Stdlib.GNU.setenv (N, V, (if Overwrite then 1 else 0)));
end Lock_Set;
function Lock_Get (Name : String) return String is
N : C.char_array := C.To_C (Name);
P : C.Strings.chars_ptr;
begin
P := Libc.Stdlib.getenv (N);
if P = C.Strings.Null_Ptr then
return "";
else
return C.Strings.Value (P);
end if;
end Lock_Get;
end Env_Lock;
end Linted.Env;
|
package FLTK.Widgets.Valuators is
type Valuator is new Widget with private;
type Valuator_Reference (Data : not null access Valuator'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Valuator;
end Forge;
function Clamp
(This : in Valuator;
Input : in Long_Float)
return Long_Float;
function Round
(This : in Valuator;
Input : in Long_Float)
return Long_Float;
function Increment
(This : in Valuator;
Input : in Long_Float;
Step : in Integer)
return Long_Float;
function Get_Minimum
(This : in Valuator)
return Long_Float;
procedure Set_Minimum
(This : in out Valuator;
To : in Long_Float);
function Get_Maximum
(This : in Valuator)
return Long_Float;
procedure Set_Maximum
(This : in out Valuator;
To : in Long_Float);
function Get_Step
(This : in Valuator)
return Long_Float;
procedure Set_Step
(This : in out Valuator;
To : in Long_Float);
function Get_Value
(This : in Valuator)
return Long_Float;
procedure Set_Value
(This : in out Valuator;
To : in Long_Float);
procedure Set_Bounds
(This : in out Valuator;
Min, Max : in Long_Float);
procedure Set_Precision
(This : in out Valuator;
To : in Integer);
procedure Set_Range
(This : in out Valuator;
Min, Max : in Long_Float);
function Handle
(This : in out Valuator;
Event : in Event_Kind)
return Event_Outcome;
private
type Valuator is new Widget with null record;
overriding procedure Finalize
(This : in out Valuator);
pragma Inline (Clamp);
pragma Inline (Round);
pragma Inline (Increment);
pragma Inline (Get_Minimum);
pragma Inline (Set_Minimum);
pragma Inline (Get_Maximum);
pragma Inline (Set_Maximum);
pragma Inline (Get_Step);
pragma Inline (Set_Step);
pragma Inline (Get_Value);
pragma Inline (Set_Value);
pragma Inline (Set_Bounds);
pragma Inline (Set_Precision);
pragma Inline (Set_Range);
pragma Inline (Handle);
end FLTK.Widgets.Valuators;
|
-----------------------------------------------------------------------
-- wiki-filters -- Wiki filters
-- Copyright (C) 2015, 2016, 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.
-----------------------------------------------------------------------
package body Wiki.Filters is
-- ------------------------------
-- Add a simple node such as N_LINE_BREAK, N_HORIZONTAL_RULE or N_PARAGRAPH to the document.
-- ------------------------------
procedure Add_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Kind : in Wiki.Nodes.Simple_Node_Kind) is
begin
if Filter.Next /= null then
Filter.Next.Add_Node (Document, Kind);
else
Document.Append (Kind);
end if;
end Add_Node;
-- ------------------------------
-- Add a text content with the given format to the document.
-- ------------------------------
procedure Add_Text (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Format_Map) is
begin
if Filter.Next /= null then
Filter.Next.Add_Text (Document, Text, Format);
else
Wiki.Documents.Append (Document, Text, Format);
end if;
end Add_Text;
-- ------------------------------
-- Add a section header with the given level in the document.
-- ------------------------------
procedure Add_Header (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Header : in Wiki.Strings.WString;
Level : in Natural) is
begin
if Filter.Next /= null then
Filter.Next.Add_Header (Document, Header, Level);
else
Wiki.Documents.Append (Document, Header, Level);
end if;
end Add_Header;
-- ------------------------------
-- Push a HTML node with the given tag to the document.
-- ------------------------------
procedure Push_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Tag : in Wiki.Html_Tag;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Push_Node (Document, Tag, Attributes);
else
Document.Push_Node (Tag, Attributes);
end if;
end Push_Node;
-- ------------------------------
-- Pop a HTML node with the given tag.
-- ------------------------------
procedure Pop_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Tag : in Wiki.Html_Tag) is
begin
if Filter.Next /= null then
Filter.Next.Pop_Node (Document, Tag);
else
Document.Pop_Node (Tag);
end if;
end Pop_Node;
-- ------------------------------
-- Add a blockquote (<blockquote>). The level indicates the blockquote nested level.
-- The blockquote must be closed at the next header.
-- ------------------------------
procedure Add_Blockquote (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Level : in Natural) is
begin
if Filter.Next /= null then
Filter.Next.Add_Blockquote (Document, Level);
else
Document.Add_Blockquote (Level);
end if;
end Add_Blockquote;
-- ------------------------------
-- Add a list item (<li>). Close the previous paragraph and list item if any.
-- The list item will be closed at the next list item, next paragraph or next header.
-- ------------------------------
procedure Add_List_Item (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Level : in Positive;
Ordered : in Boolean) is
begin
if Filter.Next /= null then
Filter.Next.Add_List_Item (Document, Level, Ordered);
else
Document.Add_List_Item (Level, Ordered);
end if;
end Add_List_Item;
-- ------------------------------
-- Add a link.
-- ------------------------------
procedure Add_Link (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Link (Document, Name, Attributes);
else
Document.Add_Link (Name, Attributes);
end if;
end Add_Link;
-- ------------------------------
-- Add an image.
-- ------------------------------
procedure Add_Image (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Image (Document, Name, Attributes);
else
Document.Add_Image (Name, Attributes);
end if;
end Add_Image;
-- ------------------------------
-- Add a quote.
-- ------------------------------
procedure Add_Quote (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Quote (Document, Name, Attributes);
else
Document.Add_Quote (Name, Attributes);
end if;
end Add_Quote;
-- ------------------------------
-- Add a text block that is pre-formatted.
-- ------------------------------
procedure Add_Preformatted (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Strings.WString) is
begin
if Filter.Next /= null then
Filter.Next.Add_Preformatted (Document, Text, Format);
else
Document.Add_Preformatted (Text, Format);
end if;
end Add_Preformatted;
-- ------------------------------
-- Add a new row to the current table.
-- ------------------------------
procedure Add_Row (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Add_Row (Document);
else
Document.Add_Row;
end if;
end Add_Row;
-- ------------------------------
-- Add a column to the current table row. The column is configured with the
-- given attributes. The column content is provided through calls to Append.
-- ------------------------------
procedure Add_Column (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Column (Document, Attributes);
else
Document.Add_Column (Attributes);
end if;
end Add_Column;
-- ------------------------------
-- Finish the creation of the table.
-- ------------------------------
procedure Finish_Table (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Finish_Table (Document);
else
Document.Finish_Table;
end if;
end Finish_Table;
-- ------------------------------
-- Finish the document after complete wiki text has been parsed.
-- ------------------------------
procedure Finish (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Finish (Document);
end if;
end Finish;
-- ------------------------------
-- Add the filter at beginning of the filter chain.
-- ------------------------------
procedure Add_Filter (Chain : in out Filter_Chain;
Filter : in Filter_Type_Access) is
begin
Filter.Next := Chain.Next;
Chain.Next := Filter;
end Add_Filter;
-- ------------------------------
-- Internal operation to copy the filter chain.
-- ------------------------------
procedure Set_Chain (Chain : in out Filter_Chain;
From : in Filter_Chain'Class) is
begin
Chain.Next := From.Next;
end Set_Chain;
end Wiki.Filters;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <denkpadje@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.Characters.Latin_1;
with Ada.Numerics.Generic_Elementary_Functions;
with GL.Buffers;
with Orka.Rendering.Drawing;
with Orka.Transforms.Doubles.Matrices;
with Orka.Transforms.Doubles.Vectors;
with Orka.Transforms.Doubles.Vector_Conversions;
with Orka.Transforms.Singles.Vectors;
package body Orka.Features.Atmosphere.Rendering is
package EF is new Ada.Numerics.Generic_Elementary_Functions (GL.Types.Double);
Altitude_Hack_Threshold : constant := 8000.0;
function Create_Atmosphere
(Data : aliased Model_Data;
Location : Resources.Locations.Location_Ptr;
Parameters : Model_Parameters := (others => <>)) return Atmosphere
is
Atmosphere_Model : constant Model := Create_Model (Data'Access, Location);
Sky_GLSL : constant String := Resources.Convert
(Orka.Resources.Byte_Array'(Location.Read_Data ("atmosphere/sky.frag").Get));
use Ada.Characters.Latin_1;
use Rendering.Programs;
use Rendering.Programs.Modules;
Sky_Shader : constant String :=
"#version 420 core" & LF &
(if Data.Luminance /= None then "#define USE_LUMINANCE" & LF else "") &
"const float kLengthUnitInMeters = " & Data.Length_Unit_In_Meters'Image & ";" & LF &
Sky_GLSL & LF;
Shader_Module : constant Rendering.Programs.Modules.Module := Atmosphere_Model.Get_Shader;
begin
return Result : Atmosphere :=
(Program => Create_Program (Modules.Module_Array'
(Modules.Create_Module (Location, VS => "atmosphere/sky.vert"),
Modules.Create_Module_From_Sources (FS => Sky_Shader),
Shader_Module)),
Module => Shader_Module,
Parameters => Parameters,
Bottom_Radius => Data.Bottom_Radius,
Distance_Scale => 1.0 / Data.Length_Unit_In_Meters,
others => <>)
do
Result.Uniform_Ground_Hack := Result.Program.Uniform ("ground_hack");
Result.Uniform_Camera_Offset := Result.Program.Uniform ("camera_offset");
Result.Uniform_Camera_Pos := Result.Program.Uniform ("camera_pos");
Result.Uniform_Planet_Pos := Result.Program.Uniform ("planet_pos");
Result.Uniform_View := Result.Program.Uniform ("view");
Result.Uniform_Proj := Result.Program.Uniform ("proj");
Result.Uniform_Sun_Dir := Result.Program.Uniform ("sun_direction");
Result.Uniform_Star_Dir := Result.Program.Uniform ("star_direction");
Result.Uniform_Star_Size := Result.Program.Uniform ("star_size");
end return;
end Create_Atmosphere;
function Shader_Module (Object : Atmosphere) return Orka.Rendering.Programs.Modules.Module is
(Object.Module);
function Flattened_Vector
(Parameters : Model_Parameters;
Direction : Orka.Transforms.Doubles.Vectors.Vector4)
return Orka.Transforms.Doubles.Vectors.Vector4 is
Altitude : constant := 0.0;
Flattening : GL.Types.Double renames Parameters.Flattening;
E2 : constant GL.Types.Double := 2.0 * Flattening - Flattening**2;
N : constant GL.Types.Double := Parameters.Semi_Major_Axis /
EF.Sqrt (1.0 - E2 * Direction (Orka.Z)**2);
begin
return
(Direction (Orka.X) * (N + Altitude),
Direction (Orka.Y) * (N + Altitude),
Direction (Orka.Z) * (N * (1.0 - E2) + Altitude),
1.0);
end Flattened_Vector;
package Matrices renames Orka.Transforms.Doubles.Matrices;
procedure Render
(Object : in out Atmosphere;
Camera : Cameras.Camera_Ptr;
Planet : Behaviors.Behavior_Ptr;
Star : Behaviors.Behavior_Ptr)
is
function "*" (Left : Matrices.Matrix4; Right : Matrices.Vector4) return Matrices.Vector4
renames Matrices."*";
function "*" (Left, Right : Matrices.Matrix4) return Matrices.Matrix4 renames Matrices."*";
function Far_Plane (Value : GL.Types.Compare_Function) return GL.Types.Compare_Function is
(case Value is
when Less | LEqual => LEqual,
when Greater | GEqual => GEqual,
when others => raise Constraint_Error);
Original_Function : constant GL.Types.Compare_Function := GL.Buffers.Depth_Function;
use Orka.Transforms.Doubles.Vectors;
use Orka.Transforms.Doubles.Vector_Conversions;
use all type Orka.Transforms.Doubles.Vectors.Vector4;
Planet_To_Camera : constant Vector4 := Camera.View_Position - Planet.Position;
Planet_To_Star : constant Vector4 := Star.Position - Planet.Position;
Camera_To_Star : constant Vector4 := Star.Position - Camera.View_Position;
procedure Apply_Hacks is
GL_To_Geo : constant Matrices.Matrix4 := Matrices.R
(Matrices.Vectors.Normalize ((1.0, 1.0, 1.0, 0.0)),
(2.0 / 3.0) * Ada.Numerics.Pi);
Earth_Tilt : constant Matrices.Matrix4 := Matrices.R
(Matrices.Vectors.Normalize ((1.0, 0.0, 0.0, 0.0)),
Object.Parameters.Axial_Tilt);
Inverse_Inertial : constant Matrices.Matrix4 := Earth_Tilt * GL_To_Geo;
Camera_Normal_Inert : constant Vector4 := Normalize (Inverse_Inertial * Planet_To_Camera);
Actual_Surface : constant Vector4 := Flattened_Vector
(Object.Parameters, Camera_Normal_Inert);
Expected_Surface : constant Vector4 := Camera_Normal_Inert * Object.Bottom_Radius;
Offset : constant Vector4 := Expected_Surface - Actual_Surface;
Altitude : constant Double := Length (Planet_To_Camera) - Length (Actual_Surface);
begin
Object.Uniform_Ground_Hack.Set_Boolean (Altitude < Altitude_Hack_Threshold);
Object.Uniform_Camera_Offset.Set_Vector (Convert (Offset * Object.Distance_Scale));
end Apply_Hacks;
begin
if Object.Parameters.Flattening > 0.0 then
Apply_Hacks;
else
Object.Uniform_Ground_Hack.Set_Boolean (False);
Object.Uniform_Camera_Offset.Set_Vector (Orka.Transforms.Singles.Vectors.Zero);
end if;
Object.Uniform_Camera_Pos.Set_Vector (Orka.Transforms.Singles.Vectors.Zero);
Object.Uniform_Planet_Pos.Set_Vector (Convert (-Planet_To_Camera * Object.Distance_Scale));
Object.Uniform_Sun_Dir.Set_Vector (Convert (Normalize (Planet_To_Star)));
Object.Uniform_Star_Dir.Set_Vector (Convert (Normalize (Camera_To_Star)));
-- Use distance to star and its radius instead of the
-- Sun_Angular_Radius of Model_Data
declare
Angular_Radius : constant GL.Types.Double :=
EF.Arctan (Object.Parameters.Star_Radius, Length (Camera_To_Star));
begin
Object.Uniform_Star_Size.Set_Single (GL.Types.Single (EF.Cos (Angular_Radius)));
end;
Object.Uniform_View.Set_Matrix (Camera.View_Matrix);
Object.Uniform_Proj.Set_Matrix (Camera.Projection_Matrix);
Object.Program.Use_Program;
GL.Buffers.Set_Depth_Function (Far_Plane (Original_Function));
Orka.Rendering.Drawing.Draw (GL.Types.Triangles, 0, 3);
GL.Buffers.Set_Depth_Function (Original_Function);
end Render;
end Orka.Features.Atmosphere.Rendering;
|
--
-- 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.Strings.Fixed;
package body Errors is
type String_Access is access all String;
function "-" (Item : in String) return String_Access;
function "-" (Item : in String) return String_Access is
begin
return new String'(Item);
end "-";
type Error_Table is array (Error_Id) of String_Access;
Table : constant Error_Table :=
Error_Table'(E001 => -("There is no prior rule upon which to attach the code fragment " &
"which begins on this line."),
E002 => -("Code fragment beginning on this line is not the first to follow " &
"the previous rule."),
E003 => -"Token '$1' should be either '%%' or a nonterminal name.",
E004 => -"The precedence symbol must be a terminal.",
E005 => -"There is no prior rule to assign precedence '[$1]'.",
E006 => -("Precedence mark on this line is not the first to follow the " &
"previous rule."),
E007 => -"Missing ']' on precedence mark.",
E008 => -"Expected to see a ':' following the LHS symbol '$1'.",
E009 => -"'$1' is not a valid alias for the LHS '$2'",
E010 => -"Missing ')' following LHS alias name '$1'.",
E011 => -"Missing '->' following: '$1($2)'.",
E012 => -"'$1' is not a valid alias for the RHS symbol '$2'",
E013 => -"Missing ')' following LHS alias name '$1'.",
E014 => -("The specified start symbol '$1' Start is not in a nonterminal " &
"of the grammar. '$2' will be used as the start symbol instead."),
E015 => -("The start symbol '$1' occurs on the right-hand " &
"side of a rule. This will result in a parser which " &
"does not work properly."),
E016 => -"Can not open '$1' for reading.",
E101 => -"Can't open this file for reading.",
E102 => -("C code starting on this line is not terminated before the end " &
"of the file."),
E103 => -("String starting on this line is not terminated before the end " &
"of the file."),
E201 => -"Cannot form a compound containing a non-terminal",
E202 => -"Illegal character on RHS of rule: '$1'.",
E203 => -"Unknown declaration keyword: '%$1'.",
E204 => -"Illegal declaration keyword: '$1'.",
E205 => -"Symbol name missing after %destructor keyword",
E206 => -"Symbol name missing after %type keyword",
E207 => -"Symbol %type '$1' already defined",
E208 => -"%token_class argument '%1' should be a token",
E209 => -"%token_class must be followed by an identifier: $1",
E210 => -"Symbol '$1' already used",
E211 => -"%wildcard argument '$1' should be a token",
E212 => -"Extra wildcard to token: '$1'",
E213 => -"Illegal argument to %$1: $2",
E214 => -"%token argument $1 should be a token",
E215 => -"%fallback argument $1 should be a token",
E216 => -"More than one fallback assigned to token $1",
E217 => -"Symbol $1 has already be given a precedence.",
E218 => -"Can't assign a precedence to $1.",
E301 => -"This rule can not be reduced.",
E401 => -"Nonterminal ""$1"" has no rules."
);
procedure Parser_Error
(Id : in Error_Id;
Line : in Line_Number;
Argument_1 : in String := "";
Argument_2 : in String := "")
is
-- use Ada.Strings;
File_Name : constant String := To_String (Default_File_Name);
Kind_Image : constant String := Id'Image & " ";
Message : Unbounded_String := To_Unbounded_String (Table (Id).all);
Position : Natural := 1;
begin
-- Substitued $1 placeholder
Position := Index (Message, "$1", Position);
if Position /= 0 then
Replace_Slice (Message, Position,
Position + 2 - 1,
Argument_1);
end if;
-- Substitute $2 placeholder
Position := Index (Message, "$2", Position);
if Position /= 0 then
Replace_Slice (Message, Position,
Position + 2 - 1,
Argument_2);
end if;
Emit_Error (File => Ada.Text_IO.Standard_Output,
File_Name => File_Name,
Line => Line,
Message => Kind_Image & To_String (Message));
Error_Count := Error_Count + 1;
end Parser_Error;
procedure Set_File_Name
(File_Name : in Ada.Strings.Unbounded.Unbounded_String)
is
begin
Errors.Default_File_Name := File_Name;
end Set_File_Name;
procedure Emit_Error (File : in Ada.Text_IO.File_Type;
File_Name : in String;
Line : in Line_Number;
Message : in String)
is
use Ada.Text_IO;
use Ada.Strings;
Line_Number_Image : constant String := Fixed.Trim (Line_Number'Image (Line), Left);
begin
Put (File, File_Name);
Put (File, ":");
Put (File, Line_Number_Image);
Put (File, ": ");
Put (File, Message);
New_Line (File);
end Emit_Error;
end Errors;
|
package body aspiradora is
procedure moverse(a : in out t_aspiradora) is
begin
a.direccion := direccion.direccion_opuesta(a.direccion);
end moverse;
function limpiar(a : in out t_aspiradora) return t_estado_casillero is
begin
return estado_casillero.Limpio;
end limpiar;
procedure no_hacer_nada(a : in out t_aspiradora) is
begin
null;
end no_hacer_nada;
procedure set_direccion(a : in out t_aspiradora; d: in t_direccion) is
begin
a.direccion := d ;
end set_direccion;
function get_direccion (a : in t_aspiradora) return t_direccion is
begin
return a.direccion;
end get_direccion;
end aspiradora;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . S H A R E D _ S T O R A G E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package manages the shared/persistent storage required for
-- full implementation of variables in Shared_Passive packages, more
-- precisely variables whose enclosing dynamic scope is a shared
-- passive package. This implementation is specific to GNAT and GLADE
-- provides a more general implementation not dedicated to file
-- storage.
-- --------------------------
-- -- Shared Storage Model --
-- --------------------------
-- The basic model used is that each partition that references the
-- Shared_Passive package has a local copy of the package data that
-- is initialized in accordance with the declarations of the package
-- in the normal manner. The routines in System.Shared_Storage are
-- then used to ensure that the values in these separate copies are
-- properly synchronized with the state of the overall system.
-- In the GNAT implementation, this synchronization is ensured by
-- maintaining a set of files, in a designated directory. The
-- directory is designated by setting the environment variable
-- SHARED_MEMORY_DIRECTORY. This variable must be set for all
-- partitions. If the environment variable is not defined, then the
-- current directory is used.
-- There is one storage for each variable. The name is the fully
-- qualified name of the variable with all letters forced to lower
-- case. For example, the variable Var in the shared passive package
-- Pkg results in the storage name pkg.var.
-- If the storage does not exist, it indicates that no partition has
-- assigned a new value, so that the initial value is the correct
-- one. This is the critical component of the model. It means that
-- there is no system-wide synchronization required for initializing
-- the package, since the shared storages need not (and do not)
-- reflect the initial state. There is therefore no issue of
-- synchronizing initialization and read/write access.
-- -----------------------
-- -- Read/Write Access --
-- -----------------------
-- The approach is as follows:
-- For each shared variable, var, an instantiation of the below generic
-- package is created which provides Read and Write supporting procedures.
-- The routine Read in package System.Shared_Storage.Shared_Var_Procs
-- ensures to assign variable V to the last written value among processes
-- referencing it. A call to this procedure is generated by the expander
-- before each read access to the shared variable.
-- The routine Write in package System.Shared_Storage.Shared_Var_Proc
-- set a new value to the shared variable and, according to the used
-- implementation, propagate this value among processes referencing it.
-- A call to this procedure is generated by the expander after each
-- assignment of the shared variable.
-- Note: a special circuit allows the use of stream attributes Read and
-- Write for limited types (using the corresponding attribute for the
-- full type), but there are limitations on the data that can be placed
-- in shared passive partitions. See sem_smem.ads/adb for details.
-- ----------------------------------------------------------------
-- -- Handling of Protected Objects in Shared Passive Partitions --
-- ----------------------------------------------------------------
-- In the context of GNAT, during the execution of a protected
-- subprogram call, access is locked out using a locking mechanism
-- per protected object, as provided by the GNAT.Lock_Files
-- capability in the specific case of GNAT. This package contains the
-- lock and unlock calls, and the expander generates a call to the
-- lock routine before the protected call and a call to the unlock
-- routine after the protected call.
-- Within the code of the protected subprogram, the access to the
-- protected object itself uses the local copy, without any special
-- synchronization. Since global access is locked out, no other task
-- or partition can attempt to read or write this data as long as the
-- lock is held.
-- The data in the local copy does however need synchronizing with
-- the global values in the shared storage. This is achieved as
-- follows:
-- The protected object generates a read and assignment routine as
-- described for other shared passive variables. The code for the
-- 'Read and 'Write attributes (not normally allowed, but allowed
-- in this special case) simply reads or writes the values of the
-- components in the protected record.
-- The lock call is followed by a call to the shared read routine to
-- synchronize the local copy to contain the proper global value.
-- The unlock call in the procedure case only is preceded by a call
-- to the shared assign routine to synchronize the global shared
-- storages with the (possibly modified) local copy.
-- These calls to the read and assign routines, as well as the lock
-- and unlock routines, are inserted by the expander (see exp_smem.adb).
package System.Shared_Storage is
procedure Shared_Var_Lock (Var : String);
-- This procedure claims the shared storage lock. It is used for
-- protected types in shared passive packages. A call to this
-- locking routine is generated as the first operation in the code
-- for the body of a protected subprogram, and it busy waits if
-- the lock is busy.
procedure Shared_Var_Unlock (Var : String);
-- This procedure releases the shared storage lock obtained by a
-- prior call to the Shared_Var_Lock procedure, and is to be
-- generated as the last operation in the body of a protected
-- subprogram.
-- This generic package is instantiated for each shared passive
-- variable. It provides supporting procedures called upon each
-- read or write access by the expanded code.
generic
type Typ is limited private;
-- Shared passive variable type
V : in out Typ;
-- Shared passive variable
Full_Name : String;
-- Shared passive variable storage name
package Shared_Var_Procs is
procedure Read;
-- Shared passive variable access routine. Each reference to the
-- shared variable, V, is preceded by a call to the corresponding
-- Read procedure, which either leaves the initial value unchanged
-- if the storage does not exist, or reads the current value from
-- the shared storage.
procedure Write;
-- Shared passive variable assignment routine. Each assignment to
-- the shared variable, V, is followed by a call to the corresponding
-- Write procedure, which writes the new value to the shared storage.
end Shared_Var_Procs;
end System.Shared_Storage;
|
package body Collada
is
function get_Matrix (From : in Float_array; Which : in Positive) return Matrix_4x4
is
First : constant Positive := (Which - 1) * 16 + 1;
the_Vector : constant math.Vector_16 := math.Vector_16 (From (First .. First + 15));
begin
return math.to_Matrix_4x4 (the_Vector);
end get_Matrix;
function matrix_Count (From : in Float_array) return Natural
is
begin
return From'Length / 16;
end matrix_Count;
end Collada;
|
with STM32GD.Board; use STM32GD.Board;
with HAL;
procedure Main is
package Button_IRQ is new HAL.Pin_IRQ (Pin => BUTTON);
begin
Init;
LED.Set;
Text_IO.Put_Line ("Hello, World!");
STM32GD.Clear_Event;
Button_IRQ.Configure_Trigger (Rising => True);
loop
Text_IO.Put_Line ("Waiting for button...");
Button_IRQ.Wait_For_Trigger;
LED.Toggle;
Text_IO.Put_Line ("Button pressed");
end loop;
end Main;
|
--@Author Arkadiusz Lewandowski
--@LICENSING: MIT
--@DESCRIPTION: Railway package body for FORMAL VERIFICATION in ADA|SPARK
-- Train cannot move if his next step could potentialy be a crash
-- Open_Route is procedure which establishes availability of a route and sets signalisation
-- into proper colors.
-- Move_Train is procedure which moves Train on given route and sets back the signalisation.
package body Railway with SPARK_Mode is
--Procedura Otwierajaca trase pociagu
procedure Open_Route ( Route : in Route_Type; Success : out Boolean)
is
begin
-- tutaj przygotowuje sobie trase i zamykam innym
case Route is
when Route_Enter_Left =>
if Segment_State.Left = Free then -- bo chce wjechac
Segment_State.Left := Reserved_Moving_From_Left;
Signal_State.Middle_Left := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Enter_Right =>
if Segment_State.Right = Free then -- bo chce wjechac
Segment_State.Right := Reserved_Moving_From_Right;
Success:=True;
else
Success:=False;
end if;
when Route_Leave_Left =>
if Segment_State.Left = Occupied_Standing then --juz tam jest i chce wyjechac
Segment_State.Left := Occupied_Moving_Left;
Success:=True;
else
Success:=False;
end if;
when Route_Leave_Right =>
if Segment_State.Right = Occupied_Standing then -- juz tam jest i chce wyjechac
Segment_State.Right := Occupied_Moving_Right;
Success:=True;
else
Success:=False;
end if;
when Route_Left_Middle =>
if Segment_State.Middle = Free and Segment_State.Left = Occupied_Standing then
Segment_State.Middle := Reserved_Moving_From_Left;
Signal_State.Left_Middle := Green;
Segment_State.Left := Occupied_Moving_Right; -- czy na pewno stoi?
Success:=True;
else
Success:=False;
end if;
when Route_Middle_Left =>
if Segment_State.Left = Free and Segment_State.Middle = Occupied_Standing then
Segment_State.Left := Reserved_Moving_From_Right;
Signal_State.Middle_Left := Green;
Segment_State.Middle := Occupied_Moving_Left; -- czy na pewno stoi?
Success:=True;
else
Success:=False;
end if;
when Route_Middle_Right =>
if Segment_State.Right = Free and Segment_State.Middle = Occupied_Standing then
Signal_State.Middle_Right:= Green;
Segment_State.Middle := Occupied_Moving_Right; -- czy na pewno stoi? !!!
Segment_State.Right := Reserved_Moving_From_Left;
Success:=True;
else
Success:=False;
end if;
when Route_Right_Middle =>
if Segment_State.Middle = Free and Segment_State.Right = Occupied_Standing then
Signal_State.Right_Middle := Green;
Segment_State.Right := Occupied_Moving_Left; -- czy na pewno stoi?
Segment_State.Middle := Reserved_Moving_From_Right;
Success:=True;
else
Success:=False;
end if;
when others =>
Success:=False;
end case;
end Open_Route;
--Procedura przepuszczajaca pociag
procedure Move_Train ( Route :in Route_Type; Success : out Boolean)
is
begin
case Route is
when Route_Enter_Left =>
if Segment_State.Left = Reserved_Moving_From_Left then -- bo chce wjechac
Segment_State.Left := Occupied_Standing; -- no i stanal
Signal_State.Middle_Left := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Enter_Right =>
if Segment_State.Right = Reserved_Moving_From_Right then -- bo chce wjechac
Segment_State.Right := Occupied_Standing; -- no i stanal
Signal_State.Middle_Right := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Leave_Left =>
if Segment_State.Left = Occupied_Moving_Left then
Segment_State.Left := Free; -- no i wyjechal
Signal_State.Middle_Left := Red;
Signal_State.Left_Middle := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Leave_Right =>
if Segment_State.Right = Occupied_Moving_Right then
Segment_State.Right := Free; -- no i wyjechal
Signal_State.Middle_Right := Red;
Signal_State.Right_Middle := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Left_Middle =>
if Segment_State.Middle = Reserved_Moving_From_Left and
Segment_State.Left = Occupied_Moving_Right then
Segment_State.Middle := Occupied_Standing;
Signal_State.Left_Middle := Red;
Segment_State.Left := Free; -- czy na pewno stoi?
--Signal_State.Middle_Left := Red; -- bo tylko on moze wyjechac ze srodka
Success:=True;
else
Success:=False;
end if;
when Route_Middle_Left =>
if Segment_State.Left = Reserved_Moving_From_Right and
Segment_State.Middle = Occupied_Moving_Left then
Segment_State.Left := Occupied_Standing;
Signal_State.Middle_Left := Red;
Segment_State.Middle := Free; -- czy na pewno stoi?
Success:=True;
else
Success:=False;
end if;
when Route_Middle_Right =>
if Segment_State.Right = Reserved_Moving_From_Left and
Segment_State.Middle = Occupied_Moving_Right then
Segment_State.Right := Occupied_Standing;
Segment_State.Middle := Free; -- czy na pewno stoi?
Signal_State.Middle_Right := Red;
Success:=True;
else
Success:=False;
end if;
when Route_Right_Middle =>
if Segment_State.Middle = Reserved_Moving_From_Right and
Segment_State.Right = Occupied_Moving_Left then
Segment_State.Middle := Occupied_Standing;
Segment_State.Right := Free; -- czy na pewno stoi?
Signal_State.Right_Middle := Red;
Success:=True;
else
Success:=False;
end if;
when others =>
Success:=False;
end case;
end Move_Train;
--Slight improvement in a write style
procedure Train(Route: in Route_Type; retval : in out Boolean)
is
begin
if Correct_Segments and Correct_Signals then
Open_Route(Route, retval);
if retval = True then Move_Train(Route, retval);
else retval:=false;
end if;
end if;
end Train;
end Railway;
|
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, 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 Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be reverse
-- engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf52.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.TEMP is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Write '1' to Enable interrupt for DATARDY event
type INTENSET_DATARDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_DATARDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for DATARDY event
type INTENSET_DATARDY_Field_1 is
(-- Reset value for the field
Intenset_Datardy_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_DATARDY_Field_1 use
(Intenset_Datardy_Field_Reset => 0,
Set => 1);
-- Enable interrupt
type INTENSET_Register is record
-- Write '1' to Enable interrupt for DATARDY event
DATARDY : INTENSET_DATARDY_Field_1 :=
Intenset_Datardy_Field_Reset;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
DATARDY at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Write '1' to Disable interrupt for DATARDY event
type INTENCLR_DATARDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_DATARDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for DATARDY event
type INTENCLR_DATARDY_Field_1 is
(-- Reset value for the field
Intenclr_Datardy_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_DATARDY_Field_1 use
(Intenclr_Datardy_Field_Reset => 0,
Clear => 1);
-- Disable interrupt
type INTENCLR_Register is record
-- Write '1' to Disable interrupt for DATARDY event
DATARDY : INTENCLR_DATARDY_Field_1 :=
Intenclr_Datardy_Field_Reset;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
DATARDY at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
subtype A0_A0_Field is HAL.UInt12;
-- Slope of 1st piece wise linear function
type A0_Register is record
-- Slope of 1st piece wise linear function
A0 : A0_A0_Field := 16#320#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A0_Register use record
A0 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype A1_A1_Field is HAL.UInt12;
-- Slope of 2nd piece wise linear function
type A1_Register is record
-- Slope of 2nd piece wise linear function
A1 : A1_A1_Field := 16#343#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A1_Register use record
A1 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype A2_A2_Field is HAL.UInt12;
-- Slope of 3rd piece wise linear function
type A2_Register is record
-- Slope of 3rd piece wise linear function
A2 : A2_A2_Field := 16#35D#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A2_Register use record
A2 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype A3_A3_Field is HAL.UInt12;
-- Slope of 4th piece wise linear function
type A3_Register is record
-- Slope of 4th piece wise linear function
A3 : A3_A3_Field := 16#400#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A3_Register use record
A3 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype A4_A4_Field is HAL.UInt12;
-- Slope of 5th piece wise linear function
type A4_Register is record
-- Slope of 5th piece wise linear function
A4 : A4_A4_Field := 16#47F#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A4_Register use record
A4 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype A5_A5_Field is HAL.UInt12;
-- Slope of 6th piece wise linear function
type A5_Register is record
-- Slope of 6th piece wise linear function
A5 : A5_A5_Field := 16#37B#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for A5_Register use record
A5 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype B0_B0_Field is HAL.UInt14;
-- y-intercept of 1st piece wise linear function
type B0_Register is record
-- y-intercept of 1st piece wise linear function
B0 : B0_B0_Field := 16#3FCC#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B0_Register use record
B0 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype B1_B1_Field is HAL.UInt14;
-- y-intercept of 2nd piece wise linear function
type B1_Register is record
-- y-intercept of 2nd piece wise linear function
B1 : B1_B1_Field := 16#3F98#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B1_Register use record
B1 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype B2_B2_Field is HAL.UInt14;
-- y-intercept of 3rd piece wise linear function
type B2_Register is record
-- y-intercept of 3rd piece wise linear function
B2 : B2_B2_Field := 16#3F98#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B2_Register use record
B2 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype B3_B3_Field is HAL.UInt14;
-- y-intercept of 4th piece wise linear function
type B3_Register is record
-- y-intercept of 4th piece wise linear function
B3 : B3_B3_Field := 16#12#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B3_Register use record
B3 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype B4_B4_Field is HAL.UInt14;
-- y-intercept of 5th piece wise linear function
type B4_Register is record
-- y-intercept of 5th piece wise linear function
B4 : B4_B4_Field := 16#6A#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B4_Register use record
B4 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype B5_B5_Field is HAL.UInt14;
-- y-intercept of 6th piece wise linear function
type B5_Register is record
-- y-intercept of 6th piece wise linear function
B5 : B5_B5_Field := 16#3DD0#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for B5_Register use record
B5 at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype T0_T0_Field is HAL.UInt8;
-- End point of 1st piece wise linear function
type T0_Register is record
-- End point of 1st piece wise linear function
T0 : T0_T0_Field := 16#E2#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for T0_Register use record
T0 at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype T1_T1_Field is HAL.UInt8;
-- End point of 2nd piece wise linear function
type T1_Register is record
-- End point of 2nd piece wise linear function
T1 : T1_T1_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for T1_Register use record
T1 at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype T2_T2_Field is HAL.UInt8;
-- End point of 3rd piece wise linear function
type T2_Register is record
-- End point of 3rd piece wise linear function
T2 : T2_T2_Field := 16#14#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for T2_Register use record
T2 at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype T3_T3_Field is HAL.UInt8;
-- End point of 4th piece wise linear function
type T3_Register is record
-- End point of 4th piece wise linear function
T3 : T3_T3_Field := 16#19#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for T3_Register use record
T3 at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype T4_T4_Field is HAL.UInt8;
-- End point of 5th piece wise linear function
type T4_Register is record
-- End point of 5th piece wise linear function
T4 : T4_T4_Field := 16#50#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for T4_Register use record
T4 at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Temperature Sensor
type TEMP_Peripheral is record
-- Start temperature measurement
TASKS_START : aliased HAL.UInt32;
-- Stop temperature measurement
TASKS_STOP : aliased HAL.UInt32;
-- Temperature measurement complete, data ready
EVENTS_DATARDY : aliased HAL.UInt32;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- Temperature in degC (0.25deg steps)
TEMP : aliased HAL.UInt32;
-- Slope of 1st piece wise linear function
A0 : aliased A0_Register;
-- Slope of 2nd piece wise linear function
A1 : aliased A1_Register;
-- Slope of 3rd piece wise linear function
A2 : aliased A2_Register;
-- Slope of 4th piece wise linear function
A3 : aliased A3_Register;
-- Slope of 5th piece wise linear function
A4 : aliased A4_Register;
-- Slope of 6th piece wise linear function
A5 : aliased A5_Register;
-- y-intercept of 1st piece wise linear function
B0 : aliased B0_Register;
-- y-intercept of 2nd piece wise linear function
B1 : aliased B1_Register;
-- y-intercept of 3rd piece wise linear function
B2 : aliased B2_Register;
-- y-intercept of 4th piece wise linear function
B3 : aliased B3_Register;
-- y-intercept of 5th piece wise linear function
B4 : aliased B4_Register;
-- y-intercept of 6th piece wise linear function
B5 : aliased B5_Register;
-- End point of 1st piece wise linear function
T0 : aliased T0_Register;
-- End point of 2nd piece wise linear function
T1 : aliased T1_Register;
-- End point of 3rd piece wise linear function
T2 : aliased T2_Register;
-- End point of 4th piece wise linear function
T3 : aliased T3_Register;
-- End point of 5th piece wise linear function
T4 : aliased T4_Register;
end record
with Volatile;
for TEMP_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#4# range 0 .. 31;
EVENTS_DATARDY at 16#100# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
TEMP at 16#508# range 0 .. 31;
A0 at 16#520# range 0 .. 31;
A1 at 16#524# range 0 .. 31;
A2 at 16#528# range 0 .. 31;
A3 at 16#52C# range 0 .. 31;
A4 at 16#530# range 0 .. 31;
A5 at 16#534# range 0 .. 31;
B0 at 16#540# range 0 .. 31;
B1 at 16#544# range 0 .. 31;
B2 at 16#548# range 0 .. 31;
B3 at 16#54C# range 0 .. 31;
B4 at 16#550# range 0 .. 31;
B5 at 16#554# range 0 .. 31;
T0 at 16#560# range 0 .. 31;
T1 at 16#564# range 0 .. 31;
T2 at 16#568# range 0 .. 31;
T3 at 16#56C# range 0 .. 31;
T4 at 16#570# range 0 .. 31;
end record;
-- Temperature Sensor
TEMP_Periph : aliased TEMP_Peripheral
with Import, Address => TEMP_Base;
end NRF_SVD.TEMP;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2016-2017, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with System;
with Interfaces.Leon3.Irqmp;
with Interfaces; use Interfaces;
with Ada.Text_IO; use Ada.Text_IO;
with I2cm; use I2cm;
with Svga; use Svga;
package body Dvidrv is
I2cm_Video_Base : constant := 16#c000_0900#;
I2cm_Video_Interrupt : constant := 18;
I2cm_Clock_Prescale : I2cm_Clock_Prescale_Register
with Address => System'To_Address (I2cm_Video_Base + 16#00#),
Volatile, Import;
I2cm_Control : I2cm_Control_Register
with Address => System'To_Address (I2cm_Video_Base + 16#04#),
Volatile, Import;
I2cm_Data : I2cm_Data_Register
with Address => System'To_Address (I2cm_Video_Base + 16#08#),
Volatile, Import;
-- Write only
I2cm_Command : I2cm_Command_Register
with Address => System'To_Address (I2cm_Video_Base + 16#0c#),
Volatile, Import;
-- Read only
I2cm_Status : I2cm_Status_Register
with Address => System'To_Address (I2cm_Video_Base + 16#0c#),
Volatile, Import;
I2cm_Ien : constant Boolean := True;
SVGA_Regs : SVGA_Controller_Registers
with Address => System'To_Address (16#c080_0000#),
Volatile, Import;
type Svga_Screen_Type is array (0 .. 639, 0 .. 799) of Unsigned_16;
SVGA_Buffer : Svga_Screen_Type
with Address => System'To_Address (16#4d00_0000#),
Volatile, Import;
protected I2c_Prot is
pragma Interrupt_Priority (System.Interrupt_Priority'First);
procedure Handler;
pragma Attach_Handler (Handler, I2cm_Video_Interrupt);
entry Wait_Tfr;
private
It_Pending : Boolean := False;
end I2c_Prot;
protected body I2c_Prot is
procedure Handler is
begin
It_Pending := True;
I2cm_Command := (Sta => False, Sto => False,
Wr => False, Rd => False,
Ack => False, Iack => True, Res_0 => 0, Res_1 => 0);
end Handler;
entry Wait_Tfr when It_Pending is
begin
It_Pending := False;
end Wait_Tfr;
end I2c_Prot;
procedure I2c_Start (Addr : Unsigned_8; Ok : out Boolean) is
begin
-- Address
I2cm_Data := (Res => 0, Data => Addr);
I2cm_Command := (Sta => True, Sto => False,
Wr => True, Rd => False,
Ack => False, Iack => False, Res_0 => 0, Res_1 => 0);
if I2cm_Ien then
I2c_Prot.Wait_Tfr;
else
while I2cm_Status.Tip loop
null;
end loop;
end if;
if I2cm_Status.Rxack then
Put_Line ("no ack");
Ok := False;
else
Ok := True;
end if;
end I2c_Start;
procedure I2c_Write (Data : Unsigned_8; Stop : Boolean) is
begin
I2cm_Data := (Res => 0, Data => Data);
I2cm_Command := (Sta => False, Sto => Stop,
Wr => True, Rd => False,
Ack => False, Iack => False, Res_0 => 0, Res_1 => 0);
if I2cm_Ien then
I2c_Prot.Wait_Tfr;
else
while I2cm_Status.Tip loop
null;
end loop;
end if;
end I2c_Write;
procedure I2c_Read (Data : out Unsigned_8; Stop : Boolean) is
begin
I2cm_Command := (Sta => False, Sto => Stop,
Wr => False, Rd => True,
Ack => False, Iack => False, Res_0 => 0, Res_1 => 0);
if I2cm_Ien then
I2c_Prot.Wait_Tfr;
else
while I2cm_Status.Tip loop
null;
end loop;
end if;
Data := I2cm_Data.Data;
end I2c_Read;
procedure Write (Addr : Unsigned_8; Reg : Unsigned_8; Val : Unsigned_8)
is
Ok : Boolean;
begin
I2c_Start (Addr, Ok);
if not Ok then
return;
end if;
I2c_Write (Reg, False);
I2c_Write (Val, True);
end Write;
procedure Read (Addr : Unsigned_8; Reg : Unsigned_8; Val : out Unsigned_8)
is
Ok : Boolean;
begin
I2c_Start (Addr, Ok);
if not Ok then
Val := 0;
return;
end if;
I2c_Write (Reg, False);
I2c_Start (Addr or 1, Ok);
if not Ok then
Val := 0;
return;
end if;
I2c_Read (Val, True);
end Read;
subtype String2 is String (1 .. 2);
Hex_Digits : constant array (0 .. 15) of Character := "0123456789abcdef";
function Hex1 (V : Unsigned_8) return String2 is
Res : String2;
begin
for I in Res'Range loop
Res (I) := Hex_Digits (Natural (Shift_Right (V, 4 * (2 - I)) and 15));
end loop;
return Res;
end Hex1;
procedure Init_I2C is
begin
I2cm_Control := (Res_0 => 0, En => False, Ien => False, Res_1 => 0);
-- Prescale = AMBA_clock_Freq / (5 * SCL_Freq) - 1
I2cm_Clock_Prescale.Prescale :=
Unsigned_16 (100_000_000 / (5 * 100_000) - 1);
-- Enable
I2cm_Control := (Res_0 => 0, En => True, Ien => I2cm_Ien, Res_1 => 0);
if I2cm_Ien then
declare
use Interfaces.Leon3.Irqmp;
begin
Interrupt_Mask (1) :=
Interrupt_Mask (1) or 2**I2cm_Video_Interrupt;
end;
end if;
end Init_I2C;
procedure Init_Encoder is
type U8_Array is array (Natural range <>) of Unsigned_8;
Regs : constant U8_Array :=
(16#1c#, 16#1d#, 16#1e#, 16#1f#,
16#20#, 16#21#, 16#23#, 16#31#,
16#33#, 16#34#, 16#35#, 16#36#,
16#37#, 16#48#, 16#49#, 16#4a#,
16#4b#, 16#56#);
Val : Unsigned_8;
begin
for I in Regs'Range loop
Read (16#ec#, Regs (I), Val);
Put (Hex1 (Regs (I)));
Put (": ");
Put (Hex1 (Val));
New_Line;
end loop;
Read (16#ec#, 16#4a#, Val);
Put ("VID: ");
Put (Unsigned_8'Image (Val));
Read (16#ec#, 16#4b#, Val);
Put (", DID: ");
Put_Line (Unsigned_8'Image (Val));
if True then
-- AS is 0, so i2c address is 2#1110_110x#
Write (16#ec#, 16#1c#, 16#04#);
Write (16#ec#, 16#1d#, 16#45#);
Write (16#ec#, 16#1e#, 16#c0#);
Write (16#ec#, 16#1f#, 16#8a#); -- 16 bit
Write (16#ec#, 16#21#, 16#09#); -- DVI
Write (16#ec#, 16#33#, 16#08#);
Write (16#ec#, 16#34#, 16#16#);
Write (16#ec#, 16#36#, 16#60#);
Write (16#ec#, 16#48#, 16#18#); -- Color Bars
Write (16#ec#, 16#49#, 16#c0#);
Write (16#ec#, 16#56#, 16#00#);
end if;
end Init_Encoder;
procedure Init_Svga is
begin
Svga_Regs.Status.Rst := True;
Svga_Regs.Status := (Vpol => False,
Hpol => False,
Clksel => 2,
Bdsel => Depth_16,
Vr => False,
Rst => False,
En => False,
Res_1 => False,
Res_2 => 0);
Svga_Regs.Video_Length := (Vres => 16#257#, Hres => 16#31f#);
Svga_Regs.Front_Porch := (Vporch => 1, Hporch => 40);
Svga_Regs.Sync_Length := (Vplen => 4, Hplen => 128);
Svga_Regs.Line_Length := (Vllen => 16#273#, Hllen => 16#41f#);
Svga_Regs.Framebuffer := Svga_Buffer'Address;
Svga_Regs.Clock_0 := 16#9c40#;
Svga_Regs.Clock_1 := 16#9c40#;
Svga_Regs.Clock_2 := 16#61a8#;
Svga_Regs.Clock_3 := 16#3c19#;
Svga_Regs.Status.En := True;
end Init_Svga;
procedure Init is
begin
Init_I2C;
Init_Encoder;
Init_Svga;
for I in Svga_Buffer'Range (2) loop
Svga_Buffer (10, I) := 2#11111_000000_00000#;
Svga_Buffer (50, I) := 2#00000_111111_00000#;
Svga_Buffer (90, I) := 2#00000_000000_11111#;
end loop;
end Init;
end Dvidrv;
|
-- Profiles
--pragma Profile(Ravenscar); -- Safety-Critical Policy
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- Fixed Priority Scheduling
pragma Locking_Policy (Ceiling_Locking); -- ICCP
-- Standard Packages
-- Project-Defined Packages
with Task_Implementations;
-- Main
procedure main is
begin
null;
end main; |
with Ada.Text_IO; use Ada.Text_IO;
with Data_Type;
with Generic_List;
with Generic_List.Output;
procedure Main is
-- Create instance of generic list package
-- Create instance of generic list output package
-- My_List : List.List_T; -- Object of generic list type
Element : Data_Type.Record_T;
begin
null;
-- loop
-- Query user to populate Element object
-- Add Element object to My_List
-- end loop;
-- Sort My_List
-- Print My_List;
end Main;
|
package body Morse is
Dot_Duration : constant Time_Span := Milliseconds(100);
Dash_Duration : constant Time_Span := Milliseconds(200);
procedure Blink_Morse(LED: Led_No; Led_Color : Color; Duration : Time_Span) is
Timeout : Time := Clock;
begin
Led_Set(LED, Led_Color);
Timeout := Timeout + Duration;
delay until Timeout;
Led_Set(LED, Black);
Timeout := Timeout + Dot_Duration;
delay until Timeout;
end Blink_Morse;
procedure Dot is
begin
Blink_Morse(LED0, Yellow, Dot_Duration);
end Dot;
procedure Dash is
begin
Blink_Morse(LED0, Blue, Dash_Duration);
end Dash;
procedure Morse_Display (S : String) is
Timeout : Time := Clock;
begin
for I of S loop
case I is
when 'a' => Dot; Dash;
when 'b' => Dash; Dot; Dot; Dot;
when 'c' => Dash; Dot; Dash; Dot;
when 'd' => Dash; Dot; Dot;
when 'e' => Dot;
when 'f' => Dot; Dot; Dash; Dot;
when 'g' => Dash; Dash; Dot;
when 'h' => Dot; Dot; Dot; Dot;
when 'i' => Dot; Dot;
when 'j' => Dash; Dot; Dash;
when 'k' => Dash; Dot; Dash;
when 'l' => Dot; Dash; Dot; Dot;
when 'm' => Dash; Dash;
when 'n' => Dash; Dot;
when 'o' => Dash; Dash; Dash;
when 'p' => Dot; Dash; Dash; Dot;
when 'q' => Dash; Dash; Dot; Dash;
when 'r' => Dot; Dash; Dot;
when 's' => Dot; Dot; Dot;
when 't' => Dash;
when 'u' => Dot; Dot; Dash;
when 'v' => Dot; Dot; Dot; Dash;
when 'w' => Dot; Dash; Dash;
when 'x' => Dash; Dot; Dot; Dash;
when 'y' => Dash; Dot; Dash; Dash;
when 'z' => Dash; Dash; Dot; Dot;
when 'A' => Dot; Dash;
when 'B' => Dash; Dot; Dot; Dot;
when 'C' => Dash; Dot; Dash; Dot;
when 'D' => Dash; Dot; Dot;
when 'E' => Dot;
when 'F' => Dot; Dot; Dash; Dot;
when 'G' => Dash; Dash; Dot;
when 'H' => Dot; Dot; Dot; Dot;
when 'I' => Dot; Dot;
when 'J' => Dash; Dot; Dash;
when 'K' => Dash; Dot; Dash;
when 'L' => Dot; Dash; Dot; Dot;
when 'M' => Dash; Dash;
when 'N' => Dash; Dot;
when 'O' => Dash; Dash; Dash;
when 'P' => Dot; Dash; Dash; Dot;
when 'Q' => Dash; Dash; Dot; Dash;
when 'R' => Dot; Dash; Dot;
when 'S' => Dot; Dot; Dot;
when 'T' => Dash;
when 'U' => Dot; Dot; Dash;
when 'V' => Dot; Dot; Dot; Dash;
when 'W' => Dot; Dash; Dash;
when 'X' => Dash; Dot; Dot; Dash;
when 'Y' => Dash; Dot; Dash; Dash;
when 'Z' => Dash; Dash; Dot; Dot;
when '1' => Dot; Dash; Dash; Dash; Dash;
when '2' => Dot; Dot; Dash; Dash; Dash;
when '3' => Dot; Dot; Dot; Dash; Dash;
when '4' => Dot; Dot; Dot; Dot; Dash;
when '5' => Dot; Dot; Dot; Dot; Dot;
when '6' => Dash; Dot; Dot; Dot; Dot;
when '7' => Dash; Dash; Dot; Dot; Dot;
when '8' => Dash; Dash; Dash; Dot; Dot;
when '9' => Dash; Dash; Dash; Dash; Dot;
when '0' => Dash; Dash; Dash; Dash; Dash;
when others => null;
end case;
Timeout := Clock;
if I in 'a' .. 'z' or
I in 'A' .. 'Z' or
I in '0' .. '9' then
delay until Timeout + 2 * Dot_Duration;
elsif I = ' ' then
delay until Timeout + 6 * Dot_Duration;
end if;
end loop;
end Morse_Display;
end Morse;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T B U I L D --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Restrict; use Restrict;
with Rident; use Rident;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Uintp; use Uintp;
package body Tbuild is
-----------------------
-- Local Subprograms --
-----------------------
procedure Add_Unique_Serial_Number;
-- Add a unique serialization to the string in the Name_Buffer. This
-- consists of a unit specific serial number, and b/s for body/spec.
------------------------------
-- Add_Unique_Serial_Number --
------------------------------
procedure Add_Unique_Serial_Number is
Unit_Node : constant Node_Id := Unit (Cunit (Current_Sem_Unit));
begin
Add_Nat_To_Name_Buffer (Increment_Serial_Number);
-- Add either b or s, depending on whether current unit is a spec
-- or a body. This is needed because we may generate the same name
-- in a spec and a body otherwise.
Name_Len := Name_Len + 1;
if Nkind (Unit_Node) = N_Package_Declaration
or else Nkind (Unit_Node) = N_Subprogram_Declaration
or else Nkind (Unit_Node) in N_Generic_Declaration
then
Name_Buffer (Name_Len) := 's';
else
Name_Buffer (Name_Len) := 'b';
end if;
end Add_Unique_Serial_Number;
----------------
-- Checks_Off --
----------------
function Checks_Off (N : Node_Id) return Node_Id is
begin
return
Make_Unchecked_Expression (Sloc (N),
Expression => N);
end Checks_Off;
----------------
-- Convert_To --
----------------
function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id is
Result : Node_Id;
begin
if Present (Etype (Expr))
and then (Etype (Expr)) = Typ
then
return Relocate_Node (Expr);
else
Result :=
Make_Type_Conversion (Sloc (Expr),
Subtype_Mark => New_Occurrence_Of (Typ, Sloc (Expr)),
Expression => Relocate_Node (Expr));
Set_Etype (Result, Typ);
return Result;
end if;
end Convert_To;
------------------
-- Discard_List --
------------------
procedure Discard_List (L : List_Id) is
pragma Warnings (Off, L);
begin
null;
end Discard_List;
------------------
-- Discard_Node --
------------------
procedure Discard_Node (N : Node_Or_Entity_Id) is
pragma Warnings (Off, N);
begin
null;
end Discard_Node;
-------------------------------------------
-- Make_Byte_Aligned_Attribute_Reference --
-------------------------------------------
function Make_Byte_Aligned_Attribute_Reference
(Sloc : Source_Ptr;
Prefix : Node_Id;
Attribute_Name : Name_Id)
return Node_Id
is
N : constant Node_Id :=
Make_Attribute_Reference (Sloc,
Prefix => Prefix,
Attribute_Name => Attribute_Name);
begin
pragma Assert (Attribute_Name = Name_Address
or else
Attribute_Name = Name_Unrestricted_Access);
Set_Must_Be_Byte_Aligned (N, True);
return N;
end Make_Byte_Aligned_Attribute_Reference;
--------------------
-- Make_DT_Access --
--------------------
function Make_DT_Access
(Loc : Source_Ptr;
Rec : Node_Id;
Typ : Entity_Id) return Node_Id
is
Full_Type : Entity_Id := Typ;
begin
if Is_Private_Type (Typ) then
Full_Type := Underlying_Type (Typ);
end if;
return
Unchecked_Convert_To (
New_Occurrence_Of
(Etype (Node (First_Elmt (Access_Disp_Table (Full_Type)))), Loc),
Make_Selected_Component (Loc,
Prefix => New_Copy (Rec),
Selector_Name =>
New_Reference_To (First_Tag_Component (Full_Type), Loc)));
end Make_DT_Access;
--------------------------------
-- Make_Implicit_If_Statement --
--------------------------------
function Make_Implicit_If_Statement
(Node : Node_Id;
Condition : Node_Id;
Then_Statements : List_Id;
Elsif_Parts : List_Id := No_List;
Else_Statements : List_Id := No_List) return Node_Id
is
begin
Check_Restriction (No_Implicit_Conditionals, Node);
return Make_If_Statement (Sloc (Node),
Condition,
Then_Statements,
Elsif_Parts,
Else_Statements);
end Make_Implicit_If_Statement;
-------------------------------------
-- Make_Implicit_Label_Declaration --
-------------------------------------
function Make_Implicit_Label_Declaration
(Loc : Source_Ptr;
Defining_Identifier : Node_Id;
Label_Construct : Node_Id) return Node_Id
is
N : constant Node_Id :=
Make_Implicit_Label_Declaration (Loc, Defining_Identifier);
begin
Set_Label_Construct (N, Label_Construct);
return N;
end Make_Implicit_Label_Declaration;
----------------------------------
-- Make_Implicit_Loop_Statement --
----------------------------------
function Make_Implicit_Loop_Statement
(Node : Node_Id;
Statements : List_Id;
Identifier : Node_Id := Empty;
Iteration_Scheme : Node_Id := Empty;
Has_Created_Identifier : Boolean := False;
End_Label : Node_Id := Empty) return Node_Id
is
begin
Check_Restriction (No_Implicit_Loops, Node);
if Present (Iteration_Scheme)
and then Present (Condition (Iteration_Scheme))
then
Check_Restriction (No_Implicit_Conditionals, Node);
end if;
return Make_Loop_Statement (Sloc (Node),
Identifier => Identifier,
Iteration_Scheme => Iteration_Scheme,
Statements => Statements,
Has_Created_Identifier => Has_Created_Identifier,
End_Label => End_Label);
end Make_Implicit_Loop_Statement;
--------------------------
-- Make_Integer_Literal --
---------------------------
function Make_Integer_Literal
(Loc : Source_Ptr;
Intval : Int) return Node_Id
is
begin
return Make_Integer_Literal (Loc, UI_From_Int (Intval));
end Make_Integer_Literal;
--------------------------------
-- Make_Linker_Section_Pragma --
--------------------------------
function Make_Linker_Section_Pragma
(Ent : Entity_Id;
Loc : Source_Ptr;
Sec : String) return Node_Id
is
LS : Node_Id;
begin
LS :=
Make_Pragma
(Loc,
Name_Linker_Section,
New_List
(Make_Pragma_Argument_Association
(Sloc => Loc,
Expression => New_Occurrence_Of (Ent, Loc)),
Make_Pragma_Argument_Association
(Sloc => Loc,
Expression =>
Make_String_Literal
(Sloc => Loc,
Strval => Sec))));
Set_Has_Gigi_Rep_Item (Ent);
return LS;
end Make_Linker_Section_Pragma;
---------------------------------
-- Make_Raise_Constraint_Error --
---------------------------------
function Make_Raise_Constraint_Error
(Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Reason : RT_Exception_Code) return Node_Id
is
begin
pragma Assert (Reason in RT_CE_Exceptions);
return
Make_Raise_Constraint_Error (Sloc,
Condition => Condition,
Reason =>
UI_From_Int (RT_Exception_Code'Pos (Reason)));
end Make_Raise_Constraint_Error;
------------------------------
-- Make_Raise_Program_Error --
------------------------------
function Make_Raise_Program_Error
(Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Reason : RT_Exception_Code) return Node_Id
is
begin
pragma Assert (Reason in RT_PE_Exceptions);
return
Make_Raise_Program_Error (Sloc,
Condition => Condition,
Reason =>
UI_From_Int (RT_Exception_Code'Pos (Reason)));
end Make_Raise_Program_Error;
------------------------------
-- Make_Raise_Storage_Error --
------------------------------
function Make_Raise_Storage_Error
(Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Reason : RT_Exception_Code) return Node_Id
is
begin
pragma Assert (Reason in RT_SE_Exceptions);
return
Make_Raise_Storage_Error (Sloc,
Condition => Condition,
Reason =>
UI_From_Int (RT_Exception_Code'Pos (Reason)));
end Make_Raise_Storage_Error;
-------------------------
-- Make_String_Literal --
-------------------------
function Make_String_Literal
(Sloc : Source_Ptr;
Strval : String) return Node_Id
is
begin
Start_String;
Store_String_Chars (Strval);
return
Make_String_Literal (Sloc,
Strval => End_String);
end Make_String_Literal;
---------------------------
-- Make_Unsuppress_Block --
---------------------------
-- Generates the following expansion:
-- declare
-- pragma Suppress (<check>);
-- begin
-- <stmts>
-- end;
function Make_Unsuppress_Block
(Loc : Source_Ptr;
Check : Name_Id;
Stmts : List_Id) return Node_Id
is
begin
return
Make_Block_Statement (Loc,
Declarations => New_List (
Make_Pragma (Loc,
Chars => Name_Suppress,
Pragma_Argument_Associations => New_List (
Make_Pragma_Argument_Association (Loc,
Expression => Make_Identifier (Loc, Check))))),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Stmts));
end Make_Unsuppress_Block;
--------------------------
-- New_Constraint_Error --
--------------------------
function New_Constraint_Error (Loc : Source_Ptr) return Node_Id is
Ident_Node : Node_Id;
Raise_Node : Node_Id;
begin
Ident_Node := New_Node (N_Identifier, Loc);
Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
Raise_Node := New_Node (N_Raise_Statement, Loc);
Set_Name (Raise_Node, Ident_Node);
return Raise_Node;
end New_Constraint_Error;
-----------------------
-- New_External_Name --
-----------------------
function New_External_Name
(Related_Id : Name_Id;
Suffix : Character := ' ';
Suffix_Index : Int := 0;
Prefix : Character := ' ') return Name_Id
is
begin
Get_Name_String (Related_Id);
if Prefix /= ' ' then
pragma Assert (Is_OK_Internal_Letter (Prefix));
for J in reverse 1 .. Name_Len loop
Name_Buffer (J + 1) := Name_Buffer (J);
end loop;
Name_Len := Name_Len + 1;
Name_Buffer (1) := Prefix;
end if;
if Suffix /= ' ' then
pragma Assert (Is_OK_Internal_Letter (Suffix));
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Suffix;
end if;
if Suffix_Index /= 0 then
if Suffix_Index < 0 then
Add_Unique_Serial_Number;
else
Add_Nat_To_Name_Buffer (Suffix_Index);
end if;
end if;
return Name_Find;
end New_External_Name;
function New_External_Name
(Related_Id : Name_Id;
Suffix : String;
Suffix_Index : Int := 0;
Prefix : Character := ' ') return Name_Id
is
begin
Get_Name_String (Related_Id);
if Prefix /= ' ' then
pragma Assert (Is_OK_Internal_Letter (Prefix));
for J in reverse 1 .. Name_Len loop
Name_Buffer (J + 1) := Name_Buffer (J);
end loop;
Name_Len := Name_Len + 1;
Name_Buffer (1) := Prefix;
end if;
if Suffix /= "" then
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
end if;
if Suffix_Index /= 0 then
if Suffix_Index < 0 then
Add_Unique_Serial_Number;
else
Add_Nat_To_Name_Buffer (Suffix_Index);
end if;
end if;
return Name_Find;
end New_External_Name;
function New_External_Name
(Suffix : Character;
Suffix_Index : Nat) return Name_Id
is
begin
Name_Buffer (1) := Suffix;
Name_Len := 1;
Add_Nat_To_Name_Buffer (Suffix_Index);
return Name_Find;
end New_External_Name;
-----------------------
-- New_Internal_Name --
-----------------------
function New_Internal_Name (Id_Char : Character) return Name_Id is
begin
pragma Assert (Is_OK_Internal_Letter (Id_Char));
Name_Buffer (1) := Id_Char;
Name_Len := 1;
Add_Unique_Serial_Number;
return Name_Enter;
end New_Internal_Name;
-----------------------
-- New_Occurrence_Of --
-----------------------
function New_Occurrence_Of
(Def_Id : Entity_Id;
Loc : Source_Ptr) return Node_Id
is
Occurrence : Node_Id;
begin
Occurrence := New_Node (N_Identifier, Loc);
Set_Chars (Occurrence, Chars (Def_Id));
Set_Entity (Occurrence, Def_Id);
if Is_Type (Def_Id) then
Set_Etype (Occurrence, Def_Id);
else
Set_Etype (Occurrence, Etype (Def_Id));
end if;
return Occurrence;
end New_Occurrence_Of;
----------------------
-- New_Reference_To --
----------------------
function New_Reference_To
(Def_Id : Entity_Id;
Loc : Source_Ptr) return Node_Id
is
Occurrence : Node_Id;
begin
Occurrence := New_Node (N_Identifier, Loc);
Set_Chars (Occurrence, Chars (Def_Id));
Set_Entity (Occurrence, Def_Id);
return Occurrence;
end New_Reference_To;
-----------------------
-- New_Suffixed_Name --
-----------------------
function New_Suffixed_Name
(Related_Id : Name_Id;
Suffix : String) return Name_Id
is
begin
Get_Name_String (Related_Id);
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := '_';
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
return Name_Find;
end New_Suffixed_Name;
-------------------
-- OK_Convert_To --
-------------------
function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id is
Result : Node_Id;
begin
Result :=
Make_Type_Conversion (Sloc (Expr),
Subtype_Mark => New_Occurrence_Of (Typ, Sloc (Expr)),
Expression => Relocate_Node (Expr));
Set_Conversion_OK (Result, True);
Set_Etype (Result, Typ);
return Result;
end OK_Convert_To;
--------------------------
-- Unchecked_Convert_To --
--------------------------
function Unchecked_Convert_To
(Typ : Entity_Id;
Expr : Node_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Expr);
Result : Node_Id;
begin
-- If the expression is already of the correct type, then nothing
-- to do, except for relocating the node in case this is required.
if Present (Etype (Expr))
and then (Base_Type (Etype (Expr)) = Typ
or else Etype (Expr) = Typ)
then
return Relocate_Node (Expr);
-- Cases where the inner expression is itself an unchecked conversion
-- to the same type, and we can thus eliminate the outer conversion.
elsif Nkind (Expr) = N_Unchecked_Type_Conversion
and then Entity (Subtype_Mark (Expr)) = Typ
then
Result := Relocate_Node (Expr);
elsif Nkind (Expr) = N_Null
and then Is_Access_Type (Typ)
then
-- No need for a conversion
Result := Relocate_Node (Expr);
-- All other cases
else
Result :=
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Typ, Loc),
Expression => Relocate_Node (Expr));
end if;
Set_Etype (Result, Typ);
return Result;
end Unchecked_Convert_To;
end Tbuild;
|
-- { dg-do run }
-- { dg-options "-O2" }
with Ada.Command_Line; use Ada.Command_Line;
procedure Opt65 is
procedure Check_Version_And_Help (Version_String : String) is
Help_Switch_Present : Boolean := False;
Next_Arg : Natural := 1;
begin
while Next_Arg <= Argument_Count loop
declare
Next_Argv : constant String := Argument (Next_Arg);
begin
if Next_Argv = "--help" then
Help_Switch_Present := True;
end if;
Next_Arg := Next_Arg + 1;
end;
end loop;
if Help_Switch_Present then
raise Program_Error;
end if;
end;
begin
Check_Version_And_Help ("version");
end;
|
-----------------------------------------------------------------------
-- helios-commands-agent -- Helios agent commands
-- Copyright (C) 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Util.Log;
with Util.Properties;
with Util.Events.Timers;
with Helios.Monitor.Agent;
with Helios.Reports.Files;
with Helios.Reports.Remote;
package body Helios.Commands.Agent is
use Ada.Strings.Unbounded;
procedure Setup_Report (Runtime : in out Helios.Monitor.Agent.Runtime_Type;
Config : in Util.Properties.Manager;
Server : in Util.Properties.Manager);
File_Report : aliased Helios.Reports.Files.File_Report_Type;
Remote_Report : aliased Helios.Reports.Remote.Remote_Report_Type;
procedure Setup_Report (Runtime : in out Helios.Monitor.Agent.Runtime_Type;
Config : in Util.Properties.Manager;
Server : in Util.Properties.Manager) is
Mode : constant String := Config.Get ("mode", "file");
Timer : Util.Events.Timers.Timer_Ref;
begin
Runtime.Report_Period := Helios.Monitor.Get_Period (Config, "period", 300);
if Mode = "file" then
File_Report.Period := Runtime.Report_Period;
File_Report.Path := To_Unbounded_String (Config.Get ("pattern",
"report-%F-%H-%M-%S.json"));
Runtime.Timers.Set_Timer (File_Report'Access, Timer, File_Report.Period);
else
Remote_Report.Period := Runtime.Report_Period;
-- Remote_Report.URI := To_Unbounded_String (Config.Get ("remote_uri"));
Remote_Report.Set_Server_Config (Server);
Helios.Reports.Remote.Start (Remote_Report'Access);
Runtime.Timers.Set_Timer (Remote_Report'Access, Timer, Remote_Report.Period);
end if;
end Setup_Report;
-- ------------------------------
-- Execute a information command to report information about the agent and monitoring.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
begin
if Args.Get_Count /= 0 then
Helios.Commands.Usage (Args);
else
Load (Context);
Setup_Report (Context.Runtime, Context.Config.Get ("report"), Context.Server);
Monitor.Agent.Configure (Context.Runtime, Context.Config);
Monitor.Agent.Run (Context.Runtime);
end if;
exception
when Util.Properties.NO_PROPERTY =>
Command.Log (Util.Log.ERROR_LEVEL, Name, "Missing report configuration");
raise Error;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
pragma Unreferenced (Name, Command, Context);
begin
Ada.Text_IO.Put_Line ("agent: start the monitoring agent");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Usage: agent");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" The agent command is the main command to run the agent and");
Ada.Text_IO.Put_Line (" to monitor the system components according to the configuration.");
end Help;
end Helios.Commands.Agent;
|
with Ada.Exceptions.Finally;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System;
package body Ada.Containers.Limited_Doubly_Linked_Lists is
use type Base.Node_Access;
-- diff
use type System.Address;
function Upcast is new Unchecked_Conversion (Cursor, Base.Node_Access);
function Downcast is new Unchecked_Conversion (Base.Node_Access, Cursor);
-- diff (Upcast)
--
-- diff (Downcast)
--
procedure Free is new Unchecked_Deallocation (Node, Cursor);
procedure Free is new Unchecked_Deallocation (Element_Type, Element_Access);
-- diff (Context_Type)
--
--
--
-- diff (Equivalent_Element)
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Allocate_Element)
--
--
--
--
--
--
--
--
-- diff (Allocate_Node)
--
--
--
--
--
--
--
--
--
--
-- diff (Copy_Node)
--
--
--
--
--
--
--
--
--
--
--
procedure Free_Node (Object : in out Base.Node_Access);
procedure Free_Node (Object : in out Base.Node_Access) is
X : Cursor := Downcast (Object);
begin
Free (X.Element);
Free (X);
Object := null;
end Free_Node;
-- diff (Allocate_Data)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Copy_Data)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Free)
procedure Free_Data (Data : in out List);
procedure Free_Data (Data : in out List) is
-- diff
begin
Base.Free (Data.First, Data.Last, Data.Length, Free => Free_Node'Access);
-- diff
-- diff
end Free_Data;
-- diff (Unique)
--
--
--
--
--
--
--
--
--
--
--
--
-- implementation
function Empty_List return List is
begin
return (Finalization.Limited_Controlled with null, null, 0);
end Empty_List;
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= null;
end Has_Element;
-- diff ("=")
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
function Length (Container : List) return Count_Type is
-- diff
begin
-- diff
-- diff
-- diff
return Container.Length;
-- diff
end Length;
function Is_Empty (Container : List) return Boolean is
-- diff
begin
return Container.Last = null;
end Is_Empty;
procedure Clear (Container : in out List) is
begin
Free_Data (Container);
end Clear;
-- diff (Element)
--
--
--
-- diff (Replace_Element)
--
--
--
--
--
--
--
--
procedure Query_Element (
Position : Cursor;
Process : not null access procedure (Element : Element_Type)) is
begin
Process (Position.Element.all);
end Query_Element;
procedure Update_Element (
Container : in out List'Class;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type)) is
begin
Process (Reference (List (Container), Position).Element.all);
end Update_Element;
function Constant_Reference (Container : aliased List; Position : Cursor)
return Constant_Reference_Type
is
pragma Unreferenced (Container);
begin
return (Element => Position.Element.all'Access);
end Constant_Reference;
function Reference (Container : aliased in out List; Position : Cursor)
return Reference_Type
is
pragma Unreferenced (Container);
begin
return (Element => Position.Element.all'Access);
end Reference;
-- diff (Assign)
--
--
--
--
--
--
-- diff (Copy)
--
--
--
--
--
--
--
--
--
procedure Move (Target : in out List; Source : in out List) is
begin
if Target.First /= Source.First then
Clear (Target);
Target.First := Source.First;
Target.Last := Source.Last;
Target.Length := Source.Length;
Source.First := null;
Source.Last := null;
Source.Length := 0;
end if;
end Move;
procedure Insert (
Container : in out List'Class;
Before : Cursor;
New_Item : not null access function return Element_Type;
Count : Count_Type := 1)
is
Position : Cursor;
begin
Insert (Container, Before, New_Item, Position, Count);
end Insert;
procedure Insert (
Container : in out List'Class;
Before : Cursor;
New_Item : not null access function return Element_Type;
Position : out Cursor;
Count : Count_Type := 1) is
begin
Position := Before;
if Count > 0 then
-- diff
for I in 1 .. Count loop
declare
package Holder is
new Exceptions.Finally.Scoped_Holder (Cursor, Free);
New_Node : aliased Cursor := new Node;
begin
Holder.Assign (New_Node);
New_Node.Element := new Element_Type'(New_Item.all);
Holder.Clear;
Base.Insert (
Container.First,
Container.Last,
Container.Length,
Before => Upcast (Position),
New_Item => Upcast (New_Node));
Position := New_Node;
end;
end loop;
end if;
end Insert;
-- diff (Insert)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
procedure Prepend (
Container : in out List'Class;
New_Item : not null access function return Element_Type;
Count : Count_Type := 1) is
begin
Insert (Container, First (List (Container)), New_Item, Count);
end Prepend;
procedure Append (
Container : in out List'Class;
New_Item : not null access function return Element_Type;
Count : Count_Type := 1) is
begin
Insert (Container, null, New_Item, Count);
end Append;
procedure Delete (
Container : in out List;
Position : in out Cursor;
Count : Count_Type := 1) is
begin
if Count > 0 then
-- diff
for I in 1 .. Count loop
declare
-- diff
X : Base.Node_Access;
Next : Base.Node_Access;
begin
X := Upcast (Position);
Next := Base.Next (Upcast (Position));
Base.Remove (
Container.First,
Container.Last,
Container.Length,
Position => X,
Next => Next);
Free_Node (X);
Position := Downcast (Next);
end;
end loop;
Position := No_Element;
end if;
end Delete;
procedure Delete_First (
Container : in out List'Class;
Count : Count_Type := 1)
is
Position : Cursor := First (List (Container));
begin
Delete (List (Container), Position, Count);
end Delete_First;
procedure Delete_Last (
Container : in out List'Class;
Count : Count_Type := 1)
is
Position : Cursor := Last (List (Container));
begin
for I in 1 .. Count loop
declare
Previous_Position : constant Cursor := Previous (Position);
begin
Delete (List (Container), Position);
Position := Previous_Position;
end;
end loop;
end Delete_Last;
procedure Reverse_Elements (Container : in out List) is
begin
-- diff
-- diff
-- diff
-- diff
-- diff
Base.Reverse_Elements (
Container.First,
Container.Last,
Container.Length);
-- diff
-- diff
end Reverse_Elements;
procedure Swap (Container : in out List; I, J : Cursor) is
pragma Unreferenced (Container);
-- diff
-- diff
Temp : constant Element_Access := I.Element;
begin
I.Element := J.Element;
J.Element := Temp;
-- diff
end Swap;
procedure Swap_Links (Container : in out List; I, J : Cursor) is
begin
-- diff
-- diff
-- diff
-- diff
Base.Swap_Links (
Container.First,
Container.Last,
Upcast (I),
Upcast (J));
-- diff
end Swap_Links;
procedure Splice (
Target : in out List;
Before : Cursor;
Source : in out List) is
begin
if Target.First /= Source.First then
-- diff
-- diff
-- diff
-- diff
-- diff
-- diff
Base.Splice (
Target.First,
Target.Last,
Target.Length,
Upcast (Before),
Source.First,
Source.Last,
Source.Length);
-- diff
end if;
end Splice;
procedure Splice (
Target : in out List;
Before : Cursor;
Source : in out List;
Position : in out Cursor) is
begin
if Before /= Position then -- RM A.18.3(114/3)
-- diff
-- diff
-- diff
-- diff
-- diff
-- diff
Base.Remove (
Source.First,
Source.Last,
Source.Length,
Upcast (Position),
Base.Next (Upcast (Position)));
Base.Insert (
Target.First,
Target.Last,
Target.Length,
Upcast (Before),
Upcast (Position));
-- diff
end if;
end Splice;
procedure Splice (
Container : in out List;
Before : Cursor;
Position : Cursor) is
begin
if Before /= Position then -- RM A.18.3(116/3)
-- diff
-- diff
-- diff
-- diff
Base.Remove (
Container.First,
Container.Last,
Container.Length,
Upcast (Position),
Base.Next (Upcast (Position)));
Base.Insert (
Container.First,
Container.Last,
Container.Length,
Upcast (Before),
Upcast (Position));
-- diff
end if;
end Splice;
function First (Container : List) return Cursor is
begin
return Downcast (Container.First);
-- diff
-- diff
-- diff
-- diff
-- diff
end First;
-- diff (First_Element)
--
--
--
--
function Last (Container : List) return Cursor is
begin
return Downcast (Container.Last);
-- diff
-- diff
-- diff
-- diff
-- diff
end Last;
-- diff (Last_Element)
--
--
--
--
function Next (Position : Cursor) return Cursor is
begin
return Downcast (Base.Next (Upcast (Position)));
end Next;
function Previous (Position : Cursor) return Cursor is
begin
return Downcast (Base.Previous (Upcast (Position)));
end Previous;
procedure Next (Position : in out Cursor) is
begin
Position := Downcast (Base.Next (Upcast (Position)));
end Next;
procedure Previous (Position : in out Cursor) is
begin
Position := Downcast (Base.Previous (Upcast (Position)));
end Previous;
-- diff (Find)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Find)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Reverse_Find)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Reverse_Find)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Contains)
--
--
--
function "<" (Left, Right : Cursor) return Boolean is
begin
return Base.Is_Before (Upcast (Left), Upcast (Right));
end "<";
procedure Iterate (
Container : List'Class;
Process : not null access procedure (Position : Cursor))
is
type P1 is access procedure (Position : Cursor);
type P2 is access procedure (Position : Base.Node_Access);
function Cast is new Unchecked_Conversion (P1, P2);
begin
-- diff
-- diff
Base.Iterate (
Container.First,
Cast (Process));
-- diff
end Iterate;
procedure Reverse_Iterate (
Container : List;
Process : not null access procedure (Position : Cursor))
is
type P1 is access procedure (Position : Cursor);
type P2 is access procedure (Position : Base.Node_Access);
function Cast is new Unchecked_Conversion (P1, P2);
begin
-- diff
-- diff
Base.Reverse_Iterate (
Container.Last,
Cast (Process));
-- diff
end Reverse_Iterate;
function Iterate (Container : List'Class)
return List_Iterator_Interfaces.Reversible_Iterator'Class is
begin
return List_Iterator'(
First => First (List (Container)),
Last => Last (List (Container)));
end Iterate;
function Iterate (Container : List'Class; First, Last : Cursor)
return List_Iterator_Interfaces.Reversible_Iterator'Class
is
pragma Unreferenced (Container);
Actual_First : Cursor := First;
Actual_Last : Cursor := Last;
begin
if Actual_First = No_Element
or else Actual_Last = No_Element
or else Actual_Last < Actual_First
then
Actual_First := No_Element;
Actual_Last := No_Element;
end if;
return List_Iterator'(First => Actual_First, Last => Actual_Last);
end Iterate;
-- diff (Adjust)
--
--
--
overriding function First (Object : List_Iterator) return Cursor is
begin
return Object.First;
end First;
overriding function Next (Object : List_Iterator; Position : Cursor)
return Cursor is
begin
if Position = Object.Last then
return No_Element;
else
return Next (Position);
end if;
end Next;
overriding function Last (Object : List_Iterator) return Cursor is
begin
return Object.Last;
end Last;
overriding function Previous (Object : List_Iterator; Position : Cursor)
return Cursor is
begin
if Position = Object.First then
return No_Element;
else
return Previous (Position);
end if;
end Previous;
package body Generic_Sorting is
function LT (Left, Right : not null Base.Node_Access) return Boolean;
function LT (Left, Right : not null Base.Node_Access) return Boolean is
begin
return Downcast (Left).Element.all < Downcast (Right).Element.all;
end LT;
function Is_Sorted (Container : List) return Boolean is
begin
-- diff
-- diff
-- diff
-- diff
return Base.Is_Sorted (Container.Last, LT => LT'Access);
-- diff
-- diff
-- diff
end Is_Sorted;
procedure Sort (Container : in out List) is
begin
-- diff
-- diff
-- diff
-- diff
-- diff
Base.Merge_Sort (
Container.First,
Container.Last,
Container.Length,
LT => LT'Access);
-- diff
-- diff
end Sort;
procedure Merge (Target : in out List; Source : in out List) is
pragma Check (Pre,
Check =>
Target'Address /= Source'Address
or else Is_Empty (Target)
or else raise Program_Error);
-- RM A.18.3(151/3), same nonempty container
begin
if not Is_Empty (Source) then
if Is_Empty (Target) then
Move (Target, Source);
else
-- diff
-- diff
-- diff
-- diff
-- diff
-- diff
-- diff
-- diff
Base.Merge (
Target.First,
Target.Last,
Target.Length,
Source.First,
Source.Last,
Source.Length,
LT => LT'Access);
-- diff
end if;
end if;
end Merge;
end Generic_Sorting;
package body Equivalents is
type Context_Type is limited record
Left : not null access Element_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function Equivalent_Element (
Right : not null Base.Node_Access;
Params : System.Address)
return Boolean;
function Equivalent_Element (
Right : not null Base.Node_Access;
Params : System.Address)
return Boolean
is
Context : aliased Context_Type;
for Context'Address use Params;
begin
return Context.Left.all = Downcast (Right).Element.all;
end Equivalent_Element;
function "=" (Left, Right : List) return Boolean is
function Equivalent (Left, Right : not null Base.Node_Access)
return Boolean;
function Equivalent (Left, Right : not null Base.Node_Access)
return Boolean is
begin
return Downcast (Left).Element.all = Downcast (Right).Element.all;
end Equivalent;
begin
return Left.Length = Right.Length
and then Base.Equivalent (
Left.Last,
Right.Last,
Equivalent => Equivalent'Access);
end "=";
function Find (Container : List; Item : Element_Type)
return Cursor
is
Context : aliased Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Base.Find (
Container.First,
Context'Address,
Equivalent => Equivalent_Element'Access));
end Find;
function Find (Container : List; Item : Element_Type; Position : Cursor)
return Cursor
is
pragma Check (Pre,
Check =>
(not Is_Empty (Container) and then Position /= No_Element)
or else (Is_Empty (Container) and then Position = No_Element)
or else raise Constraint_Error);
Context : aliased Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Base.Find (
Upcast (Position),
Context'Address,
Equivalent => Equivalent_Element'Access));
end Find;
function Reverse_Find (
Container : List;
Item : Element_Type)
return Cursor
is
Context : aliased Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (
Base.Reverse_Find (
Container.Last,
Context'Address,
Equivalent => Equivalent_Element'Access));
end Reverse_Find;
function Reverse_Find (
Container : List;
Item : Element_Type;
Position : Cursor)
return Cursor
is
pragma Check (Pre,
Check =>
(not Is_Empty (Container) and then Position /= No_Element)
or else (Is_Empty (Container) and then Position = No_Element)
or else raise Constraint_Error);
Context : aliased Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (
Base.Reverse_Find (
Upcast (Position),
Context'Address,
Equivalent => Equivalent_Element'Access));
end Reverse_Find;
function Contains (Container : List; Item : Element_Type)
return Boolean is
begin
return Find (Container, Item) /= null;
end Contains;
end Equivalents;
end Ada.Containers.Limited_Doubly_Linked_Lists;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . F I N A L I Z A T I O N _ I M P L E M E N T A T I O N --
-- --
-- S p e c --
-- --
-- $Revision: 2 $ --
-- --
-- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved --
-- --
-- The GNAT library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU Library General Public License as published by --
-- the Free Software Foundation; either version 2, or (at your option) any --
-- later version. The GNAT library is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Library General Public License for more details. You should have --
-- received a copy of the GNU Library General Public License along with --
-- the GNAT library; see the file COPYING.LIB. If not, write to the Free --
-- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- ??? this package should be a private package. It is set as public for now
-- in order to simplify testing
package System.Finalization_Implementation is
pragma Preelaborate (Finalization_Implementation);
type Root;
subtype Finalizable is Root'Class;
type Finalizable_Ptr is access all Root'Class;
type Root is abstract tagged record
Prev : Finalizable_Ptr;
Next : Finalizable_Ptr;
end record;
procedure Initialize (Object : in out Root) is abstract;
procedure Finalize (Object : in out Root) is abstract;
procedure Adjust (Object : in out Root);
-------------------------------------------------
-- Finalization Management Abstract Interface --
-------------------------------------------------
Global_Final_List : Finalizable_Ptr;
-- This list stores the controlled objects defined in library-level
-- packages. They will be finalized after the main program completion.
procedure Finalize_Global_List;
-- The procedure to be called in order to finalize the global list;
procedure Attach_To_Final_List
(L : in out Finalizable_Ptr;
Obj : in out Finalizable);
-- Put the finalizable object on a list of finalizable elements.
procedure Detach_From_Final_List
(L : in out Finalizable_Ptr;
Obj : in out Finalizable);
-- Remove the specified object from the Final list and reset its
-- pointers to null.
procedure Finalize_List (L : Finalizable_Ptr);
-- Call Finalize on each element of the list L;
procedure Finalize_One
(From : in out Finalizable_Ptr;
Obj : in out Finalizable);
-- Call Finalize on Obj and remove it from the list From.
-----------------------------
-- Record Controller Types --
-----------------------------
-- Definition of the types of the controller component that is included
-- in records containing controlled components. This controller is
-- attached to the finalization chain of the upper-level and carries
-- the pointer of the finalization chain for the lower level
type Limited_Record_Controller is new Root with record
F : System.Finalization_Implementation.Finalizable_Ptr;
end record;
procedure Initialize (Object : in out Limited_Record_Controller);
-- Does nothing
procedure Finalize (Object : in out Limited_Record_Controller);
-- Finalize the controlled components of the enclosing record by
-- following the list starting at Object.F
type Record_Controller is
new Limited_Record_Controller with record
My_Address : System.Address;
end record;
procedure Initialize (Object : in out Record_Controller);
-- Initialize the field My_Address to the Object'Address
procedure Adjust (Object : in out Record_Controller);
-- Adjust the components and their finalization pointers by substracting
-- by the offset of the target and the source addresses of the assignment
-- Inherit Finalize from Limited_Record_Controller
end System.Finalization_Implementation;
|
--------------------------------------------------------------------------
-- Arbitrary Precision Math Library: Constants
-- Joe Wingbermuehle 20020320 <> 20020327
--------------------------------------------------------------------------
with Arbitrary.Trig; use Arbitrary.Trig;
package body Arbitrary.Const is
-----------------------------------------------------------------------
-- Compute precision digits of pi
-----------------------------------------------------------------------
function Pi(precision : integer) return Arbitrary_Type is
result : Arbitrary_Type(precision);
one : constant Arbitrary_Type(precision) :=
To_Arbitrary(1, precision);
begin
-- pi = 4*(44*atan(1/57) + 7*atan(1/239) - 12*atan(1/682)
-- + 24*atan(1/12943)
result := To_Arbitrary(44 * 4, precision)
* ArcTan(one / To_Arbitrary(57, precision));
result := result + To_Arbitrary(7 * 4, precision)
* ArcTan(one / To_Arbitrary(239, precision));
result := result - To_Arbitrary(12 * 4, precision)
* ArcTan(one / To_Arbitrary(682, precision));
result := result + To_Arbitrary(24 * 4, precision)
* ArcTan(one / To_Arbitrary(12943, precision));
return result;
end Pi;
-----------------------------------------------------------------------
-- Compute precision digits of the golen ratio
-----------------------------------------------------------------------
function Golden_Ratio(precision : integer) return Arbitrary_Type is
result : Arbitrary_Type(precision);
begin
-- golen_ratio = (1 + sqrt(5)) / 2
result := To_Arbitrary(1, precision);
result := result + Square_Root(To_Arbitrary(5, precision));
result := result / To_Arbitrary(2, precision);
return result;
end Golden_Ratio;
end Arbitrary.Const;
|
with Ada.Numerics.Discrete_Random;
package body Alea is
subtype Intervalle is Integer range Lower_Bound..Upper_Bound;
package Generateur_P is
new Ada.Numerics.Discrete_Random (Intervalle);
use Generateur_P;
Generateur : Generateur_P.Generator;
procedure Get_Random_Number (Resultat : out Integer) is
begin
Resultat := Random (Generateur);
end Get_Random_Number;
begin
Reset(Generateur);
end Alea;
|
with Tkmrpc.Servers.Cfg;
with Tkmrpc.Response.Cfg.Tkm_Version.Convert;
package body Tkmrpc.Operation_Handlers.Cfg.Tkm_Version is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
pragma Unreferenced (Req);
Specific_Res : Response.Cfg.Tkm_Version.Response_Type;
begin
Specific_Res := Response.Cfg.Tkm_Version.Null_Response;
Servers.Cfg.Tkm_Version
(Result => Specific_Res.Header.Result,
Version => Specific_Res.Data.Version);
Res := Response.Cfg.Tkm_Version.Convert.To_Response (S => Specific_Res);
end Handle;
end Tkmrpc.Operation_Handlers.Cfg.Tkm_Version;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- R E P I N F O - I N P U T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2018-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides an alternate way of populating the internal tables
-- of Repinfo from a JSON input rather than the binary blob of the tree file.
-- Note that this is an additive mechanism, i.e. nothing is destroyed in the
-- internal state of the unit when it is used.
-- The first step is to feed the unit with a JSON stream of a specified format
-- (see the spec of Repinfo for its description) by means of Read_JSON_Stream.
-- Then, for each entity whose representation information is present in the
-- JSON stream, the appropriate Get_JSON_* routines can be invoked to override
-- the eponymous fields of the entity in the tree.
package Repinfo.Input is
function Get_JSON_Esize (Name : String) return Node_Ref_Or_Val;
-- Returns the Esize value of the entity specified by Name, which is not
-- the component of a record type, or else No_Uint if no representation
-- information was supplied for the entity. Name is the full qualified name
-- of the entity in lower case letters.
function Get_JSON_RM_Size (Name : String) return Node_Ref_Or_Val;
-- Likewise for the RM_Size
function Get_JSON_Component_Size (Name : String) return Node_Ref_Or_Val;
-- Likewise for the Component_Size of an array type
function Get_JSON_Component_Bit_Offset
(Name : String;
Record_Name : String) return Node_Ref_Or_Val;
-- Returns the Component_Bit_Offset of the component specified by Name,
-- which is declared in the record type specified by Record_Name, or else
-- No_Uint if no representation information was supplied for the component.
-- Name is the unqualified name of the component whereas Record_Name is the
-- full qualified name of the record type, both in lower case letters.
function Get_JSON_Esize
(Name : String;
Record_Name : String) return Node_Ref_Or_Val;
-- Likewise for the Esize
Invalid_JSON_Stream : exception;
-- Raised if a format error is detected in the JSON stream
procedure Read_JSON_Stream (Text : Text_Buffer; File_Name : String);
-- Reads a JSON stream and populates internal tables from it. File_Name is
-- only used in error messages issued by the JSON parser.
end Repinfo.Input;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Markdown.ATX_Headings;
with Markdown.Blockquotes;
with Markdown.Fenced_Code_Blocks;
with Markdown.HTML_Blocks;
with Markdown.Indented_Code_Blocks;
with Markdown.Link_Reference_Definitions;
with Markdown.List_Items;
with Markdown.Lists;
with Markdown.Paragraphs;
with Markdown.Thematic_Breaks;
package Markdown.Visitors is
type Visitor is limited interface;
not overriding procedure ATX_Heading
(Self : in out Visitor;
Value : Markdown.ATX_Headings.ATX_Heading) is null;
not overriding procedure Blockquote
(Self : in out Visitor;
Value : in out Markdown.Blockquotes.Blockquote) is null;
not overriding procedure Fenced_Code_Block
(Self : in out Visitor;
Value : Markdown.Fenced_Code_Blocks.Fenced_Code_Block) is null;
not overriding procedure HTML_Block
(Self : in out Visitor;
Value : Markdown.HTML_Blocks.HTML_Block) is null;
not overriding procedure Indented_Code_Block
(Self : in out Visitor;
Value : Markdown.Indented_Code_Blocks.Indented_Code_Block) is null;
not overriding procedure Link_Reference_Definition
(Self : in out Visitor;
Value : Markdown.Link_Reference_Definitions.Link_Reference_Definition) is
null;
not overriding procedure List_Item
(Self : in out Visitor;
Value : in out Markdown.List_Items.List_Item) is null;
not overriding procedure List
(Self : in out Visitor;
Value : Markdown.Lists.List) is null;
not overriding procedure Paragraph
(Self : in out Visitor;
Value : Markdown.Paragraphs.Paragraph) is null;
not overriding procedure Thematic_Break
(Self : in out Visitor;
Value : Markdown.Thematic_Breaks.Thematic_Break) is null;
end Markdown.Visitors;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@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.
private with GL.Low_Level;
package GL.Barriers is
pragma Preelaborate;
type Memory_Barrier_Bits (By_Region : Boolean) is record
Uniform : Boolean := False;
Texture_Fetch : Boolean := False;
Shader_Image_Access : Boolean := False;
Framebuffer : Boolean := False;
Atomic_Counter : Boolean := False;
Shader_Storage : Boolean := False;
case By_Region is
when False =>
Element_Array : Boolean := False;
Command : Boolean := False;
Pixel_Buffer : Boolean := False;
Texture_Update : Boolean := False;
Buffer_Update : Boolean := False;
Client_Mapped_Buffer : Boolean := False;
Query_Buffer : Boolean := False;
when others =>
null;
end case;
end record;
procedure Texture_Barrier;
procedure Memory_Barrier (Bits : Memory_Barrier_Bits)
with Pre => not Bits.By_Region;
-- Order memory transactions issued before this call relative
-- to those issues after this call
procedure Memory_Barrier_By_Region (Bits : Memory_Barrier_Bits)
with Pre => Bits.By_Region;
-- Order memory transactions caused by fragment shaders
private
for Memory_Barrier_Bits use record
Element_Array at 0 range 1 .. 1;
Uniform at 0 range 2 .. 2;
Texture_Fetch at 0 range 3 .. 3;
Shader_Image_Access at 0 range 5 .. 5;
Command at 0 range 6 .. 6;
Pixel_Buffer at 0 range 7 .. 7;
Texture_Update at 0 range 8 .. 8;
Buffer_Update at 0 range 9 .. 9;
Framebuffer at 0 range 10 .. 10;
Atomic_Counter at 0 range 12 .. 12;
Shader_Storage at 0 range 13 .. 13;
Client_Mapped_Buffer at 0 range 14 .. 14;
Query_Buffer at 0 range 15 .. 15;
-- Discriminant
By_Region at 2 range 0 .. 0;
end record;
for Memory_Barrier_Bits'Size use Low_Level.Bitfield'Size;
end GL.Barriers;
|
-- { dg-do compile { target i?86-*-* x86_64-*-* } }
-- { dg-options "-O3 -msse2 -fdump-tree-vect-details" }
package body Vect18 is
procedure Comp (X, Y : Sarray; R : in out Sarray) is
Tmp : Long_Float := R(4);
begin
for I in 1 .. 3 loop
R(I+1) := R(I) + X(I) + Y(I);
end loop;
R(1) := Tmp + X(4) + Y(4);
end;
end Vect18;
-- { dg-final { scan-tree-dump "bad data dependence" "vect" } }
|
-----------------------------------------------------------------------
-- wiki-streams-builders -- Wiki writer to a string builder
-- Copyright (C) 2011, 2012, 2013, 2015, 2016 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 Wiki.Strings;
-- === Output Builder Stream ==
-- The <tt>Output_Builder_Stream</tt> is a concrete in-memory output stream.
-- It collects the output in a <tt>Wiki.Strings.Bstring</tt> object and the
-- content can be retrieved at the end by using the <tt>To_String</tt>
-- or <tt>Iterate</tt> operation.
package Wiki.Streams.Builders is
type Output_Builder_Stream is limited new Output_Stream with private;
type Output_Builder_Stream_Access is access all Output_Builder_Stream'Class;
-- Write the content to the string builder.
overriding
procedure Write (Stream : in out Output_Builder_Stream;
Content : in Wiki.Strings.WString);
-- Write a single character to the string builder.
overriding
procedure Write (Stream : in out Output_Builder_Stream;
Content : in Wiki.Strings.WChar);
-- Write the string to the string builder.
procedure Write_String (Stream : in out Output_Builder_Stream;
Content : in String);
-- Iterate over the buffer content calling the <tt>Process</tt> procedure with each
-- chunk.
procedure Iterate (Source : in Output_Builder_Stream;
Process : not null access procedure (Chunk : in Wiki.Strings.WString));
-- Convert what was collected in the writer builder to a string and return it.
function To_String (Source : in Output_Builder_Stream) return String;
private
BLOCK_SIZE : constant Positive := 512;
type Output_Builder_Stream is limited new Output_Stream with record
Content : Wiki.Strings.BString (BLOCK_SIZE);
end record;
end Wiki.Streams.Builders;
|
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Unchecked_Deallocation;
use Ada.Text_IO, Ada.Integer_Text_IO;
package body Int_Binary_Tree is
type Compare_Result_Type is ( Less_Than, Equal, Greater_Than );
type Traced_Node_Type is
record
Node : Tree_Node_Ptr;
Parent : Tree_Node_Ptr;
end record;
----------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation( Tree_Node,
Tree_Node_Ptr );
----------------------------------------------------------------------
function Compare( Left, Right : in Integer ) return
Compare_Result_Type is
begin
if Left < Right then
return Less_Than;
elsif Left > Right then
return Greater_Than;
else
return Equal;
end if;
end Compare;
----------------------------------------------------------------------
function Find_Node( Tree: in T; Number: in Integer ) return
Traced_Node_Type is
T_Node : Traced_Node_Type := Traced_Node_Type'( Node => Tree.Root,
Parent => null );
Node : Tree_Node_Ptr renames T_Node.Node;
Parent : Tree_Node_Ptr renames T_Node.Parent;
begin
while Node /= null loop
case Compare ( Number, Node.Data ) is
when Equal =>
return T_Node;
when Less_Than =>
Parent := Node;
Node := Node.Left;
when Greater_Than =>
Parent := Node;
Node := Node.Right;
end case;
end loop;
return T_Node;
end Find_Node;
----------------------------------------------------------------------
function Is_In_Tree( Tree: in T; Number: in Integer ) return Boolean is
T_Node : Traced_Node_Type := Find_Node( Tree, Number );
begin
if T_Node.Node /= null then
return True;
else
return False;
end if;
end Is_In_Tree;
----------------------------------------------------------------------
procedure Insert( Tree: in out T; Number: in Integer ) is
T_Node : Traced_Node_Type := Find_Node( Tree, Number );
New_Node : Tree_Node_Ptr := new Tree_Node'( Data => Number,
Left => null,
Right => null );
begin
if T_Node.Node /= null then
return;
elsif T_Node.Parent = null then
Tree.Root := New_Node;
else
case Compare( Number, T_Node.Parent.Data ) is
when Less_Than =>
T_Node.Parent.Left := New_Node;
when Greater_Than =>
T_Node.Parent.Right := New_Node;
when Equal =>
null;
end case;
end if;
end Insert;
----------------------------------------------------------------------
procedure Remove( Tree: in out T; Number: in Integer ) is
Remove_Node : Traced_Node_Type := Find_Node( Tree, Number );
Pivot_Node : Tree_Node_Ptr;
Pivot_Node_Parent : Tree_Node_Ptr;
procedure Graft( Tree: in out T;
Old_Node,
New_Node,
Parent: in out Tree_Node_Ptr ) is
begin
if Parent /= null then
if Parent.Left = Old_Node then
Parent.Left := New_Node;
else
Parent.Right := New_Node;
end if;
else
Tree.Root := New_Node;
end if;
end Graft;
begin
if Remove_Node.Node = null then
return;
end if;
if Remove_Node.Node.Left = null then
Graft( Tree, Remove_Node.Node, Remove_Node.Node.Right, Remove_Node.Parent );
Free( Remove_Node.Node );
elsif Remove_Node.Node.Right = null then
Graft( Tree, Remove_Node.Node, Remove_Node.Node.Left, Remove_Node.Parent );
Free( Remove_Node.Node );
else
Pivot_Node_Parent := Remove_Node.Node;
Pivot_Node := Remove_Node.Node.Left;
while Pivot_Node.Right /= null loop
Pivot_Node_Parent := Pivot_Node;
Pivot_Node := Pivot_Node.Right;
end loop;
if Pivot_Node_Parent = Remove_Node.Node then
Pivot_Node.Right := Remove_Node.Node.Right;
else
Pivot_Node_Parent.Right := Pivot_Node.Left;
Pivot_Node.Left := Remove_Node.Node.Left;
Pivot_Node.Right := Remove_Node.Node.Right;
end if;
Graft( Tree, Remove_Node.Node, Pivot_Node, Remove_Node.Parent );
end if;
end Remove;
----------------------------------------------------------------------
procedure Print( Tree: in T ) is
procedure Print_Node( Node: in Tree_Node_Ptr ) is
begin
if Node.Left /= null then
Print_Node( Node.Left );
end if;
Put(Node.Data);
New_Line;
if Node.Right /= null then
Print_Node( Node.Right );
end if;
end;
begin
Print_Node( Tree.Root );
end Print;
----------------------------------------------------------------------
procedure Debug_Print( Tree: in T ) is
procedure Print_Node( Node: in Tree_Node_Ptr ) is
procedure Print_Branch( Node: in Tree_Node_Ptr ) is
begin
if Node = null then
Put(" null");
else
Put(Node.Data);
end if;
end Print_Branch;
begin
if Node.Left /= null then
Print_Node( Node.Left );
end if;
Put(Node.Data);
Put(" Left: "); Print_Branch(Node.Left);
Put(" Right:"); Print_Branch(Node.Right);
New_Line;
if Node.Right /= null then
Print_Node( Node.Right );
end if;
end Print_Node;
begin
Print_Node( Tree.Root );
end Debug_Print;
end Int_Binary_Tree;
|
with STM32GD.Board; use STM32GD.Board;
with Drivers.Si7006;
procedure Main is
package Si7006 is new Drivers.Si7006 (I2C => I2C);
Temperature : Si7006.Temperature_Type;
Humidity : Si7006.Humidity_Type;
Now : RTC.Date_Time_Type;
Wait_Time : RTC.Second_Delta_Type := 5;
begin
Init;
Text_IO.Put_Line ("Temperature/Humidity sensor starting");
loop
RTC.Read (Now);
LED.Set;
Text_IO.Put_Line ("Reading sensor data");
Temperature := Si7006.Temperature_x100;
Humidity := Si7006.Humidity;
Text_IO.Put ("Temperature: "); Text_IO.Put_Integer (Temperature);
Text_IO.Put (" Humidity: "); Text_IO.Put_Integer (Humidity);
Text_IO.New_Line;
LED.Clear;
RTC.Add_Seconds (Now, Wait_Time);
RTC.Set_Alarm (Now);
RTC.Wait_For_Alarm;
end loop;
end Main;
|
-- ----------------------------------------------------------------- --
-- --
-- This 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 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 this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- ----------------------------------------------------------------- --
-- ----------------------------------------------------------------- --
-- This is a translation, to the Ada programming language, of the --
-- original C test files written by Sam Lantinga - www.libsdl.org --
-- translation made by Antonio F. Vargas - www.adapower.net/~avargas --
-- ----------------------------------------------------------------- --
-- Simple program: Loop, watching keystrokes
-- Note that you need to call SDL.Events.PollEvent
-- or SDL.Events.WaitEvent to pump the event loop
-- and catch keystrokes.
with Interfaces.C.Strings;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib;
with SDL.Types; use SDL.Types;
with SDL.Keysym;
with SDL.Keyboard;
with SDL.Error;
with SDL.Quit;
with SDL.Events;
with SDL.Video;
procedure CheckKeys is
package C renames Interfaces.C;
use type C.int;
use type C.wchar_t;
package CS renames Interfaces.C.Strings;
package Ks renames SDL.Keysym;
use type Ks.Key;
package Kb renames SDL.Keyboard;
package Er renames SDL.Error;
package Ev renames SDL.Events;
package V renames SDL.Video;
Screen_Width : constant := 640;
Screen_Height : constant := 480;
-- ===============================================
procedure PrintKey (sym : in Kb.keysym; pressed : Boolean) is
begin
-- Print the keycode, name and state
if sym.sym /= 0 then
Put ("Key ");
if pressed then
Put ("pressed: ");
else
Put ("released: ");
end if;
Put (Ks.Key'Image (sym.sym) & "-" &
CS.Value (Kb.GetKeyName (sym.sym)) &
" ");
else
Put ("Unknown Key (scancode = " &
Uint8'Image (sym.scancode) & ") ");
if pressed then
Put_Line ("pressed: ");
else
Put_Line ("released: ");
end if;
end if;
-- Print the translated character, if one exists
if sym.unicode /= 0 then
-- Is it a control-character?
if C.wchar_t'Val (sym.unicode) < C.wchar_t'(' ') then
Put_Line (" (^"
& C.wchar_t'Image (C.wchar_t'Val
(sym.unicode)) & "@)");
-- & Uint16'Image (sym.unicode) & "@)");
else
-- #ifdef UNICODE
-- Put_Line (" (" & Uint16'Image (sym.unicode) & ")");
Put_Line (" (" & C.wchar_t'Image (C.wchar_t'Val
(sym.unicode)) & ")");
-- #else
-- This is a Latin-1 program, so only show 8-bits */
-- if (sym.unicode and 16#FF00#) = 0 then
-- Put_Line (" (" & Uint16'Image (sym.unicode) & ")");
-- end if;
-- #endif
end if;
end if;
New_Line;
end PrintKey;
-- ===============================================
event : Ev.Event;
done : C.int; -- Boolean should be better.
begin
-- Initialize SDL
if SDL.Init (SDL.INIT_VIDEO) < 0 then
Put_Line ("Couldn't initialize SDl: " & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (1);
end if;
SDL.Quit.atexit (SDL.SDL_Quit'Access);
declare
screen : V.Surface_ptr;
use type V.Surface_ptr;
begin
-- Set video mode
screen := V.SetVideoMode (Screen_Width, Screen_Height,
0, V.SWSURFACE);
if screen = null then
Put_Line ("Couldn't set " & Integer'Image (Screen_Width) &
"x" & Integer'Image (Screen_Height) &
" video mode: " & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (2);
end if;
end;
-- Enable UNICODE translation for keyboard input
Kb.EnableUNICODE (1);
Kb.EnableKeyRepeat (
Kb.DEFAULT_REPEAT_DELAY,
Kb.DEFAULT_REPEAT_INTERVAL);
-- Watch keystrokes
done := 0;
while done = 0 loop
-- Check for events
-- Read the note in the "event" declaration point.
Ev.WaitEvent (event);
case event.the_type is
when Ev.KEYDOWN =>
-- Read the note in the "event" declaration point.
PrintKey (event.key.keysym, True);
when Ev.KEYUP =>
-- Read the note in the "event" declaration point.
PrintKey (event.key.keysym, False);
when Ev.MOUSEBUTTONDOWN | Ev.QUIT =>
-- Any button press quits the app...
done := 1;
when others => null;
end case;
end loop;
end CheckKeys;
|
-- { dg-do run }
with Atomic7_Pkg2; use Atomic7_Pkg2;
procedure Atomic7_1 is
I : Integer := Stamp;
pragma Atomic (I);
J : Integer := Stamp;
begin
if I /= 1 then
raise Program_Error;
end if;
end;
|
generic
with function f(x:float) return float;
package Adaptive_Quad is
function AQuad(a, b, eps: float) return float;
end Adaptive_Quad; |
-- AOC 2020, Day 3
with Ada.Text_IO; use Ada.Text_IO;
with Day; use Day;
procedure main is
f : constant Forest := load_map("input.txt");
slope : constant Natural := 3;
begin
put_line("Part 1: " & Natural'Image(trees_hit(f, slope)));
put_line("Part 2: " & Natural'Image(many_trees_hit(f)));
end main;
|
with Extraction.Node_Edge_Types;
package body Extraction.Source_Files_From_Projects is
use type VFS.File_Array_Access;
use type VFS.Filesystem_String;
procedure Extract_Nodes
(Project : GPR.Project_Type; Graph : Graph_Operations.Graph_Context)
is
Source_Files : VFS.File_Array_Access :=
Project.Extended_Projects_Source_Files;
begin
for Source_File of Source_Files.all loop
Graph.Write_Node (Source_File);
end loop;
VFS.Unchecked_Free (Source_Files);
end Extract_Nodes;
procedure Extract_Edges
(Project : GPR.Project_Type; Context : Utilities.Project_Context;
Recurse_Projects : Boolean; Graph : Graph_Operations.Graph_Context)
is
Source_Files : VFS.File_Array_Access :=
Project.Extended_Projects_Source_Files;
Main_Files : VFS.File_Array_Access := null;
Has_Non_Ada_Main : Boolean := False;
begin
for Source_File of Source_Files.all loop
Graph.Write_Edge
(Project, Source_File, Node_Edge_Types.Edge_Type_Contains);
-- GPRBuild compiles all sources in languages other than Ada.
if not Utilities.Is_Ada_File_In_Project_Context
(+Source_File.Full_Name, Context, Recurse_Projects)
and then Utilities.Is_Buildable_File_In_Project_Context
(+Source_File.Full_Name, Context)
then
Graph.Write_Edge
(Project, Source_File, Node_Edge_Types.Edge_Type_Compiles);
end if;
if Project.Is_Main_File (Source_File.Full_Name) then
VFS.Append (Main_Files, Source_File);
Has_Non_Ada_Main :=
Has_Non_Ada_Main or
not Utilities.Is_Ada_File_In_Project_Context
(+Source_File.Full_Name, Context, Recurse_Projects);
end if;
end loop;
VFS.Unchecked_Free (Source_Files);
-- This is an over-approximation, as we do not handle the
-- "Roots" attibute; see the description of compilation phase
-- in the GPRBuild documentation.
declare
Built_Files : VFS.File_Array_Access;
begin
if Has_Non_Ada_Main
-- GPRBuild compiles all Ada soruces if there is non-Ada main.
or else Main_Files = null
-- GPRBuild compiles all Ada sources if no main is specified.
then
Built_Files := Project.Extended_Projects_Source_Files;
else
declare
Status : GPR.Status_Type;
begin
-- GPRBuild compiles all Ada files in the closure
-- of an Ada main.
Project.Get_Closures
(Main_Files, False, False, Status, Built_Files);
end;
end if;
for Built_File of Built_Files.all loop
if Utilities.Is_Buildable_File_In_Project_Context
(+Built_File.Full_Name, Context)
then
Graph.Write_Edge
(Project, Built_File, Node_Edge_Types.Edge_Type_Compiles);
end if;
end loop;
VFS.Unchecked_Free (Built_Files);
end;
VFS.Unchecked_Free (Main_Files);
end Extract_Edges;
end Extraction.Source_Files_From_Projects;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2018, 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. --
-- --
------------------------------------------------------------------------------
with STM32_SVD.CAN; use STM32_SVD.CAN;
with STM32.Device;
package body STM32.CAN is
use Ada.Real_Time;
---------------
-- Reset_CAN --
---------------
procedure Reset_CAN
(This : in out CAN_Controller)
is
begin
This.MCR.RESET := True;
end Reset_CAN;
-------------------
-- Set_Init_Mode --
-------------------
procedure Set_Init_Mode
(This : in out CAN_Controller;
Enabled : in Boolean)
is
Deadline : constant Time := Clock + Default_Timeout;
Success : Boolean;
begin
This.MCR.INRQ := Enabled;
while Clock < Deadline loop
if Enabled then
Success := Is_Init_Mode (This);
else
Success := not Is_Init_Mode (This);
end if;
exit when Success;
end loop;
end Set_Init_Mode;
---------------------
-- Enter_Init_Mode --
---------------------
procedure Enter_Init_Mode
(This : in out CAN_Controller)
is
begin
Set_Init_Mode (This, True);
end Enter_Init_Mode;
------------------
-- Is_Init_Mode --
------------------
function Is_Init_Mode (This : CAN_Controller) return Boolean is
(This.MSR.INAK);
--------------------
-- Exit_Init_Mode --
--------------------
procedure Exit_Init_Mode
(This : in out CAN_Controller)
is
begin
Set_Init_Mode (This, False);
end Exit_Init_Mode;
--------------------
-- Set_Sleep_Mode --
--------------------
procedure Set_Sleep_Mode
(This : in out CAN_Controller;
Enabled : in Boolean)
is
Deadline : constant Time := Clock + Default_Timeout;
Success : Boolean;
begin
This.MCR.SLEEP := Enabled;
while Clock < Deadline loop
if Enabled then
Success := Is_Sleep_Mode (This);
else
Success := not Is_Sleep_Mode (This);
end if;
exit when Success;
end loop;
end Set_Sleep_Mode;
-----------
-- Sleep --
-----------
procedure Sleep
(This : in out CAN_Controller)
is
begin
Exit_Init_Mode (This);
Set_Sleep_Mode (This, True);
end Sleep;
-------------------
-- Is_Sleep_Mode --
-------------------
function Is_Sleep_Mode (This : CAN_Controller) return Boolean is
(This.MSR.SLAK);
------------
-- Wakeup --
------------
procedure Wakeup
(This : in out CAN_Controller)
is
begin
Set_Sleep_Mode (This, False);
end Wakeup;
--------------------------
-- Calculate_Bit_Timing --
--------------------------
procedure Calculate_Bit_Timing
(Speed : in Bit_Rate_Range;
Sample_Point : in Sample_Point_Range;
Tolerance : in Clock_Tolerance;
Bit_Timing : in out Bit_Timing_Config)
is
-- The CAN clock frequency comes from APB1 peripheral clock (PCLK1).
Clock_In : constant Float := Float (STM32.Device.System_Clock_Frequencies.PCLK1);
-- Time Quanta in one Bit Time
Time_Quanta : Float;
-- Found Bit Time Quanta value.
BTQ : Boolean := False;
begin
-- Assure the clock frequency is high enough.
pragma Assert
(Integer (Clock_In / (Speed * 1_000.0 *
Float (Time_Quanta_Prescaler'First))) < Bit_Time_Quanta'First,
"CAN clock frequency too low for this bit rate.");
-- Assure the clock frequency is low enough.
pragma Assert
(Integer (Clock_In / (Speed * 1_000.0 *
Float (Time_Quanta_Prescaler'Last))) > Bit_Time_Quanta'Last,
"CAN clock frequency too high for this bit rate.");
for I in Time_Quanta_Prescaler'First .. Time_Quanta_Prescaler'Last loop
-- Choose the minimum divisor for the maximum number of Time Quanta.
Time_Quanta := Clock_In / (Speed * 1000.0 * Float (I));
-- Test if Time_Quanta < Bit_Time_Quanta'First
if Integer (Time_Quanta) < Bit_Time_Quanta'First then
exit;
-- Test if Time Quanta <= Bit_Time_Quanta'Last and if
-- Sample Point <= Segment_Sync_Quanta + Segment_1_Quanta'Last
elsif Integer (Time_Quanta) <= Bit_Time_Quanta'Last and
Integer (Time_Quanta * Sample_Point / 100.0) <=
(Segment_Sync_Quanta + Segment_1_Quanta'Last)
then
-- Calculate time segments
Bit_Timing.Time_Segment_1 :=
Integer (Time_Quanta * Sample_Point / 100.0) - Segment_Sync_Quanta;
-- Casting a float to integer rounds it to the near integer.
Bit_Timing.Time_Segment_2 :=
Integer (Time_Quanta) - Segment_Sync_Quanta - Bit_Timing.Time_Segment_1;
if Bit_Timing.Time_Segment_2 < 4 then
Bit_Timing.Resynch_Jump_Width := Bit_Timing.Time_Segment_2;
else
Bit_Timing.Resynch_Jump_Width := 4;
end if;
-- We want a division that gives tolerance inside tolerance range.
if Tolerance >= abs (Clock_In - Float ((Segment_Sync_Quanta +
Bit_Timing.Time_Segment_1 + Bit_Timing.Time_Segment_2) * I) *
Speed * 1000.0) * 100.0 / Clock_In and
Tolerance <= Float (Bit_Timing.Time_Segment_2) /
Float (2 * (13 * Integer (Time_Quanta))) and
Tolerance <= Float (Bit_Timing.Resynch_Jump_Width) /
Float (20 * Integer (Time_Quanta))
then
Bit_Timing.Quanta_Prescaler := I;
BTQ := True;
exit;
end if;
end if;
end loop;
pragma Assert
(not BTQ, "Can't find a division factor for this bit rate within tolerance.");
end Calculate_Bit_Timing;
--------------------------
-- Configure_Bit_Timing --
--------------------------
procedure Configure_Bit_Timing
(This : in out CAN_Controller;
Timing_Config : in Bit_Timing_Config)
is
begin
This.BTR :=
(BRP => UInt10 (Timing_Config.Quanta_Prescaler - 1),
Reserved_10_15 => 0,
TS1 => UInt4 (Timing_Config.Time_Segment_1 - 1),
TS2 => UInt3 (Timing_Config.Time_Segment_2 - 1),
Reserved_23_23 => 0,
SJW => UInt2 (Timing_Config.Resynch_Jump_Width - 1),
Reserved_26_29 => 0,
LBKM => This.BTR.LBKM,
SILM => This.BTR.SILM);
end Configure_Bit_Timing;
------------------------
-- Set_Operating_Mode --
------------------------
procedure Set_Operating_Mode
(This : in out CAN_Controller;
Mode : in Operating_Mode)
is
begin
case Mode is
when Normal =>
This.BTR.LBKM := False;
This.BTR.SILM := False;
when Loopback =>
This.BTR.LBKM := True;
This.BTR.SILM := False;
when Silent =>
This.BTR.LBKM := False;
This.BTR.SILM := True;
when Silent_Loopback =>
This.BTR.LBKM := True;
This.BTR.SILM := True;
end case;
end Set_Operating_Mode;
---------------
-- Configure --
---------------
procedure Configure
(This : in out CAN_Controller;
Mode : in Operating_Mode;
Time_Triggered : in Boolean;
Auto_Bus_Off : in Boolean;
Auto_Wakeup : in Boolean;
Auto_Retransmission : in Boolean;
Rx_FIFO_Locked : in Boolean;
Tx_FIFO_Prio : in Boolean;
Timing_Config : in Bit_Timing_Config)
is
begin
Wakeup (This);
Enter_Init_Mode (This);
This.MCR.TTCM := Time_Triggered;
This.MCR.ABOM := Auto_Bus_Off;
This.MCR.AWUM := Auto_Wakeup;
This.MCR.NART := not Auto_Retransmission;
This.MCR.RFLM := Rx_FIFO_Locked;
This.MCR.TXFP := Tx_FIFO_Prio;
Configure_Bit_Timing (This, Timing_Config);
Set_Operating_Mode (This, Mode);
Exit_Init_Mode (This);
end Configure;
-- The following registers are referred from CAN1 only:
-- FMR, FM1R, FS1R, FFA1R, FA1R
-- FxR1 (x=0..27)
-- FxR2 (x=0..27)
-- (I.e. filter registers)
CAN1 : CAN_Peripheral renames CAN_Periph;
---------------
-- Write_FxR --
---------------
procedure Write_FxR
(X : in Filter_Bank_Nr;
FxR1 : in UInt32;
FxR2 : in UInt32)
is
begin
case X is
when 0 => CAN1.F0R1.Val := FxR1; CAN1.F0R2.Val := FxR2;
when 1 => CAN1.F1R1.Val := FxR1; CAN1.F1R2.Val := FxR2;
when 2 => CAN1.F2R1.Val := FxR1; CAN1.F2R2.Val := FxR2;
when 3 => CAN1.F3R1.Val := FxR1; CAN1.F3R2.Val := FxR2;
when 4 => CAN1.F4R1.Val := FxR1; CAN1.F4R2.Val := FxR2;
when 5 => CAN1.F5R1.Val := FxR1; CAN1.F5R2.Val := FxR2;
when 6 => CAN1.F6R1.Val := FxR1; CAN1.F6R2.Val := FxR2;
when 7 => CAN1.F7R1.Val := FxR1; CAN1.F7R2.Val := FxR2;
when 8 => CAN1.F8R1.Val := FxR1; CAN1.F8R2.Val := FxR2;
when 9 => CAN1.F9R1.Val := FxR1; CAN1.F9R2.Val := FxR2;
when 10 => CAN1.F10R1.Val := FxR1; CAN1.F10R2.Val := FxR2;
when 11 => CAN1.F11R1.Val := FxR1; CAN1.F11R2.Val := FxR2;
when 12 => CAN1.F12R1.Val := FxR1; CAN1.F12R2.Val := FxR2;
when 13 => CAN1.F13R1.Val := FxR1; CAN1.F13R2.Val := FxR2;
end case;
end Write_FxR;
----------------------------
-- Enter_Filter_Init_Mode --
----------------------------
procedure Enter_Filter_Init_Mode
is
begin
CAN1.FMR.FINIT := True;
end Enter_Filter_Init_Mode;
-------------------------
-- Is_Filter_Init_Mode --
-------------------------
function Is_Filter_Init_Mode return Boolean is
(CAN1.FMR.FINIT);
---------------------------
-- Exit_Filter_Init_Mode --
---------------------------
procedure Exit_Filter_Init_Mode
is
begin
CAN1.FMR.FINIT := False;
end Exit_Filter_Init_Mode;
---------------------------
-- Set_Filter_Activation --
---------------------------
procedure Set_Filter_Activation
(Bank_Nr : in Filter_Bank_Nr;
Enabled : in Boolean)
is
begin
CAN1.FA1R.FACT.Arr (Bank_Nr) := Enabled;
end Set_Filter_Activation;
----------------------
-- Set_Filter_Scale --
----------------------
procedure Set_Filter_Scale
(Bank_Nr : in Filter_Bank_Nr;
Mode : in Mode_Scale)
is
begin
case Mode is
when List16 | Mask16 =>
CAN1.FS1R.FSC.Arr (Bank_Nr) := False;
when List32 | Mask32 =>
CAN1.FS1R.FSC.Arr (Bank_Nr) := True;
end case;
end Set_Filter_Scale;
---------------------
-- Set_Filter_Mode --
---------------------
procedure Set_Filter_Mode
(Bank_Nr : in Filter_Bank_Nr;
Mode : in Mode_Scale)
is
begin
case Mode is
when List16 | List32 =>
CAN1.FM1R.FBM.Arr (Bank_Nr) := True;
when Mask16 | Mask32 =>
CAN1.FM1R.FBM.Arr (Bank_Nr) := False;
end case;
end Set_Filter_Mode;
-------------------------
-- Set_Fifo_Assignment --
-------------------------
procedure Set_Fifo_Assignment
(Bank_Nr : in Filter_Bank_Nr;
Fifo : in Fifo_Nr)
is
begin
case Fifo is
when FIFO_0 =>
CAN1.FFA1R.FFA.Arr (Bank_Nr) := False;
when FIFO_1 =>
CAN1.FFA1R.FFA.Arr (Bank_Nr) := True;
end case;
end Set_Fifo_Assignment;
----------------------
-- Configure_Filter --
----------------------
procedure Configure_Filter
(This : in out CAN_Controller;
Bank_Config : in CAN_Filter_Bank)
is
pragma Unreferenced (This);
Nr : constant Filter_Bank_Nr := Bank_Config.Bank_Nr;
Reg_Repr : Filter_Reg_Union;
begin
Enter_Filter_Init_Mode;
Set_Filter_Activation (Nr, False);
case Bank_Config.Filters.Mode is
when List32 =>
Reg_Repr := (False, (List32, Bank_Config.Filters.List32));
when Mask32 =>
Reg_Repr := (False, (Mask32, Bank_Config.Filters.Mask32));
when List16 =>
Reg_Repr := (False, (List16, Bank_Config.Filters.List16));
when Mask16 =>
Reg_Repr := (False, (Mask16, Bank_Config.Filters.Mask16));
end case;
Set_Filter_Scale (Nr, Bank_Config.Filters.Mode);
Write_FxR (Nr, Reg_Repr.FxR1, Reg_Repr.FxR2);
Set_Filter_Mode (Nr, Bank_Config.Filters.Mode);
Set_Fifo_Assignment (Nr, Bank_Config.Fifo_Assignment);
Set_Filter_Activation (Nr, True);
Exit_Filter_Init_Mode;
end Configure_Filter;
--------------------------
-- Set_Slave_Start_Bank --
--------------------------
procedure Set_Slave_Start_Bank
(Bank_Nr : in Filter_Bank_Nr)
is
begin
CAN1.FMR.CAN2SB := UInt6 (Bank_Nr);
end Set_Slave_Start_Bank;
--------------------------
-- Get_Slave_Start_Bank --
--------------------------
function Get_Slave_Start_Bank return Filter_Bank_Nr is
(Filter_Bank_Nr (CAN1.FMR.CAN2SB));
------------------
-- Release_Fifo --
------------------
procedure Release_Fifo
(This : in out CAN_Controller;
Fifo : in Fifo_Nr)
is
begin
case Fifo is
when FIFO_0 =>
This.RF0R.RFOM0 := True;
when FIFO_1 =>
This.RF1R.RFOM1 := True;
end case;
end Release_Fifo;
---------------------
-- Read_Rx_Message --
---------------------
function Read_Rx_Message
(This : CAN_Controller;
Fifo : Fifo_Nr)
return CAN_Message
is
begin
case Fifo is
when FIFO_0 =>
return CAN_Message'
(Std_ID => This.RI0R.STID,
Ext_ID => This.RI0R.EXID,
Ide => This.RI0R.IDE,
Rtr => This.RI0R.RTR,
Dlc => This.RDT0R.DLC,
Data => Message_Data (This.RDL0R.Arr) &
Message_Data (This.RDH0R.Arr));
when FIFO_1 =>
return CAN_Message'
(Std_ID => This.RI1R.STID,
Ext_ID => This.RI1R.EXID,
Ide => This.RI1R.IDE,
Rtr => This.RI1R.RTR,
Dlc => This.RDT1R.DLC,
Data => Message_Data (This.RDL1R.Arr) &
Message_Data (This.RDH1R.Arr));
end case;
end Read_Rx_Message;
---------------------
-- Nof_Msg_In_Fifo --
---------------------
function Nof_Msg_In_Fifo
(This : CAN_Controller;
Fifo : Fifo_Nr)
return UInt2
is
begin
case Fifo is
when FIFO_0 =>
return This.RF0R.FMP0;
when FIFO_1 =>
return This.RF1R.FMP1;
end case;
end Nof_Msg_In_Fifo;
---------------------
-- Receive_Message --
---------------------
procedure Receive_Message
(This : in out CAN_Controller;
Fifo : in Fifo_Nr;
Message : out CAN_Message;
Success : out Boolean;
Timeout : in Time_Span := Default_Timeout)
is
Deadline : constant Time := Clock + Timeout;
begin
loop
Success := Clock < Deadline;
exit when not Success or Nof_Msg_In_Fifo (This, Fifo) > 0;
end loop;
if Success then
Message := Read_Rx_Message (This, Fifo);
Release_Fifo (This, Fifo);
end if;
end Receive_Message;
--------------
-- Is_Empty --
--------------
function Is_Empty
(This : CAN_Controller;
Mailbox : Mailbox_Type)
return Boolean
is
begin
return This.TSR.TME.Arr (Mailbox_Type'Pos (Mailbox));
end Is_Empty;
-----------------------
-- Get_Empty_Mailbox --
-----------------------
procedure Get_Empty_Mailbox
(This : in out CAN_Controller;
Mailbox : out Mailbox_Type;
Empty_Found : out Boolean)
is
begin
for Mbx in Mailbox_Type'Range loop
Empty_Found := Is_Empty (This, Mbx);
Mailbox := Mbx;
exit when Empty_Found;
end loop;
end Get_Empty_Mailbox;
--------------------------
-- Transmission_Request --
--------------------------
procedure Transmission_Request
(This : in out CAN_Controller;
Mailbox : in Mailbox_Type)
is
begin
case Mailbox is
when Mailbox_0 =>
This.TI0R.TXRQ := True;
when Mailbox_1 =>
This.TI1R.TXRQ := True;
when Mailbox_2 =>
This.TI2R.TXRQ := True;
end case;
end Transmission_Request;
-----------------------
-- Request_Completed --
-----------------------
function Request_Completed
(This : CAN_Controller;
Mailbox : Mailbox_Type)
return Boolean
is
begin
case Mailbox is
when Mailbox_0 =>
return This.TSR.RQCP0;
when Mailbox_1 =>
return This.TSR.RQCP1;
when Mailbox_2 =>
return This.TSR.RQCP2;
end case;
end Request_Completed;
---------------------
-- Transmission_OK --
---------------------
function Transmission_OK
(This : CAN_Controller;
Mailbox : Mailbox_Type)
return Boolean
is
begin
case Mailbox is
when Mailbox_0 =>
return This.TSR.TXOK0;
when Mailbox_1 =>
return This.TSR.TXOK1;
when Mailbox_2 =>
return This.TSR.TXOK2;
end case;
end Transmission_OK;
----------------------------
-- Transmission_Completed --
----------------------------
function Transmission_Completed
(This : CAN_Controller;
Mailbox : Mailbox_Type)
return Boolean
is
begin
return Is_Empty (This, Mailbox) and then
Request_Completed (This, Mailbox);
end Transmission_Completed;
-----------------------------
-- Transmission_Successful --
-----------------------------
function Transmission_Successful
(This : CAN_Controller;
Mailbox : Mailbox_Type)
return Boolean
is
begin
return Transmission_Completed (This, Mailbox) and then
Transmission_OK (This, Mailbox);
end Transmission_Successful;
----------------------
-- Write_Tx_Message --
----------------------
procedure Write_Tx_Message
(This : in out CAN_Controller;
Message : in CAN_Message;
Mailbox : in Mailbox_Type)
is
begin
case Mailbox is
when Mailbox_0 =>
This.TI0R := (TXRQ => False,
RTR => Message.Rtr,
IDE => Message.Ide,
EXID => Message.Ext_ID,
STID => Message.Std_ID);
This.TDT0R.DLC := Message.Dlc;
This.TDL0R.Arr := TDL0R_DATA_Field_Array (Message.Data (0 .. 3));
This.TDH0R.Arr := TDH0R_DATA_Field_Array (Message.Data (4 .. 7));
when Mailbox_1 =>
This.TI1R := (TXRQ => False,
RTR => Message.Rtr,
IDE => Message.Ide,
EXID => Message.Ext_ID,
STID => Message.Std_ID);
This.TDT1R.DLC := Message.Dlc;
This.TDL1R.Arr := TDL1R_DATA_Field_Array (Message.Data (0 .. 3));
This.TDH1R.Arr := TDH1R_DATA_Field_Array (Message.Data (4 .. 7));
when Mailbox_2 =>
This.TI2R := (TXRQ => False,
RTR => Message.Rtr,
IDE => Message.Ide,
EXID => Message.Ext_ID,
STID => Message.Std_ID);
This.TDT2R.DLC := Message.Dlc;
This.TDL2R.Arr := TDL2R_DATA_Field_Array (Message.Data (0 .. 3));
This.TDH2R.Arr := TDH2R_DATA_Field_Array (Message.Data (4 .. 7));
end case;
end Write_Tx_Message;
----------------------
-- Transmit_Message --
----------------------
procedure Transmit_Message
(This : in out CAN_Controller;
Message : in CAN_Message;
Success : out Boolean;
Timeout : in Time_Span := Default_Timeout)
is
Mailbox : Mailbox_Type;
Deadline : constant Time := Clock + Timeout;
begin
Get_Empty_Mailbox (This, Mailbox, Success);
if Success then
Write_Tx_Message (This, Message, Mailbox);
Transmission_Request (This, Mailbox);
while not Transmission_Successful (This, Mailbox) and Success loop
Success := Clock < Deadline;
end loop;
end if;
end Transmit_Message;
----------------
-- Is_Overrun --
----------------
function Is_Overrun
(This : CAN_Controller;
Fifo : Fifo_Nr)
return Boolean
is
begin
case Fifo is
when FIFO_0 =>
return This.RF0R.FOVR0;
when FIFO_1 =>
return This.RF1R.FOVR1;
end case;
end Is_Overrun;
-------------
-- Is_Full --
-------------
function Is_Full
(This : CAN_Controller;
Fifo : Fifo_Nr)
return Boolean
is
begin
case Fifo is
when FIFO_0 =>
return This.RF0R.FULL0;
when FIFO_1 =>
return This.RF1R.FULL1;
end case;
end Is_Full;
-----------------------
-- Interrupt_Enabled --
-----------------------
function Interrupt_Enabled
(This : CAN_Controller;
Source : CAN_Interrupt)
return Boolean
is
begin
case Source is
when Transmit_Mailbox_Empty =>
return This.IER.TMEIE;
when FIFO_0_Message_Pending =>
return This.IER.FMPIE0;
when FIFO_1_Message_Pending =>
return This.IER.FMPIE1;
when FIFO_0_Full =>
return This.IER.FFIE0;
when FIFO_1_Full =>
return This.IER.FFIE1;
when FIFO_0_Overrun =>
return This.IER.FOVIE0;
when FIFO_1_Overrun =>
return This.IER.FOVIE1;
when Error =>
return This.IER.ERRIE;
when Last_Error_Code =>
return This.IER.LECIE;
when Bus_Off =>
return This.IER.BOFIE;
when Error_Passive =>
return This.IER.EPVIE;
when Error_Warning =>
return This.IER.EWGIE;
when Sleep_Acknowledge =>
return This.IER.SLKIE;
when Wakeup =>
return This.IER.WKUIE;
end case;
end Interrupt_Enabled;
-----------------------
-- Enable_Interrupts --
-----------------------
procedure Enable_Interrupts
(This : in out CAN_Controller;
Source : CAN_Interrupt)
is
begin
case Source is
when Transmit_Mailbox_Empty =>
This.IER.TMEIE := True;
when FIFO_0_Message_Pending =>
This.IER.FMPIE0 := True;
when FIFO_1_Message_Pending =>
This.IER.FMPIE1 := True;
when FIFO_0_Full =>
This.IER.FFIE0 := True;
when FIFO_1_Full =>
This.IER.FFIE1 := True;
when FIFO_0_Overrun =>
This.IER.FOVIE0 := True;
when FIFO_1_Overrun =>
This.IER.FOVIE1 := True;
when Error =>
This.IER.ERRIE := True;
when Last_Error_Code =>
This.IER.LECIE := True;
when Bus_Off =>
This.IER.BOFIE := True;
when Error_Passive =>
This.IER.EPVIE := True;
when Error_Warning =>
This.IER.EWGIE := True;
when Sleep_Acknowledge =>
This.IER.SLKIE := True;
when Wakeup =>
This.IER.WKUIE := True;
end case;
end Enable_Interrupts;
------------------------
-- Disable_Interrupts --
------------------------
procedure Disable_Interrupts
(This : in out CAN_Controller;
Source : CAN_Interrupt)
is
begin
case Source is
when Transmit_Mailbox_Empty =>
This.IER.TMEIE := False;
when FIFO_0_Message_Pending =>
This.IER.FMPIE0 := False;
when FIFO_1_Message_Pending =>
This.IER.FMPIE1 := False;
when FIFO_0_Full =>
This.IER.FFIE0 := False;
when FIFO_1_Full =>
This.IER.FFIE1 := False;
when FIFO_0_Overrun =>
This.IER.FOVIE0 := False;
when FIFO_1_Overrun =>
This.IER.FOVIE1 := False;
when Error =>
This.IER.ERRIE := False;
when Last_Error_Code =>
This.IER.LECIE := False;
when Bus_Off =>
This.IER.BOFIE := False;
when Error_Passive =>
This.IER.EPVIE := False;
when Error_Warning =>
This.IER.EWGIE := False;
when Sleep_Acknowledge =>
This.IER.SLKIE := False;
when Wakeup =>
This.IER.WKUIE := False;
end case;
end Disable_Interrupts;
end STM32.CAN;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash;
with Ada.Characters.Conversions;
with Ada.Containers.Hashed_Sets;
with Platform_Info;
with Unicode.Case_Folding.Simple;
with Ada_Lexical_Parser; use Ada_Lexical_Parser;
separate (Repositories)
procedure Validate_AURA_Spec
(Stream: not null access Ada.Streams.Root_Stream_Type'Class)
is
End_Error: exception renames Ada.IO_Exceptions.End_Error;
Source: Source_Buffer (Stream);
E: Lexical_Element;
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
package Identifier_Sets is new Ada.Containers.Hashed_Sets
(Element_Type => WWU.Unbounded_Wide_Wide_String,
Hash => WWU.Wide_Wide_Hash,
Equivalent_Elements => WWU."=",
"=" => WWU."=");
function To_WWS (Source: WWU.Unbounded_Wide_Wide_String)
return Wide_Wide_String
renames WWU.To_Wide_Wide_String;
function To_WWS (Item: in String) return Wide_Wide_String
renames Ada.Characters.Conversions.To_Wide_Wide_String;
function To_String (Item : in Wide_Wide_String;
Substitute: in Character := ' ')
return String
renames Ada.Characters.Conversions.To_String;
procedure Next_Element is
begin
loop
E := Next_Element (Source);
exit when E.Category /= Comment;
end loop;
end Next_Element;
function Category return Lexical_Category is (E.Category);
function Content return Wide_Wide_String is (To_WWS (E.Content));
begin
-- The AURA Spec is very specific and simple. We are strict about
-- the checking we do
Next_Element;
Assert (Check => Category = Reserved_Word
and then Content = "package",
Message => "AURA spec shall be a package spec without "
& "with clauses");
Next_Element;
Assert (Check => Category = Identifier
and then Content = "aura",
Message => "AURA package spec file does not have correct "
& "package name.");
Next_Element;
declare
No_Pure_Msg: constant String
:= "AURA package shall be declared Pure with an aspect_specification";
begin
Assert (Check => Category = Reserved_Word
and then Content = "with",
Message => No_Pure_Msg);
Next_Element;
Assert (Check => Category = Identifier
and then Content = "pure",
Message => No_Pure_Msg);
end;
Next_Element;
Assert (Check => Category = Reserved_Word
and then Content = "is",
Message => "Malformed package declaration");
-- The package shall contain a single enumeration type declaration
-- for Repository_Format
declare
Invalid_Declarations: constant String
:= "AURA package shall contain only the declaration for "
& "enumeration type Repository_Format";
procedure Assert (Check: in Boolean;
Message: in String := Invalid_Declarations)
renames Repositories.Assert;
begin
Next_Element;
Assert (Category = Reserved_Word and then Content = "type");
Next_Element;
Assert (Category = Identifier and then Content = "repository_format");
Next_Element;
Assert (Category = Reserved_Word and then Content = "is");
Next_Element;
Assert (Category = Delimiter and then Content = "(");
end;
-- Now we can extract all the enumeration literals
declare
Expected_Literals : Identifier_Sets.Set;
Encountered_Literals: Identifier_Sets.Set;
begin
-- load the expected literals from the internal literals of the type
for Format in Repository_Format loop
declare
Img: Wide_Wide_String
:= To_WWS (Repository_Format'Image (Format));
begin
for C of Img loop
C := Unicode.Case_Folding.Simple (C);
end loop;
Expected_Literals.Include
(WWU.To_Unbounded_Wide_Wide_String (Img));
end;
end loop;
-- Now we load the literals from the spec
loop
Next_Element;
case Category is
when Delimiter =>
if Content = ")" then
Assert (Check => Encountered_Literals.Length > 0,
Message => "Illegal enumeration");
exit;
else
Assert (Check => Content = ",",
Message => "Illegal enumeration");
end if;
when Identifier =>
begin
Encountered_Literals.Insert (E.Content);
exception
when Constraint_Error =>
raise Assertion_Error with
"Illegal enumeration: Duplicate enumeration literals";
end;
when Comment =>
null;
when others =>
raise Assertion_Error with "Illegal enumeration";
end case;
end loop;
Next_Element;
Assert (Check => Category = Delimiter
and then Content = ";",
Message => "Illegal enumeration");
-- Finally compare the sets.
declare
use UBS;
use Identifier_Sets;
Diff: Identifier_Sets.Set := Difference
(Encountered_Literals, Expected_Literals);
Unsupported_Formats: Unbounded_String
:= To_Unbounded_String ("Unsupported repository formats: ");
begin
if Difference (Encountered_Literals,
Expected_Literals ).Length > 0
then
Set_Unbounded_String
(Target => Unsupported_Formats,
Source => "Unsupported repository formats: ");
for Format of Diff loop
Append (Source => Unsupported_Formats,
New_Item => To_String (To_WWS (Format)));
end loop;
raise Assertion_Error with UBS.To_String (Unsupported_Formats);
end if;
end;
end;
-- Next we expect to find the platform infromation, in a particular order
declare
Have_Family, Have_Flavor, Have_Version, Have_Arch: Boolean := False;
function Have_All return Boolean is
(Have_Family and Have_Flavor and Have_Version and Have_Arch);
package Expected_Values is
use Ada.Characters.Conversions;
Family: constant Wide_Wide_String := To_Wide_Wide_String
(Platform_Info.Platform_Family);
Flavor: constant Wide_Wide_String := To_Wide_Wide_String
(Platform_Info.Platform_Flavor);
Version: constant Wide_Wide_String := To_Wide_Wide_String
(Platform_Info.Platform_Version);
Arch : constant Wide_Wide_String := To_Wide_Wide_String
(Platform_Info.Platform_Architecture);
end Expected_Values;
generic
Name : in Wide_Wide_String;
Expected_Value: in Wide_Wide_String;
procedure Verify_Value;
-- Verify that the pattern following Name is a constant
-- String declaration, with the correct value and style
procedure Verify_Value is
begin
Next_Element;
Assert (Check => Category = Delimiter
and then Content = ":",
Message => "expected "":"" following identifier """
& To_String (Name)
& """");
Next_Element;
Assert (Check => Category = Reserved_Word
and then Content = "constant",
Message => """" & To_String (Name)
& """ must be a constant");
Next_Element;
Assert (Check => Category = Identifier
and then Content = "string",
Message => """" & To_String (Name)
& """ must be a String");
Next_Element;
Assert (Check => Category = Delimiter
and then Content = ":=",
Message => "expected "":="" following ""String"" """
& To_String (Name)
& """");
Next_Element;
Assert (Check => Category = String_Literal,
Message => "Expected String literal");
Assert (Check => Content = Expected_Value,
Message => "Expected value for """
& To_String (Name) & """ is """
& To_String (Expected_Value) & """");
Next_Element;
Assert (Check => Category = Delimiter
and then Content = ";",
Message => "Expressions are not allowed");
end Verify_Value;
procedure Verify_Family is new Verify_Value
(Name => "platform_family",
Expected_Value => Expected_Values.Family);
procedure Verify_Flavor is new Verify_Value
(Name => "platform_flavor",
Expected_Value => Expected_Values.Flavor);
procedure Verify_Version is new Verify_Value
(Name => "platform_version",
Expected_Value => Expected_Values.Version);
procedure Verify_Arch is new Verify_Value
(Name => "platform_architecture",
Expected_Value => Expected_Values.Arch);
begin
while not Have_All loop
Next_Element;
Assert (Check => Category = Identifier,
Message => "Unexpected """
& To_String (Content)
& """ in AURA package");
if Content = "platform_family" then
Verify_Family;
Have_Family := True;
elsif Content = "platform_flavor" then
Verify_Flavor;
Have_Flavor := True;
elsif Content = "platform_version" then
Verify_Version;
Have_Version := True;
elsif Content = "platform_architecture" then
Verify_Arch;
Have_Arch := True;
else
raise Assertion_Error with
"Illegal identifier """
& To_String (Content)
& """ in AURA spec";
end if;
end loop;
end;
Next_Element;
Assert (Check => Category = Reserved_Word
and then Content = "end",
Message => "AURA package shall only contain the Repository_Format "
& "type declaration, and the Platform information constants.");
Next_Element;
if Category = Identifier then
Assert (Check => Content = "aura",
Message => "Package name mismatch - should be AURA");
Next_Element;
end if;
Assert (Check => Category = Delimiter
and then Content = ";",
Message => "Syntax error at end of package - expected "";"" "
& "following ""end""");
-- Looks good.
end Validate_AURA_Spec;
|
-------------------------------------------------------------------------------
-- Title : Blinky example for Cortex-M0
--
-- File : main.adb
-- Author : Vitor Finotti
-- Created on : 2019-04-24 19:46:32
-- Description :
--
--
--
-------------------------------------------------------------------------------
pragma Restrictions (No_Exceptions); -- avoid __gnat_last_chance_handler being used
package body Main is
procedure Run is
-- Period : constant Integer := 1000000; -- Synthesis period
Period : constant Integer := 200; -- Simulation period
type Period_Range is range 0 .. Period;
type Uint32 is mod 2**32;
Led_Toggle : constant := 16#f0f0f0f0#;
Counter : Integer := 0;
Dummy : Uint32 := 0;
begin
loop
Counter := 0;
for I in Period_Range loop
Counter := Counter + 1;
end loop;
Dummy := Led_Toggle;
Dummy := Dummy + 1; -- force toggle parameter to change
end loop;
end Run;
end Main;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.