content stringlengths 23 1.05M |
|---|
with neural.Privvy;
with fann_c.Binding;
with Interfaces.C;
with Fann_C.Pointers;
package body Neural.Set
is
use neural.Privvy,
fann_c.Binding,
Interfaces;
function to_Set (the_Patterns : in Patterns_view) return Set
is
the_Set : Set;
procedure fill_Fann (pattern_Id : in Interfaces.C.unsigned;
inputs_Count : in Interfaces.C.unsigned;
outputs_Count : in Interfaces.C.unsigned;
Inputs : in fann_c.Pointers.fann_type_Pointer;
Outputs : in fann_c.Pointers.fann_type_Pointer);
pragma Convention (C, fill_Fann);
procedure fill_Fann (pattern_Id : in Interfaces.C.unsigned;
inputs_Count : in Interfaces.C.unsigned;
outputs_Count : in Interfaces.C.unsigned;
Inputs : in fann_c.Pointers.fann_type_Pointer;
Outputs : in fann_c.Pointers.fann_type_Pointer)
is
use fann_c, fann_type_Pointers;
the_Pattern : Pattern renames the_Patterns (Integer (pattern_Id) + 1);
the_Inputs : fann_c.fann_Type_array (1 .. c.size_t (inputs_Count));
the_Outputs : fann_c.fann_Type_array (1 .. c.size_t (outputs_Count));
begin
-- set inputs
--
for Each in the_Inputs'range loop
the_Inputs (Each) := fann_Type (the_Pattern.Inputs (Integer (Each)));
-- put_Line (math.Image (math.Real (the_Inputs (Each))));
end loop;
copy_Array (the_Inputs (1)'Unchecked_Access,
Inputs.all'access,
c.ptrdiff_t (inputs_Count));
-- set outputs
--
for Each in the_Outputs'range loop
the_Outputs (Each) := fann_Type (the_Pattern.Outputs (Integer (Each)));
end loop;
copy_Array (the_Outputs (1)'Unchecked_Access,
Outputs.all'access,
c.ptrdiff_t (outputs_Count));
end fill_Fann;
begin
the_Set.Patterns := the_Patterns;
the_Set.Fann := create_train_from_callback (num_data => the_Patterns'Length,
num_input => the_Patterns (1).Inputs 'Length,
num_output => the_Patterns (1).Outputs'Length,
the_user_function => fill_Fann'unrestricted_access);
return the_Set;
end to_Set;
end Neural.Set;
|
-- 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 System;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with Libc.Stddef;
with Libc.Stdint;
with Pulse.Context;
with Pulse.Sample;
limited with Pulse.Channelmap;
with Pulse.Def;
limited with Pulse.Volume;
limited with Pulse.Format;
with Pulse.Proplist;
package Pulse.Stream with
Spark_Mode => Off is
type pa_stream is limited private;
type pa_stream_access is access all pa_stream;
type pa_stream_success_cb_t is access procedure
(arg1 : System.Address;
arg2 : int;
arg3 : System.Address);
pragma Convention
(C,
pa_stream_success_cb_t); -- /usr/include/pulse/stream.h:325
type pa_stream_request_cb_t is access procedure
(s : pa_stream_access;
nbytes : Libc.Stddef.size_t;
userdata : System.Address);
pragma Convention
(C,
pa_stream_request_cb_t); -- /usr/include/pulse/stream.h:328
type pa_stream_notify_cb_t is access procedure
(arg1 : System.Address;
arg2 : System.Address);
pragma Convention
(C,
pa_stream_notify_cb_t); -- /usr/include/pulse/stream.h:331
type pa_stream_event_cb_t is access procedure
(arg1 : System.Address;
arg2 : Interfaces.C.Strings.chars_ptr;
arg3 : System.Address;
arg4 : System.Address);
pragma Convention
(C,
pa_stream_event_cb_t); -- /usr/include/pulse/stream.h:339
function pa_stream_new
(c : Pulse.Context.pa_context_access;
name : Interfaces.C.Strings.chars_ptr;
ss : Pulse.Sample.pa_sample_spec;
map : access constant Pulse.Channelmap.pa_channel_map)
return pa_stream_access; -- /usr/include/pulse/stream.h:344
pragma Import (C, pa_stream_new, "pa_stream_new");
function pa_stream_new_with_proplist
(c : Pulse.Context.pa_context_access;
name : Interfaces.C.Strings.chars_ptr;
ss : Pulse.Sample.pa_sample_spec;
map : access constant Pulse.Channelmap.pa_channel_map;
p : pa_stream_access)
return System.Address; -- /usr/include/pulse/stream.h:353
pragma Import
(C,
pa_stream_new_with_proplist,
"pa_stream_new_with_proplist");
function pa_stream_new_extended
(c : Pulse.Context.pa_context_access;
name : Interfaces.C.Strings.chars_ptr;
formats : pa_stream_access;
n_formats : unsigned;
p : pa_stream_access)
return System.Address; -- /usr/include/pulse/stream.h:364
pragma Import (C, pa_stream_new_extended, "pa_stream_new_extended");
procedure pa_stream_unref
(s : pa_stream_access); -- /usr/include/pulse/stream.h:372
pragma Import (C, pa_stream_unref, "pa_stream_unref");
function pa_stream_ref
(s : pa_stream_access)
return System.Address; -- /usr/include/pulse/stream.h:375
pragma Import (C, pa_stream_ref, "pa_stream_ref");
function pa_stream_get_state
(p : pa_stream_access)
return Pulse.Def.pa_stream_state_t; -- /usr/include/pulse/stream.h:378
pragma Import (C, pa_stream_get_state, "pa_stream_get_state");
function pa_stream_get_context
(p : pa_stream_access)
return System.Address; -- /usr/include/pulse/stream.h:381
pragma Import (C, pa_stream_get_context, "pa_stream_get_context");
function pa_stream_get_index
(s : pa_stream_access)
return Libc.Stdint.uint32_t; -- /usr/include/pulse/stream.h:387
pragma Import (C, pa_stream_get_index, "pa_stream_get_index");
function pa_stream_get_device_index
(s : pa_stream_access)
return Libc.Stdint.uint32_t; -- /usr/include/pulse/stream.h:398
pragma Import (C, pa_stream_get_device_index, "pa_stream_get_device_index");
function pa_stream_get_device_name
(s : pa_stream_access)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/stream.h:409
pragma Import (C, pa_stream_get_device_name, "pa_stream_get_device_name");
function pa_stream_is_suspended
(s : pa_stream_access) return int; -- /usr/include/pulse/stream.h:415
pragma Import (C, pa_stream_is_suspended, "pa_stream_is_suspended");
function pa_stream_is_corked
(s : pa_stream_access) return int; -- /usr/include/pulse/stream.h:419
pragma Import (C, pa_stream_is_corked, "pa_stream_is_corked");
function pa_stream_connect_playback
(s : pa_stream_access;
dev : Interfaces.C.Strings.chars_ptr;
attr : Pulse.Def.pa_buffer_attr;
flags : Pulse.Def.pa_stream_flags_t;
volume : access constant Pulse.Volume.pa_cvolume;
sync_stream : System.Address)
return int; -- /usr/include/pulse/stream.h:439
pragma Import (C, pa_stream_connect_playback, "pa_stream_connect_playback");
function pa_stream_connect_record
(s : pa_stream_access;
dev : Interfaces.C.Strings.chars_ptr;
attr : Pulse.Def.pa_buffer_attr;
flags : Pulse.Def.pa_stream_flags_t)
return int; -- /usr/include/pulse/stream.h:448
pragma Import (C, pa_stream_connect_record, "pa_stream_connect_record");
function pa_stream_disconnect
(s : pa_stream_access) return int; -- /usr/include/pulse/stream.h:455
pragma Import (C, pa_stream_disconnect, "pa_stream_disconnect");
function pa_stream_begin_write
(p : pa_stream_access;
data : System.Address;
nbytes : access Libc.Stddef.size_t)
return int; -- /usr/include/pulse/stream.h:489
pragma Import (C, pa_stream_begin_write, "pa_stream_begin_write");
function pa_stream_cancel_write
(p : pa_stream_access) return int; -- /usr/include/pulse/stream.h:503
pragma Import (C, pa_stream_cancel_write, "pa_stream_cancel_write");
function pa_stream_write
(p : pa_stream_access;
data : System.Address;
nbytes : Libc.Stddef.size_t;
free_cb : Pulse.Def.pa_free_cb_t;
offset : Libc.Stdint.int64_t;
seek : Pulse.Def.pa_seek_mode_t)
return int; -- /usr/include/pulse/stream.h:528
pragma Import (C, pa_stream_write, "pa_stream_write");
function pa_stream_peek
(p : pa_stream_access;
data : System.Address;
nbytes : access Libc.Stddef.size_t)
return int; -- /usr/include/pulse/stream.h:552
pragma Import (C, pa_stream_peek, "pa_stream_peek");
function pa_stream_drop
(p : pa_stream_access) return int; -- /usr/include/pulse/stream.h:559
pragma Import (C, pa_stream_drop, "pa_stream_drop");
function pa_stream_writable_size
(p : pa_stream_access)
return Libc.Stddef.size_t; -- /usr/include/pulse/stream.h:562
pragma Import (C, pa_stream_writable_size, "pa_stream_writable_size");
function pa_stream_readable_size
(p : pa_stream_access)
return Libc.Stddef.size_t; -- /usr/include/pulse/stream.h:565
pragma Import (C, pa_stream_readable_size, "pa_stream_readable_size");
function pa_stream_drain
(s : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:571
pragma Import (C, pa_stream_drain, "pa_stream_drain");
function pa_stream_update_timing_info
(p : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:577
pragma Import
(C,
pa_stream_update_timing_info,
"pa_stream_update_timing_info");
procedure pa_stream_set_state_callback
(s : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:580
pragma Import
(C,
pa_stream_set_state_callback,
"pa_stream_set_state_callback");
procedure pa_stream_set_write_callback
(p : pa_stream_access;
cb : pa_stream_request_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:584
pragma Import
(C,
pa_stream_set_write_callback,
"pa_stream_set_write_callback");
procedure pa_stream_set_read_callback
(p : pa_stream_access;
cb : pa_stream_request_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:587
pragma Import
(C,
pa_stream_set_read_callback,
"pa_stream_set_read_callback");
procedure pa_stream_set_overflow_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:590
pragma Import
(C,
pa_stream_set_overflow_callback,
"pa_stream_set_overflow_callback");
function pa_stream_get_underflow_index
(p : pa_stream_access)
return Libc.Stdint.int64_t; -- /usr/include/pulse/stream.h:596
pragma Import
(C,
pa_stream_get_underflow_index,
"pa_stream_get_underflow_index");
procedure pa_stream_set_underflow_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:599
pragma Import
(C,
pa_stream_set_underflow_callback,
"pa_stream_set_underflow_callback");
procedure pa_stream_set_started_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:606
pragma Import
(C,
pa_stream_set_started_callback,
"pa_stream_set_started_callback");
procedure pa_stream_set_latency_update_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:611
pragma Import
(C,
pa_stream_set_latency_update_callback,
"pa_stream_set_latency_update_callback");
procedure pa_stream_set_moved_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:618
pragma Import
(C,
pa_stream_set_moved_callback,
"pa_stream_set_moved_callback");
procedure pa_stream_set_suspended_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:628
pragma Import
(C,
pa_stream_set_suspended_callback,
"pa_stream_set_suspended_callback");
procedure pa_stream_set_event_callback
(p : pa_stream_access;
cb : pa_stream_event_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:632
pragma Import
(C,
pa_stream_set_event_callback,
"pa_stream_set_event_callback");
procedure pa_stream_set_buffer_attr_callback
(p : pa_stream_access;
cb : pa_stream_notify_cb_t;
userdata : System.Address); -- /usr/include/pulse/stream.h:639
pragma Import
(C,
pa_stream_set_buffer_attr_callback,
"pa_stream_set_buffer_attr_callback");
function pa_stream_cork
(s : pa_stream_access;
b : int;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:651
pragma Import (C, pa_stream_cork, "pa_stream_cork");
function pa_stream_flush
(s : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:657
pragma Import (C, pa_stream_flush, "pa_stream_flush");
function pa_stream_prebuf
(s : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:661
pragma Import (C, pa_stream_prebuf, "pa_stream_prebuf");
function pa_stream_trigger
(s : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:666
pragma Import (C, pa_stream_trigger, "pa_stream_trigger");
function pa_stream_set_name
(s : pa_stream_access;
name : Interfaces.C.Strings.chars_ptr;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:669
pragma Import (C, pa_stream_set_name, "pa_stream_set_name");
function pa_stream_get_time
(s : pa_stream_access;
r_usec : access Pulse.Sample.pa_usec_t)
return int; -- /usr/include/pulse/stream.h:702
pragma Import (C, pa_stream_get_time, "pa_stream_get_time");
function pa_stream_get_latency
(s : pa_stream_access;
r_usec : access Pulse.Sample.pa_usec_t;
negative : access int) return int; -- /usr/include/pulse/stream.h:716
pragma Import (C, pa_stream_get_latency, "pa_stream_get_latency");
function pa_stream_get_timing_info
(s : pa_stream_access)
return access constant Pulse.Def
.pa_timing_info; -- /usr/include/pulse/stream.h:732
pragma Import (C, pa_stream_get_timing_info, "pa_stream_get_timing_info");
function pa_stream_get_sample_spec
(s : pa_stream_access)
return access constant Pulse.Sample
.pa_sample_spec; -- /usr/include/pulse/stream.h:735
pragma Import (C, pa_stream_get_sample_spec, "pa_stream_get_sample_spec");
function pa_stream_get_channel_map
(s : pa_stream_access)
return access constant Pulse.Channelmap
.pa_channel_map; -- /usr/include/pulse/stream.h:738
pragma Import (C, pa_stream_get_channel_map, "pa_stream_get_channel_map");
function pa_stream_get_format_info
(s : pa_stream_access)
return access constant Pulse.Format
.pa_format_info; -- /usr/include/pulse/stream.h:741
pragma Import (C, pa_stream_get_format_info, "pa_stream_get_format_info");
function pa_stream_get_buffer_attr
(s : pa_stream_access)
return access constant Pulse.Def
.pa_buffer_attr; -- /usr/include/pulse/stream.h:751
pragma Import (C, pa_stream_get_buffer_attr, "pa_stream_get_buffer_attr");
function pa_stream_set_buffer_attr
(s : pa_stream_access;
attr : Pulse.Def.pa_buffer_attr;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:761
pragma Import (C, pa_stream_set_buffer_attr, "pa_stream_set_buffer_attr");
function pa_stream_update_sample_rate
(s : pa_stream_access;
rate : Libc.Stdint.uint32_t;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:768
pragma Import
(C,
pa_stream_update_sample_rate,
"pa_stream_update_sample_rate");
function pa_stream_proplist_update
(s : pa_stream_access;
mode : Pulse.Proplist.pa_update_mode_t;
p : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:776
pragma Import (C, pa_stream_proplist_update, "pa_stream_proplist_update");
function pa_stream_proplist_remove
(s : pa_stream_access;
keys : pa_stream_access;
cb : pa_stream_success_cb_t;
userdata : System.Address)
return System.Address; -- /usr/include/pulse/stream.h:780
pragma Import (C, pa_stream_proplist_remove, "pa_stream_proplist_remove");
function pa_stream_set_monitor_stream
(s : pa_stream_access;
sink_input_idx : Libc.Stdint.uint32_t)
return int; -- /usr/include/pulse/stream.h:786
pragma Import
(C,
pa_stream_set_monitor_stream,
"pa_stream_set_monitor_stream");
function pa_stream_get_monitor_stream
(s : pa_stream_access)
return Libc.Stdint.uint32_t; -- /usr/include/pulse/stream.h:791
pragma Import
(C,
pa_stream_get_monitor_stream,
"pa_stream_get_monitor_stream");
private
type pa_stream is limited record
null;
end record;
end Pulse.Stream;
|
-----------------------------------------------------------------------
-- asf-applications-views-tests - Unit tests for ASF.Applications.Views
-- Copyright (C) 2009, 2010, 2011, 2012, 2014, 2015, 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 ASF.Applications.Main;
with ASF.Applications.Tests;
with ASF.Requests.Mockup;
with ASF.Responses.Mockup;
with ASF.Servlets.Faces;
with ASF.Converters.Dates;
with ASF.Server;
with Ada.Directories;
with Ada.Unchecked_Deallocation;
with Util.Files;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Measures;
package body ASF.Applications.Views.Tests is
use Ada.Strings.Unbounded;
overriding
procedure Set_Up (T : in out Test) is
begin
null;
end Set_Up;
-- Set up performed before each test case
-- ------------------------------
-- Test loading of facelet file
-- ------------------------------
procedure Test_Load_Facelet (T : in out Test) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => ASF.Converters.Dates.Date_Converter'Class,
Name => ASF.Converters.Dates.Date_Converter_Access);
App : aliased Applications.Main.Application;
View_Name : constant String := To_String (T.File);
Result_File : constant String := To_String (T.Result);
Conf : Applications.Config;
App_Factory : Applications.Main.Application_Factory;
Dir : constant String := "regtests/files";
Path : constant String := Util.Tests.Get_Path (Dir);
Faces : aliased ASF.Servlets.Faces.Faces_Servlet;
List : Util.Beans.Basic.Readonly_Bean_Access;
List_Bean : Util.Beans.Objects.Object;
Form : Util.Beans.Basic.Readonly_Bean_Access;
Form_Bean : Util.Beans.Objects.Object;
C : ASF.Converters.Dates.Date_Converter_Access;
Container : ASF.Server.Container;
begin
List := Applications.Tests.Create_Form_List;
List_Bean := Util.Beans.Objects.To_Object (List);
Form := Applications.Tests.Create_Form_Bean;
Form_Bean := Util.Beans.Objects.To_Object (Form);
Conf.Load_Properties ("regtests/view.properties");
Conf.Set ("view.dir", Path);
App.Initialize (Conf, App_Factory);
App.Register_Application ("/");
App.Add_Servlet ("faces", Faces'Unchecked_Access);
App.Add_Mapping ("*.xhtml", "faces");
C := ASF.Converters.Dates.Create_Date_Converter (Date => ASF.Converters.Dates.DEFAULT,
Time => ASF.Converters.Dates.DEFAULT,
Format => ASF.Converters.Dates.TIME,
Locale => "en",
Pattern => "");
App.Add_Converter ("date-default-converter", C.all'Access);
App.Set_Global ("function", "Test_Load_Facelet");
App.Set_Global ("date", "2011-12-03 03:04:05.23");
Container.Register_Application ("/asfunit", App'Unchecked_Access);
Container.Start;
for I in 1 .. 2 loop
declare
S : Util.Measures.Stamp;
Req : ASF.Requests.Mockup.Request;
Reply : aliased ASF.Responses.Mockup.Response;
Content : Unbounded_String;
begin
Req.Set_Method ("GET");
Req.Set_Request_URI ("/asfunit/" & View_Name);
Req.Set_Parameter ("file-name", To_String (T.Name));
Req.Set_Header ("file", To_String (T.Name));
Req.Set_Attribute ("list", List_Bean);
Req.Set_Attribute ("form", Form_Bean);
Container.Service (Req, Reply);
Util.Measures.Report (S, "Pass" & Integer'Image (I) & ": Render view "
& View_Name);
Reply.Read_Content (Content);
Util.Files.Write_File (Result_File, Content);
Util.Tests.Assert_Equal_Files (T => T,
Expect => To_String (T.Expect),
Test => Result_File,
Message => "Restore and render view");
end;
end loop;
Free (C);
end Test_Load_Facelet;
-- ------------------------------
-- Test case name
-- ------------------------------
overriding
function Name (T : Test) return Util.Tests.Message_String is
begin
return Util.Tests.Format ("Test " & To_String (T.Name));
end Name;
-- ------------------------------
-- Perform the test.
-- ------------------------------
overriding
procedure Run_Test (T : in out Test) is
begin
T.Test_Load_Facelet;
end Run_Test;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
use Ada.Directories;
Result_Dir : constant String := "regtests/result/views";
Dir : constant String := "regtests/files/views";
Expect_Dir : constant String := "regtests/expect/views";
Path : constant String := Util.Tests.Get_Path (Dir);
Expect_Path : constant String := Util.Tests.Get_Path (Expect_Dir);
Result_Path : constant String := Util.Tests.Get_Test_Path (Result_Dir);
Search : Search_Type;
Filter : constant Filter_Type := (others => True);
Ent : Directory_Entry_Type;
begin
if Kind (Path) /= Directory then
Ada.Text_IO.Put_Line ("Cannot read test directory: " & Path);
end if;
Start_Search (Search, Directory => Path, Pattern => "*.xhtml", Filter => Filter);
while More_Entries (Search) loop
Get_Next_Entry (Search, Ent);
declare
Simple : constant String := Simple_Name (Ent);
Tst : Test_Case_Access;
begin
if Simple /= "." and then Simple /= ".."
and then Simple /= ".svn"
then
Tst := new Test;
Tst.Name := To_Unbounded_String (Dir & "/" & Simple);
Tst.File := To_Unbounded_String ("views/" & Simple);
Tst.Expect := To_Unbounded_String (Expect_Path & "/" & Simple);
Tst.Result := To_Unbounded_String (Result_Path & "/" & Simple);
Suite.Add_Test (Tst.all'Access);
end if;
end;
end loop;
end Add_Tests;
end ASF.Applications.Views.Tests;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
begin
-- Guide: http://archive.adaic.com/standards/83lrm/html/lrm-11-01.html
declare
PP : Positive;
P2 : Positive;
begin
P2 := 5;
PP := 3 - P2; -- intentionally violate Positive range constraint
exception
when Constraint_Error =>
Put_Line("HANDLED: violate range constraint gives Constraint_Error");
end;
declare
SS : String(1..4);
PP : Positive;
begin
PP := 5;
SS(PP) := 'X'; -- intentionally violate SS's index constraint
exception
when Constraint_Error =>
Put_Line("HANDLED: violate index constraint gives Constraint_Error");
end;
declare
type Liquid is (None, Water);
type Glass (Contents : Liquid) is
record
Weight : Positive;
case Contents is
when Water =>
Ounces : Positive;
when None =>
null;
end case;
end record;
GG : Glass(None);
begin
GG.Ounces := 5; -- intentionally access variant record component that
-- doesn't exist for GG
exception
when Constraint_Error =>
Put_Line("HANDLED: violate variant record component existance gives"
& " Constraint_Error");
end;
end Main;
|
with Obj; use Obj;
procedure Tester is
A, B, C : Obj_T;
begin
A := New_Obj( 1 );
B := New_Obj( 2 );
C := New_Obj( 3 );
A := C;
end Tester;
|
--------------------------------------------------------------------------
-- Arbitrary Precision Math Library: Constants
-- Joe Wingbermuehle 20020320 <> 20020327
--------------------------------------------------------------------------
package Arbitrary.Const is
function Pi(precision : integer) return Arbitrary_Type;
function Golden_Ratio(precision : integer) return Arbitrary_Type;
end Arbitrary.Const;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- U I N T P --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Support for universal integer arithmetic
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file sinfo.h
with Alloc;
with Table;
with Types; use Types;
package Uintp is
-------------------------------------------------
-- Basic Types and Constants for Uintp Package --
-------------------------------------------------
type Uint is private;
-- The basic universal integer type
No_Uint : constant Uint;
-- A constant value indicating a missing or unset Uint value
Uint_0 : constant Uint;
Uint_1 : constant Uint;
Uint_2 : constant Uint;
Uint_3 : constant Uint;
Uint_4 : constant Uint;
Uint_5 : constant Uint;
Uint_6 : constant Uint;
Uint_7 : constant Uint;
Uint_8 : constant Uint;
Uint_9 : constant Uint;
Uint_10 : constant Uint;
Uint_12 : constant Uint;
Uint_15 : constant Uint;
Uint_16 : constant Uint;
Uint_24 : constant Uint;
Uint_32 : constant Uint;
Uint_63 : constant Uint;
Uint_64 : constant Uint;
Uint_128 : constant Uint;
Uint_Minus_1 : constant Uint;
Uint_Minus_2 : constant Uint;
Uint_Minus_3 : constant Uint;
Uint_Minus_4 : constant Uint;
Uint_Minus_5 : constant Uint;
Uint_Minus_6 : constant Uint;
Uint_Minus_7 : constant Uint;
Uint_Minus_8 : constant Uint;
Uint_Minus_9 : constant Uint;
Uint_Minus_12 : constant Uint;
Uint_Minus_128 : constant Uint;
-----------------
-- Subprograms --
-----------------
procedure Initialize;
-- Initialize Uint tables. Note that Initialize must not be called if
-- Tree_Read is used. Note also that there is no lock routine in this
-- unit, these are among the few tables that can be expanded during
-- gigi processing.
procedure Tree_Read;
-- Initializes internal tables from current tree file using Tree_Read.
-- Note that Initialize should not be called if Tree_Read is used.
-- Tree_Read includes all necessary initialization.
procedure Tree_Write;
-- Writes out internal tables to current tree file using Tree_Write.
function UI_Abs (Right : Uint) return Uint;
pragma Inline (UI_Abs);
-- Returns abs function of universal integer.
function UI_Add (Left : Uint; Right : Uint) return Uint;
function UI_Add (Left : Int; Right : Uint) return Uint;
function UI_Add (Left : Uint; Right : Int) return Uint;
-- Returns sum of two integer values.
function UI_Decimal_Digits_Hi (U : Uint) return Nat;
-- Returns an estimate of the number of decimal digits required to
-- represent the absolute value of U. This estimate is correct or high,
-- i.e. it never returns a value that is too low. The accuracy of the
-- estimate affects only the effectiveness of comparison optimizations
-- in Urealp.
function UI_Decimal_Digits_Lo (U : Uint) return Nat;
-- Returns an estimate of the number of decimal digits required to
-- represent the absolute value of U. This estimate is correct or low,
-- i.e. it never returns a value that is too high. The accuracy of the
-- estimate affects only the effectiveness of comparison optimizations
-- in Urealp.
function UI_Div (Left : Uint; Right : Uint) return Uint;
function UI_Div (Left : Int; Right : Uint) return Uint;
function UI_Div (Left : Uint; Right : Int) return Uint;
-- Returns quotient of two integer values. Fatal error if Right = 0
function UI_Eq (Left : Uint; Right : Uint) return Boolean;
function UI_Eq (Left : Int; Right : Uint) return Boolean;
function UI_Eq (Left : Uint; Right : Int) return Boolean;
pragma Inline (UI_Eq);
-- Compares integer values for equality.
function UI_Expon (Left : Uint; Right : Uint) return Uint;
function UI_Expon (Left : Int; Right : Uint) return Uint;
function UI_Expon (Left : Uint; Right : Int) return Uint;
function UI_Expon (Left : Int; Right : Int) return Uint;
-- Returns result of exponentiating two integer values
-- Fatal error if Right is negative.
function UI_GCD (Uin, Vin : Uint) return Uint;
-- Computes GCD of input values. Assumes Uin >= Vin >= 0.
function UI_Ge (Left : Uint; Right : Uint) return Boolean;
function UI_Ge (Left : Int; Right : Uint) return Boolean;
function UI_Ge (Left : Uint; Right : Int) return Boolean;
pragma Inline (UI_Ge);
-- Compares integer values for greater than or equal.
function UI_Gt (Left : Uint; Right : Uint) return Boolean;
function UI_Gt (Left : Int; Right : Uint) return Boolean;
function UI_Gt (Left : Uint; Right : Int) return Boolean;
pragma Inline (UI_Gt);
-- Compares integer values for greater than.
function UI_Is_In_Int_Range (Input : Uint) return Boolean;
pragma Inline (UI_Is_In_Int_Range);
-- Determines if universal integer is in Int range.
function UI_Le (Left : Uint; Right : Uint) return Boolean;
function UI_Le (Left : Int; Right : Uint) return Boolean;
function UI_Le (Left : Uint; Right : Int) return Boolean;
pragma Inline (UI_Le);
-- Compares integer values for less than or equal.
function UI_Lt (Left : Uint; Right : Uint) return Boolean;
function UI_Lt (Left : Int; Right : Uint) return Boolean;
function UI_Lt (Left : Uint; Right : Int) return Boolean;
-- Compares integer values for less than.
function UI_Max (Left : Uint; Right : Uint) return Uint;
function UI_Max (Left : Int; Right : Uint) return Uint;
function UI_Max (Left : Uint; Right : Int) return Uint;
-- Returns maximum of two integer values
function UI_Min (Left : Uint; Right : Uint) return Uint;
function UI_Min (Left : Int; Right : Uint) return Uint;
function UI_Min (Left : Uint; Right : Int) return Uint;
-- Returns minimum of two integer values.
function UI_Mod (Left : Uint; Right : Uint) return Uint;
function UI_Mod (Left : Int; Right : Uint) return Uint;
function UI_Mod (Left : Uint; Right : Int) return Uint;
pragma Inline (UI_Mod);
-- Returns mod function of two integer values.
function UI_Mul (Left : Uint; Right : Uint) return Uint;
function UI_Mul (Left : Int; Right : Uint) return Uint;
function UI_Mul (Left : Uint; Right : Int) return Uint;
-- Returns product of two integer values
function UI_Ne (Left : Uint; Right : Uint) return Boolean;
function UI_Ne (Left : Int; Right : Uint) return Boolean;
function UI_Ne (Left : Uint; Right : Int) return Boolean;
pragma Inline (UI_Ne);
-- Compares integer values for inequality.
function UI_Negate (Right : Uint) return Uint;
pragma Inline (UI_Negate);
-- Returns negative of universal integer.
function UI_Rem (Left : Uint; Right : Uint) return Uint;
function UI_Rem (Left : Int; Right : Uint) return Uint;
function UI_Rem (Left : Uint; Right : Int) return Uint;
-- Returns rem of two integer values.
function UI_Sub (Left : Uint; Right : Uint) return Uint;
function UI_Sub (Left : Int; Right : Uint) return Uint;
function UI_Sub (Left : Uint; Right : Int) return Uint;
pragma Inline (UI_Sub);
-- Returns difference of two integer values
function UI_From_Dint (Input : Dint) return Uint;
-- Converts Dint value to universal integer form.
function UI_From_Int (Input : Int) return Uint;
-- Converts Int value to universal integer form.
function UI_To_Int (Input : Uint) return Int;
-- Converts universal integer value to Int. Fatal error
-- if value is not in appropriate range.
function Num_Bits (Input : Uint) return Nat;
-- Approximate number of binary bits in given universal integer.
-- This function is used for capacity checks, and it can be one
-- bit off without affecting its usage.
---------------------
-- Output Routines --
---------------------
type UI_Format is (Hex, Decimal, Auto);
-- Used to determine whether UI_Image/UI_Write output is in hexadecimal
-- or decimal format. Auto, the default setting, lets the routine make
-- a decision based on the value.
UI_Image_Max : constant := 32;
UI_Image_Buffer : String (1 .. UI_Image_Max);
UI_Image_Length : Natural;
-- Buffer used for UI_Image as described below
procedure UI_Image (Input : Uint; Format : UI_Format := Auto);
-- Places a representation of Uint, consisting of a possible minus sign,
-- followed by the value in UI_Image_Buffer. The form of the value is an
-- integer literal in either decimal (no base) or hexadecimal (base 16)
-- format. If Hex is True on entry, then hex mode is forced, otherwise
-- UI_Image makes a guess at which output format is more convenient. The
-- value must fit in UI_Image_Buffer. If necessary, the result is an
-- approximation of the proper value, using an exponential format. The
-- image of No_Uint is output as a single question mark.
procedure UI_Write (Input : Uint; Format : UI_Format := Auto);
-- Writes a representation of Uint, consisting of a possible minus sign,
-- followed by the value to the output file. The form of the value is an
-- integer literal in either decimal (no base) or hexadecimal (base 16)
-- format as appropriate. UI_Format shows which format to use. Auto,
-- the default, asks UI_Write to make a guess at which output format
-- will be more convenient to read.
procedure pid (Input : Uint);
-- Writes representation of Uint in decimal with a terminating line
-- return. This is intended for use from the debugger.
procedure pih (Input : Uint);
-- Writes representation of Uint in hex with a terminating line return.
-- This is intended for use from the debugger.
------------------------
-- Operator Renamings --
------------------------
function "+" (Left : Uint; Right : Uint) return Uint renames UI_Add;
function "+" (Left : Int; Right : Uint) return Uint renames UI_Add;
function "+" (Left : Uint; Right : Int) return Uint renames UI_Add;
function "/" (Left : Uint; Right : Uint) return Uint renames UI_Div;
function "/" (Left : Int; Right : Uint) return Uint renames UI_Div;
function "/" (Left : Uint; Right : Int) return Uint renames UI_Div;
function "*" (Left : Uint; Right : Uint) return Uint renames UI_Mul;
function "*" (Left : Int; Right : Uint) return Uint renames UI_Mul;
function "*" (Left : Uint; Right : Int) return Uint renames UI_Mul;
function "-" (Left : Uint; Right : Uint) return Uint renames UI_Sub;
function "-" (Left : Int; Right : Uint) return Uint renames UI_Sub;
function "-" (Left : Uint; Right : Int) return Uint renames UI_Sub;
function "**" (Left : Uint; Right : Uint) return Uint renames UI_Expon;
function "**" (Left : Uint; Right : Int) return Uint renames UI_Expon;
function "**" (Left : Int; Right : Uint) return Uint renames UI_Expon;
function "**" (Left : Int; Right : Int) return Uint renames UI_Expon;
function "abs" (Real : Uint) return Uint renames UI_Abs;
function "mod" (Left : Uint; Right : Uint) return Uint renames UI_Mod;
function "mod" (Left : Int; Right : Uint) return Uint renames UI_Mod;
function "mod" (Left : Uint; Right : Int) return Uint renames UI_Mod;
function "rem" (Left : Uint; Right : Uint) return Uint renames UI_Rem;
function "rem" (Left : Int; Right : Uint) return Uint renames UI_Rem;
function "rem" (Left : Uint; Right : Int) return Uint renames UI_Rem;
function "-" (Real : Uint) return Uint renames UI_Negate;
function "=" (Left : Uint; Right : Uint) return Boolean renames UI_Eq;
function "=" (Left : Int; Right : Uint) return Boolean renames UI_Eq;
function "=" (Left : Uint; Right : Int) return Boolean renames UI_Eq;
function ">=" (Left : Uint; Right : Uint) return Boolean renames UI_Ge;
function ">=" (Left : Int; Right : Uint) return Boolean renames UI_Ge;
function ">=" (Left : Uint; Right : Int) return Boolean renames UI_Ge;
function ">" (Left : Uint; Right : Uint) return Boolean renames UI_Gt;
function ">" (Left : Int; Right : Uint) return Boolean renames UI_Gt;
function ">" (Left : Uint; Right : Int) return Boolean renames UI_Gt;
function "<=" (Left : Uint; Right : Uint) return Boolean renames UI_Le;
function "<=" (Left : Int; Right : Uint) return Boolean renames UI_Le;
function "<=" (Left : Uint; Right : Int) return Boolean renames UI_Le;
function "<" (Left : Uint; Right : Uint) return Boolean renames UI_Lt;
function "<" (Left : Int; Right : Uint) return Boolean renames UI_Lt;
function "<" (Left : Uint; Right : Int) return Boolean renames UI_Lt;
-----------------------------
-- Mark/Release Processing --
-----------------------------
-- The space used by Uint data is not automatically reclaimed. However,
-- a mark-release regime is implemented which allows storage to be
-- released back to a previously noted mark. This is used for example
-- when doing comparisons, where only intermediate results get stored
-- that do not need to be saved for future use.
type Save_Mark is private;
function Mark return Save_Mark;
-- Note mark point for future release
procedure Release (M : Save_Mark);
-- Release storage allocated since mark was noted
procedure Release_And_Save (M : Save_Mark; UI : in out Uint);
-- Like Release, except that the given Uint value (which is typically
-- among the data being released) is recopied after the release, so
-- that it is the most recent item, and UI is updated to point to
-- its copied location.
procedure Release_And_Save (M : Save_Mark; UI1, UI2 : in out Uint);
-- Like Release, except that the given Uint values (which are typically
-- among the data being released) are recopied after the release, so
-- that they are the most recent items, and UI1 and UI2 are updated if
-- necessary to point to the copied locations. This routine is careful
-- to do things in the right order, so that the values do not clobber
-- one another.
-----------------------------------
-- Representation of Uint Values --
-----------------------------------
private
type Uint is new Int range Uint_Low_Bound .. Uint_High_Bound;
for Uint'Size use 32;
No_Uint : constant Uint := Uint (Uint_Low_Bound);
-- Uint values are represented as multiple precision integers stored in
-- a multi-digit format using Base as the base. This value is chosen so
-- that the product Base*Base is within the range of allowed Int values.
-- Base is defined to allow efficient execution of the primitive
-- operations (a0, b0, c0) defined in the section "The Classical
-- Algorithms" (sec. 4.3.1) of Donald Knuth's "The Art of Computer
-- Programming", Vol. 2. These algorithms are used in this package.
Base_Bits : constant := 15;
-- Number of bits in base value
Base : constant Int := 2 ** Base_Bits;
-- Values in the range -(Base+1) .. maxdirect are encoded directly as
-- Uint values by adding a bias value. The value of maxdirect is chosen
-- so that a directly represented number always fits in two digits when
-- represented in base format.
Min_Direct : constant Int := -(Base - 1);
Max_Direct : constant Int := (Base - 1) * (Base - 1);
-- The following values define the bias used to store Uint values which
-- are in this range, as well as the biased values for the first and
-- last values in this range. We use a new derived type for these
-- constants to avoid accidental use of Uint arithmetic on these
-- values, which is never correct.
type Ctrl is range Int'First .. Int'Last;
Uint_Direct_Bias : constant Ctrl := Ctrl (Uint_Low_Bound) + Ctrl (Base);
Uint_Direct_First : constant Ctrl := Uint_Direct_Bias + Ctrl (Min_Direct);
Uint_Direct_Last : constant Ctrl := Uint_Direct_Bias + Ctrl (Max_Direct);
Uint_0 : constant Uint := Uint (Uint_Direct_Bias);
Uint_1 : constant Uint := Uint (Uint_Direct_Bias + 1);
Uint_2 : constant Uint := Uint (Uint_Direct_Bias + 2);
Uint_3 : constant Uint := Uint (Uint_Direct_Bias + 3);
Uint_4 : constant Uint := Uint (Uint_Direct_Bias + 4);
Uint_5 : constant Uint := Uint (Uint_Direct_Bias + 5);
Uint_6 : constant Uint := Uint (Uint_Direct_Bias + 6);
Uint_7 : constant Uint := Uint (Uint_Direct_Bias + 7);
Uint_8 : constant Uint := Uint (Uint_Direct_Bias + 8);
Uint_9 : constant Uint := Uint (Uint_Direct_Bias + 9);
Uint_10 : constant Uint := Uint (Uint_Direct_Bias + 10);
Uint_12 : constant Uint := Uint (Uint_Direct_Bias + 12);
Uint_15 : constant Uint := Uint (Uint_Direct_Bias + 15);
Uint_16 : constant Uint := Uint (Uint_Direct_Bias + 16);
Uint_24 : constant Uint := Uint (Uint_Direct_Bias + 24);
Uint_32 : constant Uint := Uint (Uint_Direct_Bias + 32);
Uint_63 : constant Uint := Uint (Uint_Direct_Bias + 63);
Uint_64 : constant Uint := Uint (Uint_Direct_Bias + 64);
Uint_128 : constant Uint := Uint (Uint_Direct_Bias + 128);
Uint_Minus_1 : constant Uint := Uint (Uint_Direct_Bias - 1);
Uint_Minus_2 : constant Uint := Uint (Uint_Direct_Bias - 2);
Uint_Minus_3 : constant Uint := Uint (Uint_Direct_Bias - 3);
Uint_Minus_4 : constant Uint := Uint (Uint_Direct_Bias - 4);
Uint_Minus_5 : constant Uint := Uint (Uint_Direct_Bias - 5);
Uint_Minus_6 : constant Uint := Uint (Uint_Direct_Bias - 6);
Uint_Minus_7 : constant Uint := Uint (Uint_Direct_Bias - 7);
Uint_Minus_8 : constant Uint := Uint (Uint_Direct_Bias - 8);
Uint_Minus_9 : constant Uint := Uint (Uint_Direct_Bias - 9);
Uint_Minus_12 : constant Uint := Uint (Uint_Direct_Bias - 12);
Uint_Minus_128 : constant Uint := Uint (Uint_Direct_Bias - 128);
type Save_Mark is record
Save_Uint : Uint;
Save_Udigit : Int;
end record;
-- Values outside the range that is represented directly are stored
-- using two tables. The secondary table Udigits contains sequences of
-- Int values consisting of the digits of the number in a radix Base
-- system. The digits are stored from most significant to least
-- significant with the first digit only carrying the sign.
-- There is one entry in the primary Uints table for each distinct Uint
-- value. This table entry contains the length (number of digits) and
-- a starting offset of the value in the Udigits table.
Uint_First_Entry : constant Uint := Uint (Uint_Table_Start);
-- Some subprograms defined in this package manipulate the Udigits
-- table directly, while for others it is more convenient to work with
-- locally defined arrays of the digits of the Universal Integers.
-- The type UI_Vector is defined for this purpose and some internal
-- subprograms used for converting from one to the other are defined.
type UI_Vector is array (Pos range <>) of Int;
-- Vector containing the integer values of a Uint value
-- Note: An earlier version of this package used pointers of arrays
-- of Ints (dynamically allocated) for the Uint type. The change
-- leads to a few less natural idioms used throughout this code, but
-- eliminates all uses of the heap except for the table package itself.
-- For example, Uint parameters are often converted to UI_Vectors for
-- internal manipulation. This is done by creating the local UI_Vector
-- using the function N_Digits on the Uint to find the size needed for
-- the vector, and then calling Init_Operand to copy the values out
-- of the table into the vector.
type Uint_Entry is record
Length : Pos;
-- Length of entry in Udigits table in digits (i.e. in words)
Loc : Int;
-- Starting location in Udigits table of this Uint value
end record;
package Uints is new Table.Table (
Table_Component_Type => Uint_Entry,
Table_Index_Type => Uint,
Table_Low_Bound => Uint_First_Entry,
Table_Initial => Alloc.Uints_Initial,
Table_Increment => Alloc.Uints_Increment,
Table_Name => "Uints");
package Udigits is new Table.Table (
Table_Component_Type => Int,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => Alloc.Udigits_Initial,
Table_Increment => Alloc.Udigits_Increment,
Table_Name => "Udigits");
-- Note: the reason these tables are defined here in the private part of
-- the spec, rather than in the body, is that they are refrerenced
-- directly by gigi.
end Uintp;
|
generic
type child_type is limited private;
type child_access_type is access child_type;
package agar.gui.widget.fixed is
use type c.unsigned;
type flags_t is new c.unsigned;
FIXED_HFILL : constant flags_t := 16#01#;
FIXED_VFILL : constant flags_t := 16#02#;
FIXED_NO_UPDATE : constant flags_t := 16#04#;
FIXED_FILLBG : constant flags_t := 16#08#;
FIXED_BOX : constant flags_t := 16#10#;
FIXED_INVBOX : constant flags_t := 16#20#;
FIXED_FRAME : constant flags_t := 16#40#;
FIXED_EXPAND : constant flags_t := FIXED_HFILL or FIXED_VFILL;
type fixed_t is record
widget : aliased widget_t;
flags : flags_t;
width_pre : c.int;
height_pre : c.int;
end record;
type fixed_access_t is access all fixed_t;
pragma convention (c, fixed_t);
pragma convention (c, fixed_access_t);
-- name uniformity
subtype child_t is child_type;
subtype child_access_t is child_access_type;
-- API
procedure put
(fixed : fixed_access_t;
child : child_access_t;
x : natural;
y : natural);
pragma inline (put);
procedure delete
(fixed : fixed_access_t;
child : child_access_t);
pragma import (c, delete, "AG_FixedDel");
procedure size
(fixed : fixed_access_t;
child : child_access_t;
width : positive;
height : positive);
pragma inline (size);
procedure move
(fixed : fixed_access_t;
child : child_access_t;
x : natural;
y : natural);
pragma inline (move);
function widget (fixed : fixed_access_t) return widget_access_t;
pragma inline (widget);
end agar.gui.widget.fixed;
|
-- =============================================================================
-- This package herachy is an exact 1:1 mapping to the gstreamer header-files
-- It's generated with the -fdump-ada-spec flag to gcc and patched in
-- Two phases.
-- Phase 1: Automatic bulk change using scripts.
-- Phase 2: Manual change of the final stuff.
--
-- This header file also provides placeholdrs for datatypes provided by GLIB.
--
-- The intention of is to use the generated packages as base to write more
-- Ada style bindings for requred packages and put them in the herachy
-- "gstreamer.*"
-- =============================================================================
pragma Warnings (Off);
with Interfaces.C.Extensions;
with System;
with Glib.Error;
with Glib.Object;
with Glib.Types;
private package GStreamer.GST_Low_Level is
use Interfaces.C;
package Glib_2_0_Glib_Gqueue_H is
type GQueue is new Interfaces.C.Extensions.Void;
end Glib_2_0_Glib_Gqueue_H;
package Glib_2_0_Glib_Gthread_H is
type GMutex is new Interfaces.C.Extensions.Void;
type GCond is new Interfaces.C.Extensions.Void;
type GThread is new Interfaces.C.Extensions.Void;
type GThreadPriority is new Interfaces.C.Extensions.Void;
type GThreadFunc is new Interfaces.C.Extensions.Void;
end Glib_2_0_Glib_Gthread_H;
package glib_2_0_glib_gthreadpool_h is
type GThreadPool is new Interfaces.C.Extensions.Void;
end glib_2_0_glib_gthreadpool_h;
package Glib_2_0_Glib_Gmain_H is
type GSource is new Interfaces.C.Extensions.Void;
end Glib_2_0_Glib_Gmain_H;
package Glib_2_0_Glib_Glist_H is
type GList is new Interfaces.C.Extensions.Void;
type GSList is new Interfaces.C.Extensions.Void;
end Glib_2_0_Glib_Glist_H;
package Glib_2_0_Gobject_Gobject_H is
type GObjectClass is new Interfaces.C.Extensions.Void;
end Glib_2_0_Gobject_Gobject_H;
package Glib_2_0_Gobject_Gparam_H is
type GParamSpec is new Interfaces.C.Extensions.Void;
type GParamFlags is new Interfaces.C.Extensions.Void;
end Glib_2_0_Gobject_Gparam_H;
package Glib_2_0_Gobject_Gtype_H is
subtype GTypeInterface is Glib.Types.GType_Interface;
type GTypeInstance is new System.Address;
type GTypeClass is new System.Address;
type GTimeVal is new System.Address;
type GBaseInitFunc is new System.Address;
type GBaseFinalizeFunc is new System.Address;
type GClassInitFunc is new System.Address;
type GClassFinalizeFunc is new System.Address;
type GTypeValueTable is new System.Address;
type GTypeFlags is new System.Address;
type GInstanceInitFunc is new System.Address;
end Glib_2_0_Gobject_Gtype_H;
package Glib_2_0_Glib_Deprecated_Gthread_H is
type GStaticRecMutex is new Interfaces.C.Extensions.Void;
type GThreadPriority is new Interfaces.C.Int;
end Glib_2_0_Glib_Deprecated_Gthread_H;
package Glib_2_0_Glib_Gtypes_H is
type GDestroyNotify is new Interfaces.C.Extensions.Void;
type GCompareDataFunc is new System.Address;
type GFreeFunc is new System.Address;
type GTimeVal is new System.Address;
type GCompareFunc is new System.Address;
type GFunc is new System.Address;
type GInstanceInitFunc is new System.Address;
type GTypeValueTable is new System.Address;
type GTypeFlags is new System.Address;
end Glib_2_0_Glib_Gtypes_H;
package glib_2_0_gobject_gclosure_h is
type GCallback is new System.Address;
end glib_2_0_gobject_gclosure_h;
package Glib_2_0_Glib_Garray_H is
type GPtrArray is new System.Address;
end glib_2_0_glib_garray_h;
package Glib_2_0_Glib_Gslist_H is
type GSList is new System.Address;
end Glib_2_0_Glib_Gslist_H;
package glib_2_0_glib_gpoll_h is
type GPollFD is record
Fd : aliased GLIB.Gint; -- /usr/include/glib-2.0/glib/gpoll.h:98
Events : aliased GLIB.Gushort; -- /usr/include/glib-2.0/glib/gpoll.h:100
Revents : aliased GLIB.Gushort; -- /usr/include/glib-2.0/glib/gpoll.h:101
end record;
end Glib_2_0_Glib_Gpoll_H;
package glib_2_0_gobject_gvaluearray_h is
type GValueArray is new System.Address;
end Glib_2_0_Gobject_Gvaluearray_H;
package Glib_2_0_Glib_Gstring_H is
type GString is new System.Address;
end Glib_2_0_Glib_Gstring_H;
package Sys_Types_H is
type Off_T is new Long;
end Sys_Types_H;
package Bits_Types_Time_T_H is
type Time_T is new Long;
end Bits_Types_Time_T_H;
package Libxml2_Libxml_Tree_H is
type XmlNodePtr is new Interfaces.C.Extensions.void_ptr;
type xmlNsPtr is new Interfaces.C.Extensions.void_ptr;
type xmlDocPtr is new Interfaces.C.Extensions.void_ptr;
end Libxml2_Libxml_Tree_H;
package time_h is
type pid_t is new int;
end time_h;
package Bits_Socket_H is
type Sockaddr is record
Sa_Family : aliased Unsigned_Short; -- /usr/include/bits/socket.h:176
Sa_Data : aliased Interfaces.C.Char_Array (0 .. 13); -- /usr/include/bits/socket.h:177
end record;
pragma Convention (C_Pass_By_Copy, Sockaddr); -- /usr/include/bits/socket.h:174
type Socklen_T is new Unsigned;
end Bits_Socket_H;
package Glib_2_0_Glib_Gdate_H is
type GDate is record
Julian_Days : aliased GLIB.Guint; -- /usr/include/glib-2.0/glib/gdate.h:101
Julian : Extensions.Unsigned_1; -- /usr/include/glib-2.0/glib/gdate.h:107
Dmy : Extensions.Unsigned_1; -- /usr/include/glib-2.0/glib/gdate.h:108
Day : Extensions.Unsigned_6; -- /usr/include/glib-2.0/glib/gdate.h:111
Month : Extensions.Unsigned_4; -- /usr/include/glib-2.0/glib/gdate.h:112
Year : aliased Unsigned_Short; -- /usr/include/glib-2.0/glib/gdate.h:113
end record;
pragma Convention (C_Pass_By_Copy, GDate);
pragma Pack (GDate); -- /usr/include/glib-2.0/glib/gdate.h:99
end Glib_2_0_Glib_Gdate_H;
end GStreamer.GST_Low_Level;
|
with Ada.Text_IO;use Ada.Text_IO;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Numerics.Discrete_Random;
procedure sporadic_task is
protected sporadic is
procedure release;
entry next_release;
private
barrier : Boolean;
min_int : Time_Span := Milliseconds(3000);
last_release : Time;
end sporadic;
protected body sporadic is
procedure release is
current : Time := Clock;
begin
if current - last_release > min_int then
--Put_Line("Interrupt:");
barrier := True;
last_release := Clock;
end if;
end release;
entry next_release when barrier is
begin
barrier := False;
end next_release;
end sporadic;
task type sptask is
end sptask;
task type sserver is
end sserver;
task body sptask is
begin
loop
sporadic.next_release;
Put_Line("Sporadic Task Released");
end loop;
end sptask;
task body sserver is
subtype Die is Integer range 1 .. 10;
package Random_Die is new Ada.Numerics.Discrete_Random (Die);
use Random_Die;
G : Generator;
now : Time;
intrval : Time_Span := Milliseconds(3000);
begin
Reset (G);
now := Clock;
loop
if Random(G) > 5 then
delay until (now + intrval);
end if;
now := Clock;
sporadic.release;
end loop;
end sserver;
task1 : sptask;
server :sserver;
begin
Put_Line("This is an example of spoardic tasks");
end sporadic_task;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2013-2014, 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 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Interfaces; use Interfaces;
with System;
with Sam4s; use Sam4s;
with Pll;
with Leds;
procedure Main is
procedure Wait is
begin
for I in 1 .. 16#3ffff# loop
null;
end loop;
end Wait;
PB2 : constant := 2 ** 2;
PB3 : constant := 2 ** 3;
PA9 : constant := 2 ** 9;
PA10 : constant := 2 ** 10;
-- Uart_Ports : constant := PA9 + PA10;
Uart_Ports : constant := PB2 + PB3;
begin
Pll.Init;
Leds.Init;
-- Disable watchdog
WDT.WDT_MR := WDT_MR.WDDIS;
-- Init uart1
PMC.PMC_PCER0 := 2 ** UART1_ID + 2 ** PIOB_ID;
PIOB.PDR := Uart_Ports;
PIOB.ODR := Uart_Ports;
PIOB.PUER := Uart_Ports;
PIOB.MDDR := Uart_Ports;
PIOB.ABCDSR1 := PIOB.ABCDSR1 and not Uart_Ports;
PIOB.ABCDSR2 := PIOB.ABCDSR2 and not Uart_Ports;
UART1.UART_BRGR := 120_000_000 / (16 * 115200);
UART1.UART_MR := UART_MR.CHMODE_NORMAL or UART_MR.PAR_NO;
UART1.UART_CR := UART_CR.TXEN or UART_CR.RXEN;
for I in 1 .. 10 loop
while (UART1.UART_SR and UART_SR.TXRDY) = 0 loop
null;
end loop;
UART1.UART_THR := Character'Pos ('H');
end loop;
loop
null;
end loop;
end Main;
|
with Ada.Assertions;
use Ada.Assertions;
package TestEnvironment is
procedure run_test;
end TestEnvironment;
|
with AdaCar; use AdaCar;
with AdaCar.Alarmas;
with AdaCar.Entrada_Salida;
with AdaCar.Sensor_Proximidad;
with AdaCar.Seguimiento_Sensor;
with AdaCar.Motores;
with AdaCar.Organizador_Movimiento;
with AdaCar.Parametros;
procedure Main is
begin
-- Insert code here.
null;
end Main;
|
with
freetype_c.Binding,
freetype_c.FT_BBox,
freetype_c.FT_Vector;
package body openGL.GlyphImpl
is
-----------
-- Utility
--
function Bounds_of (glyth_Slot : in freetype_c.FT_GlyphSlot.item) return Bounds
is
use freetype_c.Binding;
bBox : aliased freetype_c.FT_BBox.item;
the_Bounds : Bounds;
begin
FT_Outline_Get_CBox (FT_GlyphSlot_Get_Outline (glyth_Slot).all'unchecked_Access,
bBox'unchecked_Access);
the_Bounds := (Ball => <>,
Box => (Lower => (1 => Real (bbox.xMin) / 64.0,
2 => Real (bbox.yMin) / 64.0,
3 => 0.0),
Upper => (1 => Real (bbox.xMax) / 64.0,
2 => Real (bbox.yMax) / 64.0,
3 => 0.0)));
set_Ball_from_Box (the_Bounds);
return the_Bounds;
end Bounds_of;
---------
-- Forge
--
procedure define (Self : in out Item; glyth_Slot : in freetype_c.FT_GlyphSlot.item)
is
use type freetype_c.FT_GlyphSlot.item;
begin
Self.Err := no_Error;
if glyth_Slot /= null
then
Self.bBox := Bounds_of (glyth_Slot);
declare
use freetype_c.Binding;
the_Advance : constant freetype_c.FT_Vector.item := FT_GlyphSlot_Get_Advance (glyth_Slot);
begin
Self.Advance := (Real (the_Advance.x) / 64.0,
Real (the_Advance.y) / 64.0,
0.0);
end;
end if;
end define;
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
--------------
-- Attributes
--
function Advance (Self : in Item) return Real
is
begin
return Self.Advance (1);
end Advance;
function BBox (Self : in Item) return Bounds
is
begin
return Self.bBox;
end BBox;
function Error (Self : in Item) return error_Kind
is
begin
return Self.Err;
end Error;
end openGL.GlyphImpl;
|
package body openGL.Model.sphere
is
---------
--- Forge
--
procedure define (Self : out Item; Radius : Real)
is
begin
Self.Radius := Radius;
end define;
--------------
--- Attributes
--
overriding
function Bounds (Self : in Item) return openGL.Bounds
is
begin
return (Ball => Self.Radius,
Box => (Lower => (-Self.Radius, -Self.Radius, -Self.Radius),
Upper => ( Self.Radius, Self.Radius, Self.Radius)));
end Bounds;
end openGL.Model.sphere;
|
-----------------------------------------------------------------------
-- sqlbench-main -- Main SQL Bencharmk
-- Copyright (C) 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.Exceptions;
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Util.Log.Loggers;
with Util.Measures;
with Util.Strings;
with Util.Files;
with ADO;
with ADO.Configs;
with ADO.Drivers;
with ADO.Connections;
with ADO.Sessions;
with ADO.Sessions.Factory;
with Sqlbench.Simple;
procedure Sqlbench.Main is
use Ada.Strings.Unbounded;
procedure Read_Line (Line : in String);
procedure Read_Stat_Line (Line : in String);
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Sqlbench.Main");
Thread_Count : Natural := 0;
Rss_Size : Natural := 0;
Hwm_Size : Natural := 0;
User_Time : Natural := 0;
Sys_Time : Natural := 0;
procedure Read_Line (Line : in String) is
Pos : Natural := Util.Strings.Index (Line, ASCII.HT);
Last : Natural := Util.Strings.Rindex (Line, ' ');
begin
Log.Debug ("{0}", Line);
if Pos = 0 then
Pos := Util.Strings.Index (Line, ' ');
end if;
if Last = 0 then
Last := Line'Last;
end if;
if Pos > 0 then
if Util.Strings.Starts_With (Line, "Threads:") then
Thread_Count := Natural'Value (Line (Pos + 1 .. Last));
elsif Util.Strings.Starts_With (Line, "VmRSS:") then
Rss_Size := Natural'Value (Line (Pos + 1 .. Last));
elsif Util.Strings.Starts_With (Line, "VmHWM:") then
Hwm_Size := Natural'Value (Line (Pos + 1 .. Last));
end if;
end if;
exception
when Constraint_Error =>
null;
end Read_Line;
procedure Read_Stat_Line (Line : in String) is
Pos : Natural := Line'First;
Next : Natural;
begin
Log.Debug ("{0}", Line);
for I in 1 .. 13 loop
Pos := Util.Strings.Index (Line, ' ', Pos + 1);
exit when Pos = 0;
end loop;
Next := Util.Strings.Index (Line, ' ', Pos + 1);
User_Time := 10 * Natural'Value (Line (Pos + 1 .. Next - 1));
Pos := Next;
Next := Util.Strings.Index (Line, ' ', Pos + 1);
Sys_Time := 10 * Natural'Value (Line (Pos + 1 .. Next - 1));
exception
when Constraint_Error =>
null;
end Read_Stat_Line;
Driver : Unbounded_String;
Context : Sqlbench.Context_Type;
Repeat : Sqlbench.Repeat_Type := 100;
Output : Unbounded_String;
Output_File : Ada.Text_IO.File_Type;
Arg_Pos : Positive := 1;
Arg_Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
Util.Log.Loggers.Initialize ("sqlbench.properties");
-- Initialize the database drivers.
ADO.Drivers.Initialize ("sqlbench.properties");
while Arg_Pos <= Arg_Count loop
declare
Arg : constant String := Ada.Command_Line.Argument (Arg_Pos);
begin
if Arg = "-sqlite" then
Driver := To_Unbounded_String ("sqlite");
elsif Arg = "-mysql" then
Driver := To_Unbounded_String ("mysql");
elsif Arg = "-postgresql" then
Driver := To_Unbounded_String ("postgresql");
elsif Arg = "-repeat" and Arg_Pos + 1 <= Arg_Count then
Arg_Pos := Arg_Pos + 1;
Repeat := Repeat_Type'Value (Ada.Command_Line.Argument (Arg_Pos));
elsif Arg = "-o" and Arg_Pos + 1 <= Arg_Count then
Arg_Pos := Arg_Pos + 1;
Output := To_Unbounded_String (Ada.Command_Line.Argument (Arg_Pos));
else
raise Constraint_Error;
end if;
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"Usage: sql-bench [-sqlite] [-mysql] [-postgresql] "
& "[-repeat count] [-o output]");
Ada.Command_Line.Set_Exit_Status (2);
return;
end;
Arg_Pos := Arg_Pos + 1;
end loop;
-- Initialize the session factory to connect to the
-- database defined by 'ado.database' property.
Context.Factory.Create (ADO.Configs.Get_Config (To_String (Driver) & ".database"));
Context.Session := Context.Factory.Get_Master_Session;
Simple.Register (Context);
for Test of Context.Tests loop
Context.Repeat := Repeat * Test.Factor;
declare
T : Util.Measures.Stamp;
begin
Test.Handler (Context);
Util.Measures.Report (Context.Perf, T, Test.Title, Positive (Context.Repeat));
exception
when others =>
null;
end;
end loop;
begin
Util.Files.Read_File (Path => "/proc/self/status", Process => Read_Line'Access);
exception
when others =>
null;
end;
begin
Util.Files.Read_File (Path => "/proc/self/stat", Process => Read_Stat_Line'Access);
exception
when others =>
null;
end;
if Length (Output) > 0 then
Ada.Text_IO.Create (Output_File, Ada.Text_IO.Out_File, To_String (Output));
Ada.Text_IO.Set_Output (Output_File);
end if;
Ada.Text_IO.Put ("<benchmark language='Ada' driver='");
Ada.Text_IO.Put (Context.Get_Driver_Name);
Ada.Text_IO.Put ("' threads='");
Ada.Text_IO.Put (Util.Strings.Image (Thread_Count));
Ada.Text_IO.Put ("' rss_size='");
Ada.Text_IO.Put (Util.Strings.Image (Rss_Size));
Ada.Text_IO.Put ("' peek_rss_size='");
Ada.Text_IO.Put (Util.Strings.Image (Hwm_Size));
Ada.Text_IO.Put ("' user_time='");
Ada.Text_IO.Put (Util.Strings.Image (User_Time));
Ada.Text_IO.Put ("' sys_time='");
Ada.Text_IO.Put (Util.Strings.Image (Sys_Time));
Ada.Text_IO.Put_Line ("'>");
Util.Measures.Write (Context.Perf, "SQL Benchmark",
(if Length (Output) > 0 then
Output_File else Ada.Text_IO.Standard_Output));
Ada.Text_IO.Put_Line ("</benchmark>");
Ada.Text_IO.Flush;
exception
when E : ADO.Connections.Database_Error | ADO.Sessions.Connection_Error =>
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"Cannot connect to database: "
& Ada.Exceptions.Exception_Message (E));
Ada.Command_Line.Set_Exit_Status (1);
end Sqlbench.Main;
|
with GNAT.IO; use GNAT.IO;
package body Except
is
procedure Do_Something
is
begin
raise Test_Exception;
end Do_Something;
procedure Do_Sth_2
is
begin
begin
Do_Something;
exception
when others => Put_Line ("Exception caught (inner)");
end;
end Do_Sth_2;
end Except;
|
-----------------------------------------------------------------------
-- druss-commands -- Commands available for Druss
-- Copyright (C) 2017, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Util.Strings;
with Util.Log.Loggers;
with Readline;
with Druss.Commands.Bboxes;
with Druss.Commands.Get;
with Druss.Commands.Status;
with Druss.Commands.Wifi;
with Druss.Commands.Devices;
with Druss.Commands.Ping;
package body Druss.Commands is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Commands");
function Uptime_Image (Value : in Natural) return String;
procedure Quit (Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
Help_Command : aliased Druss.Commands.Drivers.Help_Command_Type;
Bbox_Commands : aliased Druss.Commands.Bboxes.Command_Type;
Get_Commands : aliased Druss.Commands.Get.Command_Type;
Wifi_Commands : aliased Druss.Commands.Wifi.Command_Type;
Status_Commands : aliased Druss.Commands.Status.Command_Type;
Device_Commands : aliased Druss.Commands.Devices.Command_Type;
Ping_Commands : aliased Druss.Commands.Ping.Command_Type;
procedure Gateway_Command (Command : in Drivers.Command_Type'Class;
Args : in Util.Commands.Argument_List'Class;
Arg_Pos : in Positive;
Process : access procedure (Gateway : in out Gateways.Gateway_Type;
Param : in String);
Context : in out Context_Type) is
pragma Unreferenced (Command);
begin
if Args.Get_Count < Arg_Pos then
Context.Console.Notice (N_USAGE, "Missing argument for command");
Druss.Commands.Driver.Usage (Args, Context);
end if;
declare
procedure Operation (Gateway : in out Druss.Gateways.Gateway_Type);
Param : constant String := Args.Get_Argument (Arg_Pos);
Gw : Druss.Gateways.Gateway_Ref;
procedure Operation (Gateway : in out Druss.Gateways.Gateway_Type) is
begin
Process (Gateway, Param);
end Operation;
begin
if Args.Get_Count = Arg_Pos then
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Operation'Access);
else
for I in Arg_Pos + 1 .. Args.Get_Count loop
Gw := Druss.Gateways.Find_IP (Context.Gateways, Args.Get_Argument (I));
if not Gw.Is_Null then
Operation (Gw.Value);
end if;
end loop;
end if;
end;
end Gateway_Command;
procedure Initialize is
begin
Driver.Set_Description ("Druss - The Bbox master controller");
Driver.Set_Usage ("[-v] [-d] [-i] [-o file] [-c config] <command> [<args>]" & ASCII.LF &
"where:" & ASCII.LF &
" -v Verbose execution mode" & ASCII.LF &
" -d Debug execution mode" & ASCII.LF &
" -i Enter the interactive mode" & ASCII.LF &
" -c config Use the configuration file" &
" (instead of $HOME/.config/druss/druss.properties)" & ASCII.LF &
" -o file The output file to use");
Driver.Add_Command ("help", Help_Command'Access);
Driver.Add_Command ("bbox", Bbox_Commands'Access);
Driver.Add_Command ("get", Get_Commands'Access);
Driver.Add_Command ("wifi", Wifi_Commands'Access);
Driver.Add_Command ("status", Status_Commands'Access);
Driver.Add_Command ("devices", Device_Commands'Access);
Driver.Add_Command ("ping", Ping_Commands'Access);
end Initialize;
-- ------------------------------
-- Quit the interactive loop.
-- ------------------------------
procedure Quit (Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name, Args, Context);
begin
raise Stop_Interactive;
end Quit;
-- ------------------------------
-- Enter in the interactive main loop waiting for user commands and executing them.
-- ------------------------------
procedure Interactive (Context : in out Context_Type) is
Args : Util.Commands.String_Argument_List (Max_Length => 1000,
Max_Args => 100);
begin
Log.Debug ("Entering in interactive mode");
Driver.Add_Command (Name => "quit", Handler => Quit'Access,
Description => "quit the program");
loop
declare
Line : constant String := Readline.Get_Line ("druss>");
begin
Log.Debug ("Execute: {0}", Line);
Args.Initialize (Line);
Driver.Execute (Args.Get_Command_Name, Args, Context);
exception
when Stop_Interactive =>
Log.Debug ("Leaving interactive mode");
exit;
when others =>
Context.Console.Notice (N_INFO, "Command failed");
end;
end loop;
exception
when Ada.IO_Exceptions.End_Error =>
Log.Debug ("End_Error exception received");
end Interactive;
-- ------------------------------
-- Print the bbox API status.
-- ------------------------------
procedure Print_Status (Console : in Consoles.Console_Access;
Field : in Field_Type;
Value : in String) is
begin
if Value = "2" then
Console.Print_Field (Field, "OK");
elsif Value = "-1" then
Console.Print_Field (Field, "KO");
elsif Value = "1" then
Console.Print_Field (Field, "Starting");
elsif Value = "0" then
Console.Print_Field (Field, "Stopped");
else
Console.Print_Field (Field, "?");
end if;
end Print_Status;
-- ------------------------------
-- Print a ON/OFF status.
-- ------------------------------
procedure Print_On_Off (Console : in Consoles.Console_Access;
Field : in Field_Type;
Value : in String) is
begin
if Value = "1" then
Console.Print_Field (Field, "ON");
elsif Value = "0" then
Console.Print_Field (Field, "OFF");
else
Console.Print_Field (Field, "");
end if;
end Print_On_Off;
function Uptime_Image (Value : in Natural) return String is
D : constant Natural := Value / 86400;
R : constant Natural := Value mod 86400;
H : constant Natural := R / 3600;
M : constant Natural := (R mod 3600) / 60;
S : constant Natural := (R mod 3600) mod 60;
begin
if D > 0 then
return Util.Strings.Image (D) & "d"
& (if H > 0 then Natural'Image (H) & "h" else "")
& (if M > 0 then Natural'Image (M) & "m" else "");
elsif H > 0 then
return Util.Strings.Image (H) & "h"
& (if M > 0 then Natural'Image (M) & "m" else "");
else
return Util.Strings.Image (M) & "m"
& Natural'Image (S) & "s";
end if;
end Uptime_Image;
-- ------------------------------
-- Print a uptime.
-- ------------------------------
procedure Print_Uptime (Console : in Consoles.Console_Access;
Field : in Field_Type;
Value : in String) is
begin
if Value = "" then
Console.Print_Field (Field, Value);
else
Console.Print_Field (Field, Uptime_Image (Natural'Value (Value)));
end if;
exception
when others =>
Console.Print_Field (Field, Value);
end Print_Uptime;
-- ------------------------------
-- Print a performance measure in us or ms.
-- ------------------------------
procedure Print_Perf (Console : in Consoles.Console_Access;
Field : in Field_Type;
Value : in String) is
use Commands.Consoles;
begin
if Value = "" then
Console.Print_Field (Field, Value);
elsif Value'Length <= 3 then
Console.Print_Field (Field, Value & " us", J_RIGHT);
elsif Value'Length <= 6 then
Console.Print_Field (Field, Value (Value'First .. Value'Last - 3) & "."
& Value (Value'Last - 2 .. Value'Last) & " ms", J_RIGHT);
else
Console.Print_Field (Field, Value (Value'First .. Value'Last - 6) & "."
& Value (Value'Last - 5 .. Value'Last - 3) & " s", J_RIGHT);
end if;
end Print_Perf;
end Druss.Commands;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package body GL.Enums.Indexes is
function Representation (Value : Index) return Int is
begin
return Min_Representation + Value;
end Representation;
function Value (Representation : Int) return Index is
begin
return Representation - Min_Representation;
end Value;
end GL.Enums.Indexes;
|
with TEXT_IO; use TEXT_IO;
function Get_Discreet return Element is
Str: String(1..Element'Width+1);
Len: Natural;
begin
loop
declare
begin
Get_Line(Str,Len);
if Len <= Element'Width then
return Element'Value( Str(1..Len) );
else Skip_Line;
end if;
exception
when Constraint_Error => null;
end;
end loop;
end Get_Discreet;
|
with Ada.Directories;
with Ada.Numerics.Generic_Elementary_Functions;
with Ahven.Framework;
with Floats.Api;
package Test_Floats.Write is
package Skill renames Floats.Api;
use Floats;
use Floats.Api;
type Test is new Ahven.Framework.Test_Case with null record;
procedure Initialize (T : in out Test);
procedure Set_Up (T : in out Test);
procedure Tear_Down (T : in out Test);
procedure Float (T : in out Ahven.Framework.Test_Case'Class);
procedure Double (T : in out Ahven.Framework.Test_Case'Class);
end Test_Floats.Write;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O U T P U T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2013, 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. --
-- --
------------------------------------------------------------------------------
package body Output is
Current_FD : File_Descriptor := Standout;
-- File descriptor for current output
Special_Output_Proc : Output_Proc := null;
-- Record argument to last call to Set_Special_Output. If this is
-- non-null, then we are in special output mode.
Indentation_Amount : constant Positive := 3;
-- Number of spaces to output for each indentation level
Indentation_Limit : constant Positive := 40;
-- Indentation beyond this number of spaces wraps around
pragma Assert (Indentation_Limit < Buffer_Max / 2);
-- Make sure this is substantially shorter than the line length
Cur_Indentation : Natural := 0;
-- Number of spaces to indent each line
-----------------------
-- Local_Subprograms --
-----------------------
procedure Flush_Buffer;
-- Flush buffer if non-empty and reset column counter
---------------------------
-- Cancel_Special_Output --
---------------------------
procedure Cancel_Special_Output is
begin
Special_Output_Proc := null;
end Cancel_Special_Output;
------------
-- Column --
------------
function Column return Pos is
begin
return Pos (Next_Col);
end Column;
----------------------
-- Delete_Last_Char --
----------------------
procedure Delete_Last_Char is
begin
if Next_Col /= 1 then
Next_Col := Next_Col - 1;
end if;
end Delete_Last_Char;
------------------
-- Flush_Buffer --
------------------
procedure Flush_Buffer is
Write_Error : exception;
-- Raised if Write fails
------------------
-- Write_Buffer --
------------------
procedure Write_Buffer (Buf : String);
-- Write out Buf, either using Special_Output_Proc, or the normal way
-- using Write. Raise Write_Error if Write fails (presumably due to disk
-- full). Write_Error is not used in the case of Special_Output_Proc.
procedure Write_Buffer (Buf : String) is
begin
-- If Special_Output_Proc has been set, then use it
if Special_Output_Proc /= null then
Special_Output_Proc.all (Buf);
-- If output is not set, then output to either standard output
-- or standard error.
elsif Write (Current_FD, Buf'Address, Buf'Length) /= Buf'Length then
raise Write_Error;
end if;
end Write_Buffer;
Len : constant Natural := Next_Col - 1;
-- Start of processing for Flush_Buffer
begin
if Len /= 0 then
begin
-- If there's no indentation, or if the line is too long with
-- indentation, or if it's a blank line, just write the buffer.
if Cur_Indentation = 0
or else Cur_Indentation + Len > Buffer_Max
or else Buffer (1 .. Len) = (1 => ASCII.LF)
then
Write_Buffer (Buffer (1 .. Len));
-- Otherwise, construct a new buffer with preceding spaces, and
-- write that.
else
declare
Indented_Buffer : constant String :=
(1 .. Cur_Indentation => ' ') &
Buffer (1 .. Len);
begin
Write_Buffer (Indented_Buffer);
end;
end if;
exception
when Write_Error =>
-- If there are errors with standard error just quit. Otherwise
-- set the output to standard error before reporting a failure
-- and quitting.
if Current_FD /= Standerr then
Current_FD := Standerr;
Next_Col := 1;
Write_Line ("fatal error: disk full");
end if;
OS_Exit (2);
end;
-- Buffer is now empty
Next_Col := 1;
end if;
end Flush_Buffer;
-------------------
-- Ignore_Output --
-------------------
procedure Ignore_Output (S : String) is
begin
null;
end Ignore_Output;
------------
-- Indent --
------------
procedure Indent is
begin
-- The "mod" in the following assignment is to cause a wrap around in
-- the case where there is too much indentation.
Cur_Indentation :=
(Cur_Indentation + Indentation_Amount) mod Indentation_Limit;
end Indent;
---------------
-- Last_Char --
---------------
function Last_Char return Character is
begin
if Next_Col /= 1 then
return Buffer (Next_Col - 1);
else
return ASCII.NUL;
end if;
end Last_Char;
-------------
-- Outdent --
-------------
procedure Outdent is
begin
-- The "mod" here undoes the wrap around from Indent above
Cur_Indentation :=
(Cur_Indentation - Indentation_Amount) mod Indentation_Limit;
end Outdent;
---------------------------
-- Restore_Output_Buffer --
---------------------------
procedure Restore_Output_Buffer (S : Saved_Output_Buffer) is
begin
Next_Col := S.Next_Col;
Cur_Indentation := S.Cur_Indentation;
Buffer (1 .. Next_Col - 1) := S.Buffer (1 .. Next_Col - 1);
end Restore_Output_Buffer;
------------------------
-- Save_Output_Buffer --
------------------------
function Save_Output_Buffer return Saved_Output_Buffer is
S : Saved_Output_Buffer;
begin
S.Buffer (1 .. Next_Col - 1) := Buffer (1 .. Next_Col - 1);
S.Next_Col := Next_Col;
S.Cur_Indentation := Cur_Indentation;
Next_Col := 1;
Cur_Indentation := 0;
return S;
end Save_Output_Buffer;
------------------------
-- Set_Special_Output --
------------------------
procedure Set_Special_Output (P : Output_Proc) is
begin
Special_Output_Proc := P;
end Set_Special_Output;
----------------
-- Set_Output --
----------------
procedure Set_Output (FD : File_Descriptor) is
begin
if Special_Output_Proc = null then
Flush_Buffer;
end if;
Current_FD := FD;
end Set_Output;
------------------------
-- Set_Standard_Error --
------------------------
procedure Set_Standard_Error is
begin
Set_Output (Standerr);
end Set_Standard_Error;
-------------------------
-- Set_Standard_Output --
-------------------------
procedure Set_Standard_Output is
begin
Set_Output (Standout);
end Set_Standard_Output;
-------
-- w --
-------
procedure w (C : Character) is
begin
Write_Char (''');
Write_Char (C);
Write_Char (''');
Write_Eol;
end w;
procedure w (S : String) is
begin
Write_Str (S);
Write_Eol;
end w;
procedure w (V : Int) is
begin
Write_Int (V);
Write_Eol;
end w;
procedure w (B : Boolean) is
begin
if B then
w ("True");
else
w ("False");
end if;
end w;
procedure w (L : String; C : Character) is
begin
Write_Str (L);
Write_Char (' ');
w (C);
end w;
procedure w (L : String; S : String) is
begin
Write_Str (L);
Write_Char (' ');
w (S);
end w;
procedure w (L : String; V : Int) is
begin
Write_Str (L);
Write_Char (' ');
w (V);
end w;
procedure w (L : String; B : Boolean) is
begin
Write_Str (L);
Write_Char (' ');
w (B);
end w;
----------------
-- Write_Char --
----------------
procedure Write_Char (C : Character) is
begin
if Next_Col = Buffer'Length then
Write_Eol;
end if;
if C = ASCII.LF then
Write_Eol;
else
Buffer (Next_Col) := C;
Next_Col := Next_Col + 1;
end if;
end Write_Char;
---------------
-- Write_Eol --
---------------
procedure Write_Eol is
begin
-- Remove any trailing spaces
while Next_Col > 1 and then Buffer (Next_Col - 1) = ' ' loop
Next_Col := Next_Col - 1;
end loop;
Buffer (Next_Col) := ASCII.LF;
Next_Col := Next_Col + 1;
Flush_Buffer;
end Write_Eol;
---------------------------
-- Write_Eol_Keep_Blanks --
---------------------------
procedure Write_Eol_Keep_Blanks is
begin
Buffer (Next_Col) := ASCII.LF;
Next_Col := Next_Col + 1;
Flush_Buffer;
end Write_Eol_Keep_Blanks;
----------------------
-- Write_Erase_Char --
----------------------
procedure Write_Erase_Char (C : Character) is
begin
if Next_Col /= 1 and then Buffer (Next_Col - 1) = C then
Next_Col := Next_Col - 1;
end if;
end Write_Erase_Char;
---------------
-- Write_Int --
---------------
procedure Write_Int (Val : Int) is
begin
if Val < 0 then
Write_Char ('-');
Write_Int (-Val);
else
if Val > 9 then
Write_Int (Val / 10);
end if;
Write_Char (Character'Val ((Val mod 10) + Character'Pos ('0')));
end if;
end Write_Int;
----------------
-- Write_Line --
----------------
procedure Write_Line (S : String) is
begin
Write_Str (S);
Write_Eol;
end Write_Line;
------------------
-- Write_Spaces --
------------------
procedure Write_Spaces (N : Nat) is
begin
for J in 1 .. N loop
Write_Char (' ');
end loop;
end Write_Spaces;
---------------
-- Write_Str --
---------------
procedure Write_Str (S : String) is
begin
for J in S'Range loop
Write_Char (S (J));
end loop;
end Write_Str;
end Output;
|
WITH Spider;
PROCEDURE Draw_Box_with_1_Loop IS
------------------------------------------------------------------
--| draw 4 x 4 box with spider - use loop
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: July 1995
------------------------------------------------------------------
BEGIN -- Draw_Box_with_1_Loop
Spider.Start;
FOR Side IN 1..4 LOOP
Spider.Step;
Spider.Step;
Spider.Step;
Spider.Right;
END LOOP;
Spider.Quit;
END Draw_Box_with_1_Loop; |
------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- SHA2 (512) --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019-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. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Ada.Streams;
package Modular_Hashing.SHA512 is
type SHA512_Hash is new Hash with private;
-- The final hash is a 512-bit message digest, which can also be displayed
-- as a 128 character hex string and is 64 bytes long
overriding function "<" (Left, Right : SHA512_Hash) return Boolean;
overriding function ">" (Left, Right : SHA512_Hash) return Boolean;
overriding function "=" (Left, Right : SHA512_Hash) return Boolean;
SHA512_Hash_Bytes: constant := 64;
overriding function Binary_Bytes (Value: SHA512_Hash) return Positive is
(SHA512_Hash_Bytes);
overriding function Binary (Value: SHA512_Hash) return Hash_Binary_Value
with Post => Binary'Result'Length = SHA512_Hash_Bytes;
type SHA512_Engine is new Hash_Algorithm with private;
overriding
procedure Write (Stream : in out SHA512_Engine;
Item : in Ada.Streams.Stream_Element_Array);
overriding procedure Reset (Engine : in out SHA512_Engine);
overriding function Digest (Engine : in out SHA512_Engine)
return Hash'Class;
private
use Ada.Streams, Interfaces;
package U_128 is
type Unsigned_128 is
record
--Internal_Repr : array (1 .. 2) of Unsigned_64 := (others => 0);
High : Unsigned_64 := 0;
Low : Unsigned_64 := 0;
end record;
function "+" (Left, Right : Unsigned_128) return Unsigned_128;
end U_128;
-----------------
-- SHA512_Hash --
-----------------
type Message_Digest is array (1 .. 8) of Unsigned_64;
type SHA512_Hash is new Hash with
record
Digest: Message_Digest;
end record;
-------------------
-- SHA512_Engine --
-------------------
-- SHA-2 Defined initialization constants
H0_Initial: constant := 16#6a09e667f3bcc908#;
H1_Initial: constant := 16#bb67ae8584caa73b#;
H2_Initial: constant := 16#3c6ef372fe94f82b#;
H3_Initial: constant := 16#a54ff53a5f1d36f1#;
H4_Initial: constant := 16#510e527fade682d1#;
H5_Initial: constant := 16#9b05688c2b3e6c1f#;
H6_Initial: constant := 16#1f83d9abfb41bd6b#;
H7_Initial: constant := 16#5be0cd19137e2179#;
type K_Arr is array (1 .. 80) of Unsigned_64;
K : constant K_Arr :=
(16#428a2f98d728ae22#, 16#7137449123ef65cd#, 16#b5c0fbcfec4d3b2f#, 16#e9b5dba58189dbbc#,
16#3956c25bf348b538#, 16#59f111f1b605d019#, 16#923f82a4af194f9b#, 16#ab1c5ed5da6d8118#,
16#d807aa98a3030242#, 16#12835b0145706fbe#, 16#243185be4ee4b28c#, 16#550c7dc3d5ffb4e2#,
16#72be5d74f27b896f#, 16#80deb1fe3b1696b1#, 16#9bdc06a725c71235#, 16#c19bf174cf692694#,
16#e49b69c19ef14ad2#, 16#efbe4786384f25e3#, 16#0fc19dc68b8cd5b5#, 16#240ca1cc77ac9c65#,
16#2de92c6f592b0275#, 16#4a7484aa6ea6e483#, 16#5cb0a9dcbd41fbd4#, 16#76f988da831153b5#,
16#983e5152ee66dfab#, 16#a831c66d2db43210#, 16#b00327c898fb213f#, 16#bf597fc7beef0ee4#,
16#c6e00bf33da88fc2#, 16#d5a79147930aa725#, 16#06ca6351e003826f#, 16#142929670a0e6e70#,
16#27b70a8546d22ffc#, 16#2e1b21385c26c926#, 16#4d2c6dfc5ac42aed#, 16#53380d139d95b3df#,
16#650a73548baf63de#, 16#766a0abb3c77b2a8#, 16#81c2c92e47edaee6#, 16#92722c851482353b#,
16#a2bfe8a14cf10364#, 16#a81a664bbc423001#, 16#c24b8b70d0f89791#, 16#c76c51a30654be30#,
16#d192e819d6ef5218#, 16#d69906245565a910#, 16#f40e35855771202a#, 16#106aa07032bbd1b8#,
16#19a4c116b8d2d0c8#, 16#1e376c085141ab53#, 16#2748774cdf8eeb99#, 16#34b0bcb5e19b48a8#,
16#391c0cb3c5c95a63#, 16#4ed8aa4ae3418acb#, 16#5b9cca4f7763e373#, 16#682e6ff3d6b2b8a3#,
16#748f82ee5defb2fc#, 16#78a5636f43172f60#, 16#84c87814a1f0ab72#, 16#8cc702081a6439ec#,
16#90befffa23631e28#, 16#a4506cebde82bde9#, 16#bef9a3f7b2c67915#, 16#c67178f2e372532b#,
16#ca273eceea26619c#, 16#d186b8c721c0c207#, 16#eada7dd6cde0eb1e#, 16#f57d4f7fee6ed178#,
16#06f067aa72176fba#, 16#0a637dc5a2c898a6#, 16#113f9804bef90dae#, 16#1b710b35131c471b#,
16#28db77f523047d84#, 16#32caab7b40c72493#, 16#3c9ebe0a15c9bebc#, 16#431d67c49c100d4c#,
16#4cc5d4becb3e42b6#, 16#597f299cfc657e2a#, 16#5fcb6fab3ad6faec#, 16#6c44198c4a475817#);
type SHA512_Engine is new Hash_Algorithm with record
Last_Element_Index : Stream_Element_Offset := 0;
Buffer : Stream_Element_Array(1 .. 128);
Message_Length : U_128.Unsigned_128;
H0 : Unsigned_64 := H0_Initial;
H1 : Unsigned_64 := H1_Initial;
H2 : Unsigned_64 := H2_Initial;
H3 : Unsigned_64 := H3_Initial;
H4 : Unsigned_64 := H4_Initial;
H5 : Unsigned_64 := H5_Initial;
H6 : Unsigned_64 := H6_Initial;
H7 : Unsigned_64 := H7_Initial;
end record;
end Modular_Hashing.SHA512;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E V A L _ F A T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Einfo; use Einfo;
with Errout; use Errout;
with Sem_Util; use Sem_Util;
package body Eval_Fat is
Radix : constant Int := 2;
-- This code is currently only correct for the radix 2 case. We use the
-- symbolic value Radix where possible to help in the unlikely case of
-- anyone ever having to adjust this code for another value, and for
-- documentation purposes.
-- Another assumption is that the range of the floating-point type is
-- symmetric around zero.
type Radix_Power_Table is array (Int range 1 .. 4) of Int;
Radix_Powers : constant Radix_Power_Table :=
(Radix ** 1, Radix ** 2, Radix ** 3, Radix ** 4);
-----------------------
-- Local Subprograms --
-----------------------
procedure Decompose
(RT : R;
X : T;
Fraction : out T;
Exponent : out UI;
Mode : Rounding_Mode := Round);
-- Decomposes a non-zero floating-point number into fraction and exponent
-- parts. The fraction is in the interval 1.0 / Radix .. T'Pred (1.0) and
-- uses Rbase = Radix. The result is rounded to a nearest machine number.
--------------
-- Adjacent --
--------------
function Adjacent (RT : R; X, Towards : T) return T is
begin
if Towards = X then
return X;
elsif Towards > X then
return Succ (RT, X);
else
return Pred (RT, X);
end if;
end Adjacent;
-------------
-- Ceiling --
-------------
function Ceiling (RT : R; X : T) return T is
XT : constant T := Truncation (RT, X);
begin
if UR_Is_Negative (X) then
return XT;
elsif X = XT then
return X;
else
return XT + Ureal_1;
end if;
end Ceiling;
-------------
-- Compose --
-------------
function Compose (RT : R; Fraction : T; Exponent : UI) return T is
Arg_Frac : T;
Arg_Exp : UI;
pragma Warnings (Off, Arg_Exp);
begin
Decompose (RT, Fraction, Arg_Frac, Arg_Exp);
return Scaling (RT, Arg_Frac, Exponent);
end Compose;
---------------
-- Copy_Sign --
---------------
function Copy_Sign (RT : R; Value, Sign : T) return T is
pragma Warnings (Off, RT);
Result : T;
begin
Result := abs Value;
if UR_Is_Negative (Sign) then
return -Result;
else
return Result;
end if;
end Copy_Sign;
---------------
-- Decompose --
---------------
procedure Decompose
(RT : R;
X : T;
Fraction : out T;
Exponent : out UI;
Mode : Rounding_Mode := Round)
is
Int_F : UI;
begin
Decompose_Int (RT, abs X, Int_F, Exponent, Mode);
Fraction := UR_From_Components
(Num => Int_F,
Den => Machine_Mantissa_Value (RT),
Rbase => Radix,
Negative => False);
if UR_Is_Negative (X) then
Fraction := -Fraction;
end if;
return;
end Decompose;
-------------------
-- Decompose_Int --
-------------------
-- This procedure should be modified with care, as there are many non-
-- obvious details that may cause problems that are hard to detect. For
-- zero arguments, Fraction and Exponent are set to zero. Note that sign
-- of zero cannot be preserved.
procedure Decompose_Int
(RT : R;
X : T;
Fraction : out UI;
Exponent : out UI;
Mode : Rounding_Mode)
is
Base : Int := Rbase (X);
N : UI := abs Numerator (X);
D : UI := Denominator (X);
N_Times_Radix : UI;
Even : Boolean;
-- True iff Fraction is even
Most_Significant_Digit : constant UI :=
Radix ** (Machine_Mantissa_Value (RT) - 1);
Uintp_Mark : Uintp.Save_Mark;
-- The code is divided into blocks that systematically release
-- intermediate values (this routine generates lots of junk).
begin
if N = Uint_0 then
Fraction := Uint_0;
Exponent := Uint_0;
return;
end if;
Calculate_D_And_Exponent_1 : begin
Uintp_Mark := Mark;
Exponent := Uint_0;
-- In cases where Base > 1, the actual denominator is Base**D. For
-- cases where Base is a power of Radix, use the value 1 for the
-- Denominator and adjust the exponent.
-- Note: Exponent has different sign from D, because D is a divisor
for Power in 1 .. Radix_Powers'Last loop
if Base = Radix_Powers (Power) then
Exponent := -D * Power;
Base := 0;
D := Uint_1;
exit;
end if;
end loop;
Release_And_Save (Uintp_Mark, D, Exponent);
end Calculate_D_And_Exponent_1;
if Base > 0 then
Calculate_Exponent : begin
Uintp_Mark := Mark;
-- For bases that are a multiple of the Radix, divide the base by
-- Radix and adjust the Exponent. This will help because D will be
-- much smaller and faster to process.
-- This occurs for decimal bases on machines with binary floating-
-- point for example. When calculating 1E40, with Radix = 2, N
-- will be 93 bits instead of 133.
-- N E
-- ------ * Radix
-- D
-- Base
-- N E
-- = -------------------------- * Radix
-- D D
-- (Base/Radix) * Radix
-- N E-D
-- = --------------- * Radix
-- D
-- (Base/Radix)
-- This code is commented out, because it causes numerous
-- failures in the regression suite. To be studied ???
while False and then Base > 0 and then Base mod Radix = 0 loop
Base := Base / Radix;
Exponent := Exponent + D;
end loop;
Release_And_Save (Uintp_Mark, Exponent);
end Calculate_Exponent;
-- For remaining bases we must actually compute the exponentiation
-- Because the exponentiation can be negative, and D must be integer,
-- the numerator is corrected instead.
Calculate_N_And_D : begin
Uintp_Mark := Mark;
if D < 0 then
N := N * Base ** (-D);
D := Uint_1;
else
D := Base ** D;
end if;
Release_And_Save (Uintp_Mark, N, D);
end Calculate_N_And_D;
Base := 0;
end if;
-- Now scale N and D so that N / D is a value in the interval [1.0 /
-- Radix, 1.0) and adjust Exponent accordingly, so the value N / D *
-- Radix ** Exponent remains unchanged.
-- Step 1 - Adjust N so N / D >= 1 / Radix, or N = 0
-- N and D are positive, so N / D >= 1 / Radix implies N * Radix >= D.
-- As this scaling is not possible for N is Uint_0, zero is handled
-- explicitly at the start of this subprogram.
Calculate_N_And_Exponent : begin
Uintp_Mark := Mark;
N_Times_Radix := N * Radix;
while not (N_Times_Radix >= D) loop
N := N_Times_Radix;
Exponent := Exponent - 1;
N_Times_Radix := N * Radix;
end loop;
Release_And_Save (Uintp_Mark, N, Exponent);
end Calculate_N_And_Exponent;
-- Step 2 - Adjust D so N / D < 1
-- Scale up D so N / D < 1, so N < D
Calculate_D_And_Exponent_2 : begin
Uintp_Mark := Mark;
while not (N < D) loop
-- As N / D >= 1, N / (D * Radix) will be at least 1 / Radix, so
-- the result of Step 1 stays valid
D := D * Radix;
Exponent := Exponent + 1;
end loop;
Release_And_Save (Uintp_Mark, D, Exponent);
end Calculate_D_And_Exponent_2;
-- Here the value N / D is in the range [1.0 / Radix .. 1.0)
-- Now find the fraction by doing a very simple-minded division until
-- enough digits have been computed.
-- This division works for all radices, but is only efficient for a
-- binary radix. It is just like a manual division algorithm, but
-- instead of moving the denominator one digit right, we move the
-- numerator one digit left so the numerator and denominator remain
-- integral.
Fraction := Uint_0;
Even := True;
Calculate_Fraction_And_N : begin
Uintp_Mark := Mark;
loop
while N >= D loop
N := N - D;
Fraction := Fraction + 1;
Even := not Even;
end loop;
-- Stop when the result is in [1.0 / Radix, 1.0)
exit when Fraction >= Most_Significant_Digit;
N := N * Radix;
Fraction := Fraction * Radix;
Even := True;
end loop;
Release_And_Save (Uintp_Mark, Fraction, N);
end Calculate_Fraction_And_N;
Calculate_Fraction_And_Exponent : begin
Uintp_Mark := Mark;
-- Determine correct rounding based on the remainder which is in
-- N and the divisor D. The rounding is performed on the absolute
-- value of X, so Ceiling and Floor need to check for the sign of
-- X explicitly.
case Mode is
when Round_Even =>
-- This rounding mode corresponds to the unbiased rounding
-- method that is used at run time. When the real value is
-- exactly between two machine numbers, choose the machine
-- number with its least significant bit equal to zero.
-- The recommendation advice in RM 4.9(38) is that static
-- expressions are rounded to machine numbers in the same
-- way as the target machine does.
if (Even and then N * 2 > D)
or else
(not Even and then N * 2 >= D)
then
Fraction := Fraction + 1;
end if;
when Round =>
-- Do not round to even as is done with IEEE arithmetic, but
-- instead round away from zero when the result is exactly
-- between two machine numbers. This biased rounding method
-- should not be used to convert static expressions to
-- machine numbers, see AI95-268.
if N * 2 >= D then
Fraction := Fraction + 1;
end if;
when Ceiling =>
if N > Uint_0 and then not UR_Is_Negative (X) then
Fraction := Fraction + 1;
end if;
when Floor =>
if N > Uint_0 and then UR_Is_Negative (X) then
Fraction := Fraction + 1;
end if;
end case;
-- The result must be normalized to [1.0/Radix, 1.0), so adjust if
-- the result is 1.0 because of rounding.
if Fraction = Most_Significant_Digit * Radix then
Fraction := Most_Significant_Digit;
Exponent := Exponent + 1;
end if;
-- Put back sign after applying the rounding
if UR_Is_Negative (X) then
Fraction := -Fraction;
end if;
Release_And_Save (Uintp_Mark, Fraction, Exponent);
end Calculate_Fraction_And_Exponent;
end Decompose_Int;
--------------
-- Exponent --
--------------
function Exponent (RT : R; X : T) return UI is
X_Frac : UI;
X_Exp : UI;
pragma Warnings (Off, X_Frac);
begin
Decompose_Int (RT, X, X_Frac, X_Exp, Round_Even);
return X_Exp;
end Exponent;
-----------
-- Floor --
-----------
function Floor (RT : R; X : T) return T is
XT : constant T := Truncation (RT, X);
begin
if UR_Is_Positive (X) then
return XT;
elsif XT = X then
return X;
else
return XT - Ureal_1;
end if;
end Floor;
--------------
-- Fraction --
--------------
function Fraction (RT : R; X : T) return T is
X_Frac : T;
X_Exp : UI;
pragma Warnings (Off, X_Exp);
begin
Decompose (RT, X, X_Frac, X_Exp);
return X_Frac;
end Fraction;
------------------
-- Leading_Part --
------------------
function Leading_Part (RT : R; X : T; Radix_Digits : UI) return T is
RD : constant UI := UI_Min (Radix_Digits, Machine_Mantissa_Value (RT));
L : UI;
Y : T;
begin
L := Exponent (RT, X) - RD;
Y := UR_From_Uint (UR_Trunc (Scaling (RT, X, -L)));
return Scaling (RT, Y, L);
end Leading_Part;
-------------
-- Machine --
-------------
function Machine
(RT : R;
X : T;
Mode : Rounding_Mode;
Enode : Node_Id) return T
is
X_Frac : T;
X_Exp : UI;
Emin : constant UI := Machine_Emin_Value (RT);
begin
Decompose (RT, X, X_Frac, X_Exp, Mode);
-- Case of denormalized number or (gradual) underflow
-- A denormalized number is one with the minimum exponent Emin, but that
-- breaks the assumption that the first digit of the mantissa is a one.
-- This allows the first non-zero digit to be in any of the remaining
-- Mant - 1 spots. The gap between subsequent denormalized numbers is
-- the same as for the smallest normalized numbers. However, the number
-- of significant digits left decreases as a result of the mantissa now
-- having leading seros.
if X_Exp < Emin then
declare
Emin_Den : constant UI := Machine_Emin_Value (RT)
- Machine_Mantissa_Value (RT) + Uint_1;
begin
if X_Exp < Emin_Den or not Has_Denormals (RT) then
if Has_Signed_Zeros (RT) and then UR_Is_Negative (X) then
Error_Msg_N
("floating-point value underflows to -0.0??", Enode);
return Ureal_M_0;
else
Error_Msg_N
("floating-point value underflows to 0.0??", Enode);
return Ureal_0;
end if;
elsif Has_Denormals (RT) then
-- Emin - Mant <= X_Exp < Emin, so result is denormal. Handle
-- gradual underflow by first computing the number of
-- significant bits still available for the mantissa and
-- then truncating the fraction to this number of bits.
-- If this value is different from the original fraction,
-- precision is lost due to gradual underflow.
-- We probably should round here and prevent double rounding as
-- a result of first rounding to a model number and then to a
-- machine number. However, this is an extremely rare case that
-- is not worth the extra complexity. In any case, a warning is
-- issued in cases where gradual underflow occurs.
declare
Denorm_Sig_Bits : constant UI := X_Exp - Emin_Den + 1;
X_Frac_Denorm : constant T := UR_From_Components
(UR_Trunc (Scaling (RT, abs X_Frac, Denorm_Sig_Bits)),
Denorm_Sig_Bits,
Radix,
UR_Is_Negative (X));
begin
if X_Frac_Denorm /= X_Frac then
Error_Msg_N
("gradual underflow causes loss of precision??",
Enode);
X_Frac := X_Frac_Denorm;
end if;
end;
end if;
end;
end if;
return Scaling (RT, X_Frac, X_Exp);
end Machine;
-----------
-- Model --
-----------
function Model (RT : R; X : T) return T is
X_Frac : T;
X_Exp : UI;
begin
Decompose (RT, X, X_Frac, X_Exp);
return Compose (RT, X_Frac, X_Exp);
end Model;
----------
-- Pred --
----------
function Pred (RT : R; X : T) return T is
begin
return -Succ (RT, -X);
end Pred;
---------------
-- Remainder --
---------------
function Remainder (RT : R; X, Y : T) return T is
A : T;
B : T;
Arg : T;
P : T;
Arg_Frac : T;
P_Frac : T;
Sign_X : T;
IEEE_Rem : T;
Arg_Exp : UI;
P_Exp : UI;
K : UI;
P_Even : Boolean;
pragma Warnings (Off, Arg_Frac);
begin
if UR_Is_Positive (X) then
Sign_X := Ureal_1;
else
Sign_X := -Ureal_1;
end if;
Arg := abs X;
P := abs Y;
if Arg < P then
P_Even := True;
IEEE_Rem := Arg;
P_Exp := Exponent (RT, P);
else
-- ??? what about zero cases?
Decompose (RT, Arg, Arg_Frac, Arg_Exp);
Decompose (RT, P, P_Frac, P_Exp);
P := Compose (RT, P_Frac, Arg_Exp);
K := Arg_Exp - P_Exp;
P_Even := True;
IEEE_Rem := Arg;
for Cnt in reverse 0 .. UI_To_Int (K) loop
if IEEE_Rem >= P then
P_Even := False;
IEEE_Rem := IEEE_Rem - P;
else
P_Even := True;
end if;
P := P * Ureal_Half;
end loop;
end if;
-- That completes the calculation of modulus remainder. The final step
-- is get the IEEE remainder. Here we compare Rem with (abs Y) / 2.
if P_Exp >= 0 then
A := IEEE_Rem;
B := abs Y * Ureal_Half;
else
A := IEEE_Rem * Ureal_2;
B := abs Y;
end if;
if A > B or else (A = B and then not P_Even) then
IEEE_Rem := IEEE_Rem - abs Y;
end if;
return Sign_X * IEEE_Rem;
end Remainder;
--------------
-- Rounding --
--------------
function Rounding (RT : R; X : T) return T is
Result : T;
Tail : T;
begin
Result := Truncation (RT, abs X);
Tail := abs X - Result;
if Tail >= Ureal_Half then
Result := Result + Ureal_1;
end if;
if UR_Is_Negative (X) then
return -Result;
else
return Result;
end if;
end Rounding;
-------------
-- Scaling --
-------------
function Scaling (RT : R; X : T; Adjustment : UI) return T is
pragma Warnings (Off, RT);
begin
if Rbase (X) = Radix then
return UR_From_Components
(Num => Numerator (X),
Den => Denominator (X) - Adjustment,
Rbase => Radix,
Negative => UR_Is_Negative (X));
elsif Adjustment >= 0 then
return X * Radix ** Adjustment;
else
return X / Radix ** (-Adjustment);
end if;
end Scaling;
----------
-- Succ --
----------
function Succ (RT : R; X : T) return T is
Emin : constant UI := Machine_Emin_Value (RT);
Mantissa : constant UI := Machine_Mantissa_Value (RT);
Exp : UI := UI_Max (Emin, Exponent (RT, X));
Frac : T;
New_Frac : T;
begin
if UR_Is_Zero (X) then
Exp := Emin;
end if;
-- Set exponent such that the radix point will be directly following the
-- mantissa after scaling.
if Has_Denormals (RT) or Exp /= Emin then
Exp := Exp - Mantissa;
else
Exp := Exp - 1;
end if;
Frac := Scaling (RT, X, -Exp);
New_Frac := Ceiling (RT, Frac);
if New_Frac = Frac then
if New_Frac = Scaling (RT, -Ureal_1, Mantissa - 1) then
New_Frac := New_Frac + Scaling (RT, Ureal_1, Uint_Minus_1);
else
New_Frac := New_Frac + Ureal_1;
end if;
end if;
return Scaling (RT, New_Frac, Exp);
end Succ;
----------------
-- Truncation --
----------------
function Truncation (RT : R; X : T) return T is
pragma Warnings (Off, RT);
begin
return UR_From_Uint (UR_Trunc (X));
end Truncation;
-----------------------
-- Unbiased_Rounding --
-----------------------
function Unbiased_Rounding (RT : R; X : T) return T is
Abs_X : constant T := abs X;
Result : T;
Tail : T;
begin
Result := Truncation (RT, Abs_X);
Tail := Abs_X - Result;
if Tail > Ureal_Half then
Result := Result + Ureal_1;
elsif Tail = Ureal_Half then
Result := Ureal_2 *
Truncation (RT, (Result / Ureal_2) + Ureal_Half);
end if;
if UR_Is_Negative (X) then
return -Result;
elsif UR_Is_Positive (X) then
return Result;
-- For zero case, make sure sign of zero is preserved
else
return X;
end if;
end Unbiased_Rounding;
end Eval_Fat;
|
package body Entities is
procedure Initialize(This : out Entity; EntType : in EntityTypes;
Pos, Vel, Grav : in Vec2D; Mat : in Material)
is
begin
This.EntityType := EntType;
This.Coords := Pos;
This.Velocity := Vel;
This.Force := Vec2D'(x => 0.0, y => 0.0);
This.InvMass := 0.0; -- needs to be set for each entity with ComputeMass
This.Mass := 0.0; -- needs to be set for each entity with ComputeMass
This.Mat := Mat;
This.Gravity := Grav;
end Initialize;
procedure ChangeMaterial(This : in out Entity'Class; NewMat : Material)
is
begin
This.Mat := NewMat;
This.ComputeMass;
end ChangeMaterial;
function GetDistance(A, B : in Entity'Class) return Float
is
begin
return Mag(B.GetPosition - A.GetPosition);
end GetDistance;
procedure ApplyForce(This : in out Entity; Force : Vec2D)
is
begin
This.Force := This.Force + Force;
end ApplyForce;
procedure SetGravity(This : in out Entity; Grav : Vec2D)
is
begin
This.Gravity := Grav;
end SetGravity;
procedure SetLayer(This : in out Entity; Lay : Byte)
is
begin
This.Layer := Lay;
end SetLayer;
procedure AddLayer(This : in out Entity; Lay : Byte)
is
begin
This.Layer := This.Layer or Lay;
end AddLayer;
end Entities;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package body GL.Helpers is
function Float_Array (Value : Colors.Color) return Low_Level.Single_Array is
use GL.Types.Colors;
begin
return Low_Level.Single_Array'(1 => Value (R),
2 => Value (G),
3 => Value (B),
4 => Value (A));
end Float_Array;
function Color (Value : Low_Level.Single_Array) return Colors.Color is
use GL.Types.Colors;
begin
return Colors.Color'(R => Value (1), G => Value (2), B => Value (3),
A => Value (4));
end Color;
end GL.Helpers;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2016, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with AUnit.Assertions; use AUnit.Assertions;
with Keccak.Generic_KeccakF.Optimized_Permutation;
with Keccak.Generic_KeccakF.Reference_Permutation;
package body KeccakF_Tests
is
use type Keccak.Types.Byte_Array;
procedure Set_Up(T : in out Test)
is
begin
KeccakF.Init(T.State);
end Set_Up;
-- Tests that the initial state is all zeroes.
--
-- According to The Keccak Reference, Section 1.3, the initial state (the
-- "root state" is all zeroes).
procedure Test_Initial_State(T : in out Test)
is
State_Bytes : Keccak.Types.Byte_Array(1 .. KeccakF.State_Size_Bits/8);
-- The initial state is expected to be all zeroes.
Expected_State : Keccak.Types.Byte_Array(1 .. KeccakF.State_Size_Bits/8) := (others => 0);
begin
Extract_Bytes(T.State, State_Bytes);
Assert(State_Bytes = Expected_State,
"Initial state is not all zeroes");
end Test_Initial_State;
-- Test that the XOR_Bits_Into_State procedure does not change the
-- state when Bit_Len = 0.
procedure Test_XOR_No_Data(T : in out Test)
is
Empty_Array : Keccak.Types.Byte_Array(0 .. -1) := (others => 0);
Pre_State : Keccak.Types.Byte_Array(1 .. KeccakF.State_Size_Bits/8);
Post_State : Keccak.Types.Byte_Array(1 .. KeccakF.State_Size_Bits/8);
begin
Extract_Bytes(T.State, Pre_State);
XOR_Bits_Into_State(T.State, Empty_Array, 0);
Extract_Bytes(T.State, Post_State);
Assert(Pre_State = Post_State,
"The state was changed after XOR'ing 0 bits");
end Test_XOR_No_Data;
-- Test that XOR_Bits_Into_State works for each independent byte
-- in the state.
procedure Test_XOR_Entire_State(T : in out Test)
is
use type Keccak.Types.Byte;
Data_To_XOR : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7)/8);
Result : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7)/8);
begin
-- Setup the data with a sequence: 1, 2, 3, 4, 5, ...
-- This allows us to check that each byte is not affected by other bytes.
for I in Natural range 0 .. Data_To_XOR'Length - 1 loop
Data_To_XOR(Data_To_XOR'First + I) := Keccak.Types.Byte(I + 1);
end loop;
if KeccakF.State_Size_Bits mod 8 /= 0 then
Data_To_XOR(Data_To_XOR'Last) := Data_To_XOR(Data_To_XOR'Last) and (2**(KeccakF.State_Size_Bits mod 8) - 1);
end if;
-- XOR in the data. After XOR'ing with a zero state we should end up
-- with the same data after reading the Keccak state.
XOR_Bits_Into_State(T.State, Data_To_XOR, KeccakF.State_Size_Bits);
Extract_Bytes(T.State, Result);
for I in Data_To_XOR'Range loop
Assert(Result(I) = Data_To_XOR(I),
"Expected byte at index" & Positive'Image(I) &
" to be" & Keccak.Types.Byte'Image(Data_To_XOR(I)) &
", but instead got:" & Keccak.Types.Byte'Image(Result(I)));
end loop;
end Test_XOR_Entire_State;
-- This test loops for data whose length is in the range 1 .. 1600.
-- For each iteration, the test XORs in the data, and then reads the
-- data and checks that the Keccak state is correct after XORing.
procedure Test_XOR_Bit_Length(T : in out Test)
is
use type Keccak.Types.Byte;
Data_To_XOR : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8)
:= (others => 2#1111_1111#);
Result : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
Expected_Last_Byte : Keccak.Types.Byte;
Last_Byte : Keccak.Types.Byte;
begin
for I in Positive range 1 .. KeccakF.State_Size_Bits loop
KeccakF.Init(T.State);
XOR_Bits_Into_State(T.State, Data_To_XOR, I);
Result := (others => 0);
Extract_Bytes(T.State, Result);
-- Whole bytes
for J in Positive range 1 .. ((I + 7) / 8) - 1 loop
Assert(Result(J) = 255,
"After XORing" & Positive'Image(I) &
" bits, expected byte at index" & Positive'Image(J) &
" to be 255, but instead got:" & Keccak.Types.Byte'Image(Result(J)));
end loop;
-- Last byte, if we don't expect it to be 2#1111_1111#
if I mod 8 /= 0 then
Expected_Last_Byte := (2**(I mod 8) - 1);
Last_Byte := Result((I + 7) / 8);
Assert(Last_Byte = Expected_Last_Byte,
"After XORing" & Positive'Image(I) &
" bits, expected last byte to be" & Keccak.Types.Byte'Image(Expected_Last_Byte) &
", but instead got:" & Keccak.Types.Byte'Image(Last_Byte));
end if;
-- Check that the remaining bytes are 0.
for J in Positive range ((I + 7) / 8) + 1 .. Result'Last loop
Assert(Result(J) = 0,
"After XORing " & Positive'Image(I) &
" bits, expected byte at index" & Positive'Image(J) &
" to be 0, but instead got: " & Keccak.Types.Byte'Image(Result(J)));
end loop;
end loop;
end Test_XOR_Bit_Length;
-- This procedure tests that Extract_Bytes reads the correct number of bytes
-- for all possible lengths;
procedure Test_Extract_Bytes(T : in out Test)
is
use type Keccak.Types.Byte;
Data : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
Result : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
begin
-- Initialize each value in 'Data' with a unique value
-- and setup the keccak state with the data
for I in Positive range 1 .. (KeccakF.State_Size_Bits + 7) / 8 loop
Data(I) := Keccak.Types.Byte(I);
end loop;
XOR_Bits_Into_State(T.State, Data, KeccakF.State_Size_Bits);
-- Now call Extract_Bytes for all possible output lengths,
-- checking that the correct data is returned.
for I in Natural range 0 .. KeccakF.State_Size_Bits / 8 loop
Result := (others => 0);
Extract_Bytes(T.State, Result(1 .. I));
for J in Natural range 1 .. I loop
Assert(Result(J) = Data(J),
"Expected byte at index" & Natural'Image(J) &
" to be " & Keccak.Types.Byte'Image(Data(J)) &
", but instead got: " & Keccak.Types.Byte'Image(Result(J)));
end loop;
for J in Natural range I+1 .. KeccakF.State_Size_Bits / 8 loop
Assert(Result(J) = 0,
"Expected byte at index" & Natural'Image(J) &
" to be 0, but instead got: " & Keccak.Types.Byte'Image(Result(J)));
end loop;
end loop;
end Test_Extract_Bytes;
-- Test that Extract_Bits and Extract_Bytes have the same output for
-- all possible byte lengths.
--
-- Extract_Bits should behave exactly the same as Extract_Bytes when
-- the bit length is a multiple of 8.
procedure Test_Extract_Bits_Same_As_Extract_Bytes(T : in out Test)
is
use type Keccak.Types.Byte;
Data : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
Bytes_Result : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
Bits_Result : Keccak.Types.Byte_Array(1 .. (KeccakF.State_Size_Bits + 7) / 8);
begin
-- Initialize each value in 'Data' with a unique value
-- and setup the keccak state with the data
for I in Positive range 1 .. (KeccakF.State_Size_Bits + 7) / 8 loop
Data(I) := Keccak.Types.Byte(I);
end loop;
XOR_Bits_Into_State(T.State, Data, KeccakF.State_Size_Bits);
-- Now call Extract_Bytes for all possible output lengths,
-- checking that the correct data is returned.
for I in Natural range 0 .. KeccakF.State_Size_Bits / 8 loop
Bits_Result := (others => 0);
Bytes_Result := (others => 16#FF#);
Extract_Bytes(T.State, Bytes_Result(1 .. I));
Extract_Bits(T.State, Bits_Result(1 .. I), I*8);
Assert(Bytes_Result(1 .. I) = Bits_Result(1 .. I),
"Extract_Bits and Extract_Bytes have different output for " &
"length" & Integer'Image(I));
end loop;
end Test_Extract_Bits_Same_As_Extract_Bytes;
-- Test that the reference and optimized permutation functions
-- produce the same output.
procedure Test_Permute_Implementations (T : in out Test)
is
use type KeccakF.State;
package R_Permutation is new KeccakF.Reference_Permutation;
package O_Permutation is new KeccakF.Optimized_Permutation;
procedure R_Permute is new R_Permutation.Permute;
procedure O_Permute is new O_Permutation.Permute;
R_State : KeccakF.State;
O_State : KeccakF.State;
begin
KeccakF.Init (R_State);
KeccakF.Init (O_State);
for N in 1 .. 1_000 loop
R_Permute (R_State);
O_Permute (O_State);
Assert (R_State = O_State,
"States are not equal after " & Integer'Image (N) & " permutations") ;
end loop;
end Test_Permute_Implementations;
end KeccakF_Tests;
|
-- Generated from GL/gl.h
-- Date: Wed Sep 22 12:47:08 1999
--
with Interfaces.C;
with Interfaces.C.Extensions;
package gl_h is
-- $Id: gl_h.ads,v 1.1.1.1 2002/08/30 01:09:56 afvargas Exp $
--
-- Mesa 3-D graphics library
-- Version: 3.0
-- Copyright (C) 1995-1998 Brian Paul
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Library General Public
-- License as published by the Free Software Foundation; either
-- version 2 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Library General Public License for more details.
--
-- You should have received a copy of the GNU Library General Public
-- License along with this library; if not, write to the Free
-- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--
--
-- $Log: gl_h.ads,v $
-- Revision 1.1.1.1 2002/08/30 01:09:56 afvargas
--
--
-- Revision 1.1.1.1 2001/04/11 01:21:45 afvargas
--
--
-- Revision 1.1 1999/09/24 08:37:14 briot
-- These two files provide a very basic binding to the openGL library (they
-- were generated from the Mesa files). These are mainly provided as examples,
-- not as a full binding
--
-- Revision 3.19 1998/07/31 03:23:36 brianp
-- Added Ted Jump's latest Win32 changes
--
-- Revision 3.18 1998/07/26 03:10:28 brianp
-- added defines for non-Windows compilation!
--
-- Revision 3.17 1998/07/26 01:38:39 brianp
-- updated for Windows compilation per Ted Jump
--
-- Revision 3.16 1998/07/18 02:43:07 brianp
-- added missing enums: GL_SELECTION_BUFFER_POINTER, GL_SELECTION_BUFFER_SIZE
-- added missing enums: GL_TEXTURE_INTERNAL_FORMAT
--
-- Revision 3.15 1998/06/07 22:17:58 brianp
-- added GL_EXT_multitexture extension
--
-- Revision 3.14 1998/04/01 03:01:20 brianp
-- added void parameter to glResizeBuffersMESA()
--
-- Revision 3.13 1998/03/19 02:03:51 brianp
-- added GL_SGIS_texture_edge_clamp
--
-- Revision 3.12 1998/03/15 18:48:55 brianp
-- added GL_EXT_abgr extension
--
-- Revision 3.11 1998/02/28 15:15:05 brianp
-- added official enum values for some constants
--
-- Revision 3.10 1998/02/20 04:54:45 brianp
-- implemented GL_SGIS_multitexture
--
-- Revision 3.9 1998/02/10 03:31:31 brianp
-- added static Win32 lib support (Theodore Jump)
--
-- Revision 3.8 1998/02/06 01:57:42 brianp
-- added GL 1.2 3-D texture enums and functions
--
-- Revision 3.7 1998/02/03 04:27:54 brianp
-- added texture lod clamping
--
-- Revision 3.6 1998/02/02 03:09:34 brianp
-- added GL_LIGHT_MODEL_COLOR_CONTROL (separate specular color interpolation)
--
-- Revision 3.5 1998/02/01 22:29:09 brianp
-- added support for packed pixel formats
--
-- Revision 3.4 1998/02/01 20:47:42 brianp
-- added GL_BGR and GL_BGRA pixel formats
--
-- Revision 3.3 1998/02/01 20:05:10 brianp
-- added glDrawRangeElements()
--
-- Revision 3.2 1998/02/01 19:39:36 brianp
-- added GL_CLAMP_TO_EDGE texture wrap mode
--
-- Revision 3.1 1998/02/01 16:36:47 brianp
-- added GL_EXT_rescale_normal extension
--
-- Revision 3.0 1998/02/01 16:03:04 brianp
-- initial rev
--
-- '=' : conversion from 'const double ' to 'float ', possible loss of data
-- '<' : signed/unsigned mismatch
-- '=' : truncation from 'const double ' to 'float '
-- 'function' undefined; assuming extern returning int
-- integral size mismatch in argument; conversion supplied
-- 'identifier' : inconsistent DLL linkage. dllexport assumed
-- unary minus operator applied to unsigned type, result still unsigned
-- tag specifying we're building for DLL runtime support
-- non-Windows compilation
--
-- Apps can test for this symbol to do conditional compilation if needed.
--
MESA_MAJOR_VERSION : constant := 3;
MESA_MINOR_VERSION : constant := 0;
GL_VERSION_1_1 : constant := 1;
GL_VERSION_1_2 : constant := 1;
--
-- Enumerations
--
-- Boolean values
-- Data types
-- Primitives
-- Vertex Arrays
-- Matrix Mode
-- Points
-- Lines
-- Polygons
-- Display Lists
-- Depth buffer
-- Lighting
-- User clipping planes
-- Accumulation buffer
-- Alpha testing
-- Blending
-- Render Mode
-- Feedback
-- Selection
-- Fog
-- Logic Ops
-- Stencil
-- Buffers, Pixel Drawing/Reading
-- GL_FRONT = 0x0404,
-- GL_BACK = 0x0405,
-- GL_FRONT_AND_BACK = 0x0408,
-- Implementation limits
-- Gets
-- Evaluators
-- Hints
-- Scissor box
-- Pixel Mode / Transfer
-- Texture mapping
-- GL 1.1 texturing
-- GL 1.2 texturing
-- Internal texture formats (GL 1.1)
-- Utility
-- Errors
--
-- Extensions
--
-- GL_EXT_blend_minmax and GL_EXT_blend_color
-- GL_EXT_polygon_offset
-- GL_EXT_vertex_array
-- GL_EXT_texture_object
-- GL_EXT_texture3D
-- GL_EXT_paletted_texture
-- GL_EXT_shared_texture_palette
-- GL_EXT_point_parameters
-- GL_EXT_rescale_normal
-- GL_EXT_abgr
-- GL_SGIS_multitexture
-- GL_EXT_multitexture
-- GL_SGIS_texture_edge_clamp
-- OpenGL 1.2
-- CenterLine C++ workaround:
-- all other compilers
type GLenum is new Integer;
for GLenum 'Size use 32;
GL_FALSE : constant GLenum := 0;
GL_TRUE : constant GLenum := 1;
GL_BYTE : constant GLenum := 5120;
GL_UNSIGNED_BYTE : constant GLenum := 5121;
GL_SHORT : constant GLenum := 5122;
GL_UNSIGNED_SHORT : constant GLenum := 5123;
GL_INT : constant GLenum := 5124;
GL_UNSIGNED_INT : constant GLenum := 5125;
GL_FLOAT : constant GLenum := 5126;
GL_2_BYTES : constant GLenum := 5127;
GL_3_BYTES : constant GLenum := 5128;
GL_4_BYTES : constant GLenum := 5129;
GL_DOUBLE : constant GLenum := 5130;
GL_LINES : constant GLenum := 1;
GL_POINTS : constant GLenum := 0;
GL_LINE_STRIP : constant GLenum := 3;
GL_LINE_LOOP : constant GLenum := 2;
GL_TRIANGLES : constant GLenum := 4;
GL_TRIANGLE_STRIP : constant GLenum := 5;
GL_TRIANGLE_FAN : constant GLenum := 6;
GL_QUADS : constant GLenum := 7;
GL_QUAD_STRIP : constant GLenum := 8;
GL_POLYGON : constant GLenum := 9;
GL_EDGE_FLAG : constant GLenum := 2883;
GL_VERTEX_ARRAY : constant GLenum := 32884;
GL_NORMAL_ARRAY : constant GLenum := 32885;
GL_COLOR_ARRAY : constant GLenum := 32886;
GL_INDEX_ARRAY : constant GLenum := 32887;
GL_TEXTURE_COORD_ARRAY : constant GLenum := 32888;
GL_EDGE_FLAG_ARRAY : constant GLenum := 32889;
GL_VERTEX_ARRAY_SIZE : constant GLenum := 32890;
GL_VERTEX_ARRAY_TYPE : constant GLenum := 32891;
GL_VERTEX_ARRAY_STRIDE : constant GLenum := 32892;
GL_NORMAL_ARRAY_TYPE : constant GLenum := 32894;
GL_NORMAL_ARRAY_STRIDE : constant GLenum := 32895;
GL_COLOR_ARRAY_SIZE : constant GLenum := 32897;
GL_COLOR_ARRAY_TYPE : constant GLenum := 32898;
GL_COLOR_ARRAY_STRIDE : constant GLenum := 32899;
GL_INDEX_ARRAY_TYPE : constant GLenum := 32901;
GL_INDEX_ARRAY_STRIDE : constant GLenum := 32902;
GL_TEXTURE_COORD_ARRAY_SIZE : constant GLenum := 32904;
GL_TEXTURE_COORD_ARRAY_TYPE : constant GLenum := 32905;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant GLenum := 32906;
GL_EDGE_FLAG_ARRAY_STRIDE : constant GLenum := 32908;
GL_VERTEX_ARRAY_POINTER : constant GLenum := 32910;
GL_NORMAL_ARRAY_POINTER : constant GLenum := 32911;
GL_COLOR_ARRAY_POINTER : constant GLenum := 32912;
GL_INDEX_ARRAY_POINTER : constant GLenum := 32913;
GL_TEXTURE_COORD_ARRAY_POINTER : constant GLenum := 32914;
GL_EDGE_FLAG_ARRAY_POINTER : constant GLenum := 32915;
GL_V2F : constant GLenum := 10784;
GL_V3F : constant GLenum := 10785;
GL_C4UB_V2F : constant GLenum := 10786;
GL_C4UB_V3F : constant GLenum := 10787;
GL_C3F_V3F : constant GLenum := 10788;
GL_N3F_V3F : constant GLenum := 10789;
GL_C4F_N3F_V3F : constant GLenum := 10790;
GL_T2F_V3F : constant GLenum := 10791;
GL_T4F_V4F : constant GLenum := 10792;
GL_T2F_C4UB_V3F : constant GLenum := 10793;
GL_T2F_C3F_V3F : constant GLenum := 10794;
GL_T2F_N3F_V3F : constant GLenum := 10795;
GL_T2F_C4F_N3F_V3F : constant GLenum := 10796;
GL_T4F_C4F_N3F_V4F : constant GLenum := 10797;
GL_MATRIX_MODE : constant GLenum := 2976;
GL_MODELVIEW : constant GLenum := 5888;
GL_PROJECTION : constant GLenum := 5889;
GL_TEXTURE : constant GLenum := 5890;
GL_POINT_SMOOTH : constant GLenum := 2832;
GL_POINT_SIZE : constant GLenum := 2833;
GL_POINT_SIZE_GRANULARITY : constant GLenum := 2835;
GL_POINT_SIZE_RANGE : constant GLenum := 2834;
GL_LINE_SMOOTH : constant GLenum := 2848;
GL_LINE_STIPPLE : constant GLenum := 2852;
GL_LINE_STIPPLE_PATTERN : constant GLenum := 2853;
GL_LINE_STIPPLE_REPEAT : constant GLenum := 2854;
GL_LINE_WIDTH : constant GLenum := 2849;
GL_LINE_WIDTH_GRANULARITY : constant GLenum := 2851;
GL_LINE_WIDTH_RANGE : constant GLenum := 2850;
GL_POINT : constant GLenum := 6912;
GL_LINE : constant GLenum := 6913;
GL_FILL : constant GLenum := 6914;
GL_CCW : constant GLenum := 2305;
GL_CW : constant GLenum := 2304;
GL_FRONT : constant GLenum := 1028;
GL_BACK : constant GLenum := 1029;
GL_CULL_FACE : constant GLenum := 2884;
GL_CULL_FACE_MODE : constant GLenum := 2885;
GL_POLYGON_SMOOTH : constant GLenum := 2881;
GL_POLYGON_STIPPLE : constant GLenum := 2882;
GL_FRONT_FACE : constant GLenum := 2886;
GL_POLYGON_MODE : constant GLenum := 2880;
GL_POLYGON_OFFSET_FACTOR : constant GLenum := 32824;
GL_POLYGON_OFFSET_UNITS : constant GLenum := 10752;
GL_POLYGON_OFFSET_POINT : constant GLenum := 10753;
GL_POLYGON_OFFSET_LINE : constant GLenum := 10754;
GL_POLYGON_OFFSET_FILL : constant GLenum := 32823;
GL_COMPILE : constant GLenum := 4864;
GL_COMPILE_AND_EXECUTE : constant GLenum := 4865;
GL_LIST_BASE : constant GLenum := 2866;
GL_LIST_INDEX : constant GLenum := 2867;
GL_LIST_MODE : constant GLenum := 2864;
GL_NEVER : constant GLenum := 512;
GL_LESS : constant GLenum := 513;
GL_GEQUAL : constant GLenum := 518;
GL_LEQUAL : constant GLenum := 515;
GL_GREATER : constant GLenum := 516;
GL_NOTEQUAL : constant GLenum := 517;
GL_EQUAL : constant GLenum := 514;
GL_ALWAYS : constant GLenum := 519;
GL_DEPTH_TEST : constant GLenum := 2929;
GL_DEPTH_BITS : constant GLenum := 3414;
GL_DEPTH_CLEAR_VALUE : constant GLenum := 2931;
GL_DEPTH_FUNC : constant GLenum := 2932;
GL_DEPTH_RANGE : constant GLenum := 2928;
GL_DEPTH_WRITEMASK : constant GLenum := 2930;
GL_DEPTH_COMPONENT : constant GLenum := 6402;
GL_LIGHTING : constant GLenum := 2896;
GL_LIGHT0 : constant GLenum := 16384;
GL_LIGHT1 : constant GLenum := 16385;
GL_LIGHT2 : constant GLenum := 16386;
GL_LIGHT3 : constant GLenum := 16387;
GL_LIGHT4 : constant GLenum := 16388;
GL_LIGHT5 : constant GLenum := 16389;
GL_LIGHT6 : constant GLenum := 16390;
GL_LIGHT7 : constant GLenum := 16391;
GL_SPOT_EXPONENT : constant GLenum := 4613;
GL_SPOT_CUTOFF : constant GLenum := 4614;
GL_CONSTANT_ATTENUATION : constant GLenum := 4615;
GL_LINEAR_ATTENUATION : constant GLenum := 4616;
GL_QUADRATIC_ATTENUATION : constant GLenum := 4617;
GL_AMBIENT : constant GLenum := 4608;
GL_DIFFUSE : constant GLenum := 4609;
GL_SPECULAR : constant GLenum := 4610;
GL_SHININESS : constant GLenum := 5633;
GL_EMISSION : constant GLenum := 5632;
GL_POSITION : constant GLenum := 4611;
GL_SPOT_DIRECTION : constant GLenum := 4612;
GL_AMBIENT_AND_DIFFUSE : constant GLenum := 5634;
GL_COLOR_INDEXES : constant GLenum := 5635;
GL_LIGHT_MODEL_TWO_SIDE : constant GLenum := 2898;
GL_LIGHT_MODEL_LOCAL_VIEWER : constant GLenum := 2897;
GL_LIGHT_MODEL_AMBIENT : constant GLenum := 2899;
GL_FRONT_AND_BACK : constant GLenum := 1032;
GL_SHADE_MODEL : constant GLenum := 2900;
GL_FLAT : constant GLenum := 7424;
GL_SMOOTH : constant GLenum := 7425;
GL_COLOR_MATERIAL : constant GLenum := 2903;
GL_COLOR_MATERIAL_FACE : constant GLenum := 2901;
GL_COLOR_MATERIAL_PARAMETER : constant GLenum := 2902;
GL_NORMALIZE : constant GLenum := 2977;
GL_CLIP_PLANE0 : constant GLenum := 12288;
GL_CLIP_PLANE1 : constant GLenum := 12289;
GL_CLIP_PLANE2 : constant GLenum := 12290;
GL_CLIP_PLANE3 : constant GLenum := 12291;
GL_CLIP_PLANE4 : constant GLenum := 12292;
GL_CLIP_PLANE5 : constant GLenum := 12293;
GL_ACCUM_RED_BITS : constant GLenum := 3416;
GL_ACCUM_GREEN_BITS : constant GLenum := 3417;
GL_ACCUM_BLUE_BITS : constant GLenum := 3418;
GL_ACCUM_ALPHA_BITS : constant GLenum := 3419;
GL_ACCUM_CLEAR_VALUE : constant GLenum := 2944;
GL_ACCUM : constant GLenum := 256;
GL_ADD : constant GLenum := 260;
GL_LOAD : constant GLenum := 257;
GL_MULT : constant GLenum := 259;
GL_RETURN : constant GLenum := 258;
GL_ALPHA_TEST : constant GLenum := 3008;
GL_ALPHA_TEST_REF : constant GLenum := 3010;
GL_ALPHA_TEST_FUNC : constant GLenum := 3009;
GL_BLEND : constant GLenum := 3042;
GL_BLEND_SRC : constant GLenum := 3041;
GL_BLEND_DST : constant GLenum := 3040;
GL_ZERO : constant GLenum := 0;
GL_ONE : constant GLenum := 1;
GL_SRC_COLOR : constant GLenum := 768;
GL_ONE_MINUS_SRC_COLOR : constant GLenum := 769;
GL_DST_COLOR : constant GLenum := 774;
GL_ONE_MINUS_DST_COLOR : constant GLenum := 775;
GL_SRC_ALPHA : constant GLenum := 770;
GL_ONE_MINUS_SRC_ALPHA : constant GLenum := 771;
GL_DST_ALPHA : constant GLenum := 772;
GL_ONE_MINUS_DST_ALPHA : constant GLenum := 773;
GL_SRC_ALPHA_SATURATE : constant GLenum := 776;
GL_CONSTANT_COLOR : constant GLenum := 32769;
GL_ONE_MINUS_CONSTANT_COLOR : constant GLenum := 32770;
GL_CONSTANT_ALPHA : constant GLenum := 32771;
GL_ONE_MINUS_CONSTANT_ALPHA : constant GLenum := 32772;
GL_FEEDBACK : constant GLenum := 7169;
GL_RENDER : constant GLenum := 7168;
GL_SELECT : constant GLenum := 7170;
GL_2D : constant GLenum := 1536;
GL_3D : constant GLenum := 1537;
GL_3D_COLOR : constant GLenum := 1538;
GL_3D_COLOR_TEXTURE : constant GLenum := 1539;
GL_4D_COLOR_TEXTURE : constant GLenum := 1540;
GL_POINT_TOKEN : constant GLenum := 1793;
GL_LINE_TOKEN : constant GLenum := 1794;
GL_LINE_RESET_TOKEN : constant GLenum := 1799;
GL_POLYGON_TOKEN : constant GLenum := 1795;
GL_BITMAP_TOKEN : constant GLenum := 1796;
GL_DRAW_PIXEL_TOKEN : constant GLenum := 1797;
GL_COPY_PIXEL_TOKEN : constant GLenum := 1798;
GL_PASS_THROUGH_TOKEN : constant GLenum := 1792;
GL_FEEDBACK_BUFFER_POINTER : constant GLenum := 3568;
GL_FEEDBACK_BUFFER_SIZE : constant GLenum := 3569;
GL_FEEDBACK_BUFFER_TYPE : constant GLenum := 3570;
GL_SELECTION_BUFFER_POINTER : constant GLenum := 3571;
GL_SELECTION_BUFFER_SIZE : constant GLenum := 3572;
GL_FOG : constant GLenum := 2912;
GL_FOG_MODE : constant GLenum := 2917;
GL_FOG_DENSITY : constant GLenum := 2914;
GL_FOG_COLOR : constant GLenum := 2918;
GL_FOG_INDEX : constant GLenum := 2913;
GL_FOG_START : constant GLenum := 2915;
GL_FOG_END : constant GLenum := 2916;
GL_LINEAR : constant GLenum := 9729;
GL_EXP : constant GLenum := 2048;
GL_EXP2 : constant GLenum := 2049;
GL_LOGIC_OP : constant GLenum := 3057;
GL_INDEX_LOGIC_OP : constant GLenum := 3057;
GL_COLOR_LOGIC_OP : constant GLenum := 3058;
GL_LOGIC_OP_MODE : constant GLenum := 3056;
GL_CLEAR : constant GLenum := 5376;
GL_SET : constant GLenum := 5391;
GL_COPY : constant GLenum := 5379;
GL_COPY_INVERTED : constant GLenum := 5388;
GL_NOOP : constant GLenum := 5381;
GL_INVERT : constant GLenum := 5386;
GL_AND : constant GLenum := 5377;
GL_NAND : constant GLenum := 5390;
GL_OR : constant GLenum := 5383;
GL_NOR : constant GLenum := 5384;
GL_XOR : constant GLenum := 5382;
GL_EQUIV : constant GLenum := 5385;
GL_AND_REVERSE : constant GLenum := 5378;
GL_AND_INVERTED : constant GLenum := 5380;
GL_OR_REVERSE : constant GLenum := 5387;
GL_OR_INVERTED : constant GLenum := 5389;
GL_STENCIL_TEST : constant GLenum := 2960;
GL_STENCIL_WRITEMASK : constant GLenum := 2968;
GL_STENCIL_BITS : constant GLenum := 3415;
GL_STENCIL_FUNC : constant GLenum := 2962;
GL_STENCIL_VALUE_MASK : constant GLenum := 2963;
GL_STENCIL_REF : constant GLenum := 2967;
GL_STENCIL_FAIL : constant GLenum := 2964;
GL_STENCIL_PASS_DEPTH_PASS : constant GLenum := 2966;
GL_STENCIL_PASS_DEPTH_FAIL : constant GLenum := 2965;
GL_STENCIL_CLEAR_VALUE : constant GLenum := 2961;
GL_STENCIL_INDEX : constant GLenum := 6401;
GL_KEEP : constant GLenum := 7680;
GL_REPLACE : constant GLenum := 7681;
GL_INCR : constant GLenum := 7682;
GL_DECR : constant GLenum := 7683;
GL_NONE : constant GLenum := 0;
GL_LEFT : constant GLenum := 1030;
GL_RIGHT : constant GLenum := 1031;
GL_FRONT_LEFT : constant GLenum := 1024;
GL_FRONT_RIGHT : constant GLenum := 1025;
GL_BACK_LEFT : constant GLenum := 1026;
GL_BACK_RIGHT : constant GLenum := 1027;
GL_AUX0 : constant GLenum := 1033;
GL_AUX1 : constant GLenum := 1034;
GL_AUX2 : constant GLenum := 1035;
GL_AUX3 : constant GLenum := 1036;
GL_COLOR_INDEX : constant GLenum := 6400;
GL_RED : constant GLenum := 6403;
GL_GREEN : constant GLenum := 6404;
GL_BLUE : constant GLenum := 6405;
GL_ALPHA : constant GLenum := 6406;
GL_LUMINANCE : constant GLenum := 6409;
GL_LUMINANCE_ALPHA : constant GLenum := 6410;
GL_ALPHA_BITS : constant GLenum := 3413;
GL_RED_BITS : constant GLenum := 3410;
GL_GREEN_BITS : constant GLenum := 3411;
GL_BLUE_BITS : constant GLenum := 3412;
GL_INDEX_BITS : constant GLenum := 3409;
GL_SUBPIXEL_BITS : constant GLenum := 3408;
GL_AUX_BUFFERS : constant GLenum := 3072;
GL_READ_BUFFER : constant GLenum := 3074;
GL_DRAW_BUFFER : constant GLenum := 3073;
GL_DOUBLEBUFFER : constant GLenum := 3122;
GL_STEREO : constant GLenum := 3123;
GL_BITMAP : constant GLenum := 6656;
GL_COLOR : constant GLenum := 6144;
GL_DEPTH : constant GLenum := 6145;
GL_STENCIL : constant GLenum := 6146;
GL_DITHER : constant GLenum := 3024;
GL_RGB : constant GLenum := 6407;
GL_RGBA : constant GLenum := 6408;
GL_MAX_LIST_NESTING : constant GLenum := 2865;
GL_MAX_ATTRIB_STACK_DEPTH : constant GLenum := 3381;
GL_MAX_MODELVIEW_STACK_DEPTH : constant GLenum := 3382;
GL_MAX_NAME_STACK_DEPTH : constant GLenum := 3383;
GL_MAX_PROJECTION_STACK_DEPTH : constant GLenum := 3384;
GL_MAX_TEXTURE_STACK_DEPTH : constant GLenum := 3385;
GL_MAX_EVAL_ORDER : constant GLenum := 3376;
GL_MAX_LIGHTS : constant GLenum := 3377;
GL_MAX_CLIP_PLANES : constant GLenum := 3378;
GL_MAX_TEXTURE_SIZE : constant GLenum := 3379;
GL_MAX_PIXEL_MAP_TABLE : constant GLenum := 3380;
GL_MAX_VIEWPORT_DIMS : constant GLenum := 3386;
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 3387;
GL_ATTRIB_STACK_DEPTH : constant GLenum := 2992;
GL_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 2993;
GL_COLOR_CLEAR_VALUE : constant GLenum := 3106;
GL_COLOR_WRITEMASK : constant GLenum := 3107;
GL_CURRENT_INDEX : constant GLenum := 2817;
GL_CURRENT_COLOR : constant GLenum := 2816;
GL_CURRENT_NORMAL : constant GLenum := 2818;
GL_CURRENT_RASTER_COLOR : constant GLenum := 2820;
GL_CURRENT_RASTER_DISTANCE : constant GLenum := 2825;
GL_CURRENT_RASTER_INDEX : constant GLenum := 2821;
GL_CURRENT_RASTER_POSITION : constant GLenum := 2823;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant GLenum := 2822;
GL_CURRENT_RASTER_POSITION_VALID : constant GLenum := 2824;
GL_CURRENT_TEXTURE_COORDS : constant GLenum := 2819;
GL_INDEX_CLEAR_VALUE : constant GLenum := 3104;
GL_INDEX_MODE : constant GLenum := 3120;
GL_INDEX_WRITEMASK : constant GLenum := 3105;
GL_MODELVIEW_MATRIX : constant GLenum := 2982;
GL_MODELVIEW_STACK_DEPTH : constant GLenum := 2979;
GL_NAME_STACK_DEPTH : constant GLenum := 3440;
GL_PROJECTION_MATRIX : constant GLenum := 2983;
GL_PROJECTION_STACK_DEPTH : constant GLenum := 2980;
GL_RENDER_MODE : constant GLenum := 3136;
GL_RGBA_MODE : constant GLenum := 3121;
GL_TEXTURE_MATRIX : constant GLenum := 2984;
GL_TEXTURE_STACK_DEPTH : constant GLenum := 2981;
GL_VIEWPORT : constant GLenum := 2978;
GL_AUTO_NORMAL : constant GLenum := 3456;
GL_MAP1_COLOR_4 : constant GLenum := 3472;
GL_MAP1_GRID_DOMAIN : constant GLenum := 3536;
GL_MAP1_GRID_SEGMENTS : constant GLenum := 3537;
GL_MAP1_INDEX : constant GLenum := 3473;
GL_MAP1_NORMAL : constant GLenum := 3474;
GL_MAP1_TEXTURE_COORD_1 : constant GLenum := 3475;
GL_MAP1_TEXTURE_COORD_2 : constant GLenum := 3476;
GL_MAP1_TEXTURE_COORD_3 : constant GLenum := 3477;
GL_MAP1_TEXTURE_COORD_4 : constant GLenum := 3478;
GL_MAP1_VERTEX_3 : constant GLenum := 3479;
GL_MAP1_VERTEX_4 : constant GLenum := 3480;
GL_MAP2_COLOR_4 : constant GLenum := 3504;
GL_MAP2_GRID_DOMAIN : constant GLenum := 3538;
GL_MAP2_GRID_SEGMENTS : constant GLenum := 3539;
GL_MAP2_INDEX : constant GLenum := 3505;
GL_MAP2_NORMAL : constant GLenum := 3506;
GL_MAP2_TEXTURE_COORD_1 : constant GLenum := 3507;
GL_MAP2_TEXTURE_COORD_2 : constant GLenum := 3508;
GL_MAP2_TEXTURE_COORD_3 : constant GLenum := 3509;
GL_MAP2_TEXTURE_COORD_4 : constant GLenum := 3510;
GL_MAP2_VERTEX_3 : constant GLenum := 3511;
GL_MAP2_VERTEX_4 : constant GLenum := 3512;
GL_COEFF : constant GLenum := 2560;
GL_DOMAIN : constant GLenum := 2562;
GL_ORDER : constant GLenum := 2561;
GL_FOG_HINT : constant GLenum := 3156;
GL_LINE_SMOOTH_HINT : constant GLenum := 3154;
GL_PERSPECTIVE_CORRECTION_HINT : constant GLenum := 3152;
GL_POINT_SMOOTH_HINT : constant GLenum := 3153;
GL_POLYGON_SMOOTH_HINT : constant GLenum := 3155;
GL_DONT_CARE : constant GLenum := 4352;
GL_FASTEST : constant GLenum := 4353;
GL_NICEST : constant GLenum := 4354;
GL_SCISSOR_TEST : constant GLenum := 3089;
GL_SCISSOR_BOX : constant GLenum := 3088;
GL_MAP_COLOR : constant GLenum := 3344;
GL_MAP_STENCIL : constant GLenum := 3345;
GL_INDEX_SHIFT : constant GLenum := 3346;
GL_INDEX_OFFSET : constant GLenum := 3347;
GL_RED_SCALE : constant GLenum := 3348;
GL_RED_BIAS : constant GLenum := 3349;
GL_GREEN_SCALE : constant GLenum := 3352;
GL_GREEN_BIAS : constant GLenum := 3353;
GL_BLUE_SCALE : constant GLenum := 3354;
GL_BLUE_BIAS : constant GLenum := 3355;
GL_ALPHA_SCALE : constant GLenum := 3356;
GL_ALPHA_BIAS : constant GLenum := 3357;
GL_DEPTH_SCALE : constant GLenum := 3358;
GL_DEPTH_BIAS : constant GLenum := 3359;
GL_PIXEL_MAP_S_TO_S_SIZE : constant GLenum := 3249;
GL_PIXEL_MAP_I_TO_I_SIZE : constant GLenum := 3248;
GL_PIXEL_MAP_I_TO_R_SIZE : constant GLenum := 3250;
GL_PIXEL_MAP_I_TO_G_SIZE : constant GLenum := 3251;
GL_PIXEL_MAP_I_TO_B_SIZE : constant GLenum := 3252;
GL_PIXEL_MAP_I_TO_A_SIZE : constant GLenum := 3253;
GL_PIXEL_MAP_R_TO_R_SIZE : constant GLenum := 3254;
GL_PIXEL_MAP_G_TO_G_SIZE : constant GLenum := 3255;
GL_PIXEL_MAP_B_TO_B_SIZE : constant GLenum := 3256;
GL_PIXEL_MAP_A_TO_A_SIZE : constant GLenum := 3257;
GL_PIXEL_MAP_S_TO_S : constant GLenum := 3185;
GL_PIXEL_MAP_I_TO_I : constant GLenum := 3184;
GL_PIXEL_MAP_I_TO_R : constant GLenum := 3186;
GL_PIXEL_MAP_I_TO_G : constant GLenum := 3187;
GL_PIXEL_MAP_I_TO_B : constant GLenum := 3188;
GL_PIXEL_MAP_I_TO_A : constant GLenum := 3189;
GL_PIXEL_MAP_R_TO_R : constant GLenum := 3190;
GL_PIXEL_MAP_G_TO_G : constant GLenum := 3191;
GL_PIXEL_MAP_B_TO_B : constant GLenum := 3192;
GL_PIXEL_MAP_A_TO_A : constant GLenum := 3193;
GL_PACK_ALIGNMENT : constant GLenum := 3333;
GL_PACK_LSB_FIRST : constant GLenum := 3329;
GL_PACK_ROW_LENGTH : constant GLenum := 3330;
GL_PACK_SKIP_PIXELS : constant GLenum := 3332;
GL_PACK_SKIP_ROWS : constant GLenum := 3331;
GL_PACK_SWAP_BYTES : constant GLenum := 3328;
GL_UNPACK_ALIGNMENT : constant GLenum := 3317;
GL_UNPACK_LSB_FIRST : constant GLenum := 3313;
GL_UNPACK_ROW_LENGTH : constant GLenum := 3314;
GL_UNPACK_SKIP_PIXELS : constant GLenum := 3316;
GL_UNPACK_SKIP_ROWS : constant GLenum := 3315;
GL_UNPACK_SWAP_BYTES : constant GLenum := 3312;
GL_ZOOM_X : constant GLenum := 3350;
GL_ZOOM_Y : constant GLenum := 3351;
GL_TEXTURE_ENV : constant GLenum := 8960;
GL_TEXTURE_ENV_MODE : constant GLenum := 8704;
GL_TEXTURE_1D : constant GLenum := 3552;
GL_TEXTURE_2D : constant GLenum := 3553;
GL_TEXTURE_WRAP_S : constant GLenum := 10242;
GL_TEXTURE_WRAP_T : constant GLenum := 10243;
GL_TEXTURE_MAG_FILTER : constant GLenum := 10240;
GL_TEXTURE_MIN_FILTER : constant GLenum := 10241;
GL_TEXTURE_ENV_COLOR : constant GLenum := 8705;
GL_TEXTURE_GEN_S : constant GLenum := 3168;
GL_TEXTURE_GEN_T : constant GLenum := 3169;
GL_TEXTURE_GEN_MODE : constant GLenum := 9472;
GL_TEXTURE_BORDER_COLOR : constant GLenum := 4100;
GL_TEXTURE_WIDTH : constant GLenum := 4096;
GL_TEXTURE_HEIGHT : constant GLenum := 4097;
GL_TEXTURE_BORDER : constant GLenum := 4101;
GL_TEXTURE_COMPONENTS : constant GLenum := 4099;
GL_TEXTURE_RED_SIZE : constant GLenum := 32860;
GL_TEXTURE_GREEN_SIZE : constant GLenum := 32861;
GL_TEXTURE_BLUE_SIZE : constant GLenum := 32862;
GL_TEXTURE_ALPHA_SIZE : constant GLenum := 32863;
GL_TEXTURE_LUMINANCE_SIZE : constant GLenum := 32864;
GL_TEXTURE_INTENSITY_SIZE : constant GLenum := 32865;
GL_NEAREST_MIPMAP_NEAREST : constant GLenum := 9984;
GL_NEAREST_MIPMAP_LINEAR : constant GLenum := 9986;
GL_LINEAR_MIPMAP_NEAREST : constant GLenum := 9985;
GL_LINEAR_MIPMAP_LINEAR : constant GLenum := 9987;
GL_OBJECT_LINEAR : constant GLenum := 9217;
GL_OBJECT_PLANE : constant GLenum := 9473;
GL_EYE_LINEAR : constant GLenum := 9216;
GL_EYE_PLANE : constant GLenum := 9474;
GL_SPHERE_MAP : constant GLenum := 9218;
GL_DECAL : constant GLenum := 8449;
GL_MODULATE : constant GLenum := 8448;
GL_NEAREST : constant GLenum := 9728;
GL_REPEAT : constant GLenum := 10497;
GL_CLAMP : constant GLenum := 10496;
GL_S : constant GLenum := 8192;
GL_T : constant GLenum := 8193;
GL_R : constant GLenum := 8194;
GL_Q : constant GLenum := 8195;
GL_TEXTURE_GEN_R : constant GLenum := 3170;
GL_TEXTURE_GEN_Q : constant GLenum := 3171;
GL_PROXY_TEXTURE_1D : constant GLenum := 32867;
GL_PROXY_TEXTURE_2D : constant GLenum := 32868;
GL_TEXTURE_PRIORITY : constant GLenum := 32870;
GL_TEXTURE_RESIDENT : constant GLenum := 32871;
GL_TEXTURE_BINDING_1D : constant GLenum := 32872;
GL_TEXTURE_BINDING_2D : constant GLenum := 32873;
GL_TEXTURE_INTERNAL_FORMAT : constant GLenum := 4099;
GL_PACK_SKIP_IMAGES : constant GLenum := 32875;
GL_PACK_IMAGE_HEIGHT : constant GLenum := 32876;
GL_UNPACK_SKIP_IMAGES : constant GLenum := 32877;
GL_UNPACK_IMAGE_HEIGHT : constant GLenum := 32878;
GL_TEXTURE_3D : constant GLenum := 32879;
GL_PROXY_TEXTURE_3D : constant GLenum := 32880;
GL_TEXTURE_DEPTH : constant GLenum := 32881;
GL_TEXTURE_WRAP_R : constant GLenum := 32882;
GL_MAX_3D_TEXTURE_SIZE : constant GLenum := 32883;
GL_TEXTURE_BINDING_3D : constant GLenum := 32874;
GL_ALPHA4 : constant GLenum := 32827;
GL_ALPHA8 : constant GLenum := 32828;
GL_ALPHA12 : constant GLenum := 32829;
GL_ALPHA16 : constant GLenum := 32830;
GL_LUMINANCE4 : constant GLenum := 32831;
GL_LUMINANCE8 : constant GLenum := 32832;
GL_LUMINANCE12 : constant GLenum := 32833;
GL_LUMINANCE16 : constant GLenum := 32834;
GL_LUMINANCE4_ALPHA4 : constant GLenum := 32835;
GL_LUMINANCE6_ALPHA2 : constant GLenum := 32836;
GL_LUMINANCE8_ALPHA8 : constant GLenum := 32837;
GL_LUMINANCE12_ALPHA4 : constant GLenum := 32838;
GL_LUMINANCE12_ALPHA12 : constant GLenum := 32839;
GL_LUMINANCE16_ALPHA16 : constant GLenum := 32840;
GL_INTENSITY : constant GLenum := 32841;
GL_INTENSITY4 : constant GLenum := 32842;
GL_INTENSITY8 : constant GLenum := 32843;
GL_INTENSITY12 : constant GLenum := 32844;
GL_INTENSITY16 : constant GLenum := 32845;
GL_R3_G3_B2 : constant GLenum := 10768;
GL_RGB4 : constant GLenum := 32847;
GL_RGB5 : constant GLenum := 32848;
GL_RGB8 : constant GLenum := 32849;
GL_RGB10 : constant GLenum := 32850;
GL_RGB12 : constant GLenum := 32851;
GL_RGB16 : constant GLenum := 32852;
GL_RGBA2 : constant GLenum := 32853;
GL_RGBA4 : constant GLenum := 32854;
GL_RGB5_A1 : constant GLenum := 32855;
GL_RGBA8 : constant GLenum := 32856;
GL_RGB10_A2 : constant GLenum := 32857;
GL_RGBA12 : constant GLenum := 32858;
GL_RGBA16 : constant GLenum := 32859;
GL_VENDOR : constant GLenum := 7936;
GL_RENDERER : constant GLenum := 7937;
GL_VERSION : constant GLenum := 7938;
GL_EXTENSIONS : constant GLenum := 7939;
GL_INVALID_VALUE : constant GLenum := 1281;
GL_INVALID_ENUM : constant GLenum := 1280;
GL_INVALID_OPERATION : constant GLenum := 1282;
GL_STACK_OVERFLOW : constant GLenum := 1283;
GL_STACK_UNDERFLOW : constant GLenum := 1284;
GL_OUT_OF_MEMORY : constant GLenum := 1285;
GL_CONSTANT_COLOR_EXT : constant GLenum := 32769;
GL_ONE_MINUS_CONSTANT_COLOR_EXT : constant GLenum := 32770;
GL_CONSTANT_ALPHA_EXT : constant GLenum := 32771;
GL_ONE_MINUS_CONSTANT_ALPHA_EXT : constant GLenum := 32772;
GL_BLEND_EQUATION_EXT : constant GLenum := 32777;
GL_MIN_EXT : constant GLenum := 32775;
GL_MAX_EXT : constant GLenum := 32776;
GL_FUNC_ADD_EXT : constant GLenum := 32774;
GL_FUNC_SUBTRACT_EXT : constant GLenum := 32778;
GL_FUNC_REVERSE_SUBTRACT_EXT : constant GLenum := 32779;
GL_BLEND_COLOR_EXT : constant GLenum := 32773;
GL_POLYGON_OFFSET_EXT : constant GLenum := 32823;
GL_POLYGON_OFFSET_FACTOR_EXT : constant GLenum := 32824;
GL_POLYGON_OFFSET_BIAS_EXT : constant GLenum := 32825;
GL_VERTEX_ARRAY_EXT : constant GLenum := 32884;
GL_NORMAL_ARRAY_EXT : constant GLenum := 32885;
GL_COLOR_ARRAY_EXT : constant GLenum := 32886;
GL_INDEX_ARRAY_EXT : constant GLenum := 32887;
GL_TEXTURE_COORD_ARRAY_EXT : constant GLenum := 32888;
GL_EDGE_FLAG_ARRAY_EXT : constant GLenum := 32889;
GL_VERTEX_ARRAY_SIZE_EXT : constant GLenum := 32890;
GL_VERTEX_ARRAY_TYPE_EXT : constant GLenum := 32891;
GL_VERTEX_ARRAY_STRIDE_EXT : constant GLenum := 32892;
GL_VERTEX_ARRAY_COUNT_EXT : constant GLenum := 32893;
GL_NORMAL_ARRAY_TYPE_EXT : constant GLenum := 32894;
GL_NORMAL_ARRAY_STRIDE_EXT : constant GLenum := 32895;
GL_NORMAL_ARRAY_COUNT_EXT : constant GLenum := 32896;
GL_COLOR_ARRAY_SIZE_EXT : constant GLenum := 32897;
GL_COLOR_ARRAY_TYPE_EXT : constant GLenum := 32898;
GL_COLOR_ARRAY_STRIDE_EXT : constant GLenum := 32899;
GL_COLOR_ARRAY_COUNT_EXT : constant GLenum := 32900;
GL_INDEX_ARRAY_TYPE_EXT : constant GLenum := 32901;
GL_INDEX_ARRAY_STRIDE_EXT : constant GLenum := 32902;
GL_INDEX_ARRAY_COUNT_EXT : constant GLenum := 32903;
GL_TEXTURE_COORD_ARRAY_SIZE_EXT : constant GLenum := 32904;
GL_TEXTURE_COORD_ARRAY_TYPE_EXT : constant GLenum := 32905;
GL_TEXTURE_COORD_ARRAY_STRIDE_EXT : constant GLenum := 32906;
GL_TEXTURE_COORD_ARRAY_COUNT_EXT : constant GLenum := 32907;
GL_EDGE_FLAG_ARRAY_STRIDE_EXT : constant GLenum := 32908;
GL_EDGE_FLAG_ARRAY_COUNT_EXT : constant GLenum := 32909;
GL_VERTEX_ARRAY_POINTER_EXT : constant GLenum := 32910;
GL_NORMAL_ARRAY_POINTER_EXT : constant GLenum := 32911;
GL_COLOR_ARRAY_POINTER_EXT : constant GLenum := 32912;
GL_INDEX_ARRAY_POINTER_EXT : constant GLenum := 32913;
GL_TEXTURE_COORD_ARRAY_POINTER_EXT : constant GLenum := 32914;
GL_EDGE_FLAG_ARRAY_POINTER_EXT : constant GLenum := 32915;
GL_TEXTURE_PRIORITY_EXT : constant GLenum := 32870;
GL_TEXTURE_RESIDENT_EXT : constant GLenum := 32871;
GL_TEXTURE_1D_BINDING_EXT : constant GLenum := 32872;
GL_TEXTURE_2D_BINDING_EXT : constant GLenum := 32873;
GL_PACK_SKIP_IMAGES_EXT : constant GLenum := 32875;
GL_PACK_IMAGE_HEIGHT_EXT : constant GLenum := 32876;
GL_UNPACK_SKIP_IMAGES_EXT : constant GLenum := 32877;
GL_UNPACK_IMAGE_HEIGHT_EXT : constant GLenum := 32878;
GL_TEXTURE_3D_EXT : constant GLenum := 32879;
GL_PROXY_TEXTURE_3D_EXT : constant GLenum := 32880;
GL_TEXTURE_DEPTH_EXT : constant GLenum := 32881;
GL_TEXTURE_WRAP_R_EXT : constant GLenum := 32882;
GL_MAX_3D_TEXTURE_SIZE_EXT : constant GLenum := 32883;
GL_TEXTURE_3D_BINDING_EXT : constant GLenum := 32874;
GL_TABLE_TOO_LARGE_EXT : constant GLenum := 32817;
GL_COLOR_TABLE_FORMAT_EXT : constant GLenum := 32984;
GL_COLOR_TABLE_WIDTH_EXT : constant GLenum := 32985;
GL_COLOR_TABLE_RED_SIZE_EXT : constant GLenum := 32986;
GL_COLOR_TABLE_GREEN_SIZE_EXT : constant GLenum := 32987;
GL_COLOR_TABLE_BLUE_SIZE_EXT : constant GLenum := 32988;
GL_COLOR_TABLE_ALPHA_SIZE_EXT : constant GLenum := 32989;
GL_COLOR_TABLE_LUMINANCE_SIZE_EXT : constant GLenum := 32990;
GL_COLOR_TABLE_INTENSITY_SIZE_EXT : constant GLenum := 32991;
GL_TEXTURE_INDEX_SIZE_EXT : constant GLenum := 33005;
GL_COLOR_INDEX1_EXT : constant GLenum := 32994;
GL_COLOR_INDEX2_EXT : constant GLenum := 32995;
GL_COLOR_INDEX4_EXT : constant GLenum := 32996;
GL_COLOR_INDEX8_EXT : constant GLenum := 32997;
GL_COLOR_INDEX12_EXT : constant GLenum := 32998;
GL_COLOR_INDEX16_EXT : constant GLenum := 32999;
GL_SHARED_TEXTURE_PALETTE_EXT : constant GLenum := 33275;
GL_POINT_SIZE_MIN_EXT : constant GLenum := 33062;
GL_POINT_SIZE_MAX_EXT : constant GLenum := 33063;
GL_POINT_FADE_THRESHOLD_SIZE_EXT : constant GLenum := 33064;
GL_DISTANCE_ATTENUATION_EXT : constant GLenum := 33065;
GL_RESCALE_NORMAL_EXT : constant GLenum := 32826;
GL_ABGR_EXT : constant GLenum := 32768;
GL_SELECTED_TEXTURE_SGIS : constant GLenum := 33628;
GL_SELECTED_TEXTURE_COORD_SET_SGIS : constant GLenum := 33629;
GL_MAX_TEXTURES_SGIS : constant GLenum := 33630;
GL_TEXTURE0_SGIS : constant GLenum := 33631;
GL_TEXTURE1_SGIS : constant GLenum := 33632;
GL_TEXTURE2_SGIS : constant GLenum := 33633;
GL_TEXTURE3_SGIS : constant GLenum := 33634;
GL_TEXTURE_COORD_SET_SOURCE_SGIS : constant GLenum := 33635;
GL_SELECTED_TEXTURE_EXT : constant GLenum := 33728;
GL_SELECTED_TEXTURE_COORD_SET_EXT : constant GLenum := 33729;
GL_SELECTED_TEXTURE_TRANSFORM_EXT : constant GLenum := 33730;
GL_MAX_TEXTURES_EXT : constant GLenum := 33731;
GL_MAX_TEXTURE_COORD_SETS_EXT : constant GLenum := 33732;
GL_TEXTURE_ENV_COORD_SET_EXT : constant GLenum := 33733;
GL_TEXTURE0_EXT : constant GLenum := 33734;
GL_TEXTURE1_EXT : constant GLenum := 33735;
GL_TEXTURE2_EXT : constant GLenum := 33736;
GL_TEXTURE3_EXT : constant GLenum := 33737;
GL_CLAMP_TO_EDGE_SGIS : constant GLenum := 33071;
GL_RESCALE_NORMAL : constant GLenum := 32826;
GL_CLAMP_TO_EDGE : constant GLenum := 33071;
GL_MAX_ELEMENTS_VERTICES : constant GLenum := 61672;
GL_MAX_ELEMENTS_INDICES : constant GLenum := 61673;
GL_BGR : constant GLenum := 32992;
GL_BGRA : constant GLenum := 32993;
GL_UNSIGNED_BYTE_3_3_2 : constant GLenum := 32818;
GL_UNSIGNED_BYTE_2_3_3_REV : constant GLenum := 33634;
GL_UNSIGNED_SHORT_5_6_5 : constant GLenum := 33635;
GL_UNSIGNED_SHORT_5_6_5_REV : constant GLenum := 33636;
GL_UNSIGNED_SHORT_4_4_4_4 : constant GLenum := 32819;
GL_UNSIGNED_SHORT_4_4_4_4_REV : constant GLenum := 33637;
GL_UNSIGNED_SHORT_5_5_5_1 : constant GLenum := 32820;
GL_UNSIGNED_SHORT_1_5_5_5_REV : constant GLenum := 33638;
GL_UNSIGNED_INT_8_8_8_8 : constant GLenum := 32821;
GL_UNSIGNED_INT_8_8_8_8_REV : constant GLenum := 33639;
GL_UNSIGNED_INT_10_10_10_2 : constant GLenum := 32822;
GL_UNSIGNED_INT_2_10_10_10_REV : constant GLenum := 33640;
GL_LIGHT_MODEL_COLOR_CONTROL : constant GLenum := 33272;
GL_SINGLE_COLOR : constant GLenum := 33273;
GL_SEPARATE_SPECULAR_COLOR : constant GLenum := 33274;
GL_TEXTURE_MIN_LOD : constant GLenum := 33082;
GL_TEXTURE_MAX_LOD : constant GLenum := 33083;
GL_TEXTURE_BASE_LEVEL : constant GLenum := 33084;
GL_TEXTURE_MAX_LEVEL : constant GLenum := 33085;
-- GL_NO_ERROR must be zero
GL_NO_ERROR : constant := 0;
subtype GLbitfield is Interfaces.C.unsigned;
GL_CURRENT_BIT : constant Glbitfield := 16#00000001#;
GL_POINT_BIT : constant Glbitfield := 16#00000002#;
GL_LINE_BIT : constant Glbitfield := 16#00000004#;
GL_POLYGON_BIT : constant Glbitfield := 16#00000008#;
GL_POLYGON_STIPPLE_BIT : constant Glbitfield := 16#00000010#;
GL_PIXEL_MODE_BIT : constant Glbitfield := 16#00000020#;
GL_LIGHTING_BIT : constant Glbitfield := 16#00000040#;
GL_FOG_BIT : constant Glbitfield := 16#00000080#;
GL_DEPTH_BUFFER_BIT : constant Glbitfield := 16#00000100#;
GL_ACCUM_BUFFER_BIT : constant Glbitfield := 16#00000200#;
GL_STENCIL_BUFFER_BIT : constant Glbitfield := 16#00000400#;
GL_VIEWPORT_BIT : constant Glbitfield := 16#00000800#;
GL_TRANSFORM_BIT : constant Glbitfield := 16#00001000#;
GL_ENABLE_BIT : constant Glbitfield := 16#00002000#;
GL_COLOR_BUFFER_BIT : constant Glbitfield := 16#00004000#;
GL_HINT_BIT : constant Glbitfield := 16#00008000#;
GL_EVAL_BIT : constant Glbitfield := 16#00010000#;
GL_LIST_BIT : constant Glbitfield := 16#00020000#;
GL_TEXTURE_BIT : constant Glbitfield := 16#00040000#;
GL_SCISSOR_BIT : constant Glbitfield := 16#00080000#;
GL_ALL_ATTRIB_BITS : constant Glbitfield := 16#000fffff#;
--
-- Data types (may be architecture dependent in some cases)
--
-- C type GL type storage
-- -------------------------------------------------------------------------
type Void is null record ;
subtype GLvoid is Void;
subtype GLboolean is Interfaces.C.unsigned_char;
subtype GLbyte is Interfaces.C.signed_char; -- 1-byte signed
subtype GLshort is Short_Integer; -- 2-byte signed
subtype GLint is Integer; -- 4-byte signed
type GLint_Vec_4 is array (0 .. 3) of GLint;
subtype GLubyte is Interfaces.C.unsigned_char; -- 1-byte unsigned
type GLubyte_Ptr is access GLubyte;
subtype GLushort is Interfaces.C.unsigned_short; -- 2-byte unsigned
subtype GLuint is Interfaces.C.unsigned; -- 4-byte unsigned
subtype GLsizei is Integer; -- 4-byte signed
subtype GLfloat is Float; -- single precision float
type GLfloat_Vec_16 is array (0 .. 15) of GLfloat;
subtype GLclampf is Float; -- single precision float in [0;1]
subtype GLdouble is Long_Float; -- double precision float
type GLdouble_Vec_3 is array (0 .. 2) of GLdouble;
type GLdouble_Vec_16 is array (0 .. 15) of GLdouble;
subtype GLclampd is Long_Float; -- double precision float in [0;1]
--
-- Miscellaneous
--
procedure glClearIndex (c : GLfloat);
procedure glClearColor (red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glClear (mask : GLbitfield);
procedure glIndexMask (mask : GLuint);
procedure glColorMask (red : GLboolean;
green : GLboolean;
blue : GLboolean;
alpha : GLboolean);
procedure glAlphaFunc (func : GLenum; ref : GLclampf);
procedure glBlendFunc (sfactor : GLenum; dfactor : GLenum);
procedure glLogicOp (opcode : GLenum);
procedure glCullFace (mode : GLenum);
procedure glFrontFace (mode : GLenum);
procedure glPointSize (size : GLfloat);
procedure glLineWidth (width : GLfloat);
procedure glLineStipple (factor : GLint; pattern : GLushort);
procedure glPolygonMode (face : GLenum; mode : GLenum);
procedure glPolygonOffset (factor : GLfloat; units : GLfloat);
procedure glPolygonStipple (mask : access GLubyte);
procedure glGetPolygonStipple (mask : access GLubyte);
procedure glEdgeFlag (flag : GLboolean);
procedure glEdgeFlagv (flag : access GLboolean);
procedure glScissor (x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glClipPlane (plane : GLenum; equation : access GLdouble);
procedure glGetClipPlane (plane : GLenum; equation : access GLdouble);
procedure glDrawBuffer (mode : GLenum);
procedure glReadBuffer (mode : GLenum);
procedure glEnable (cap : GLenum);
procedure glDisable (cap : GLenum);
function glIsEnabled (cap : GLenum) return GLboolean;
procedure glEnableClientState (cap : GLenum -- 1.1
);
procedure glDisableClientState (cap : GLenum -- 1.1
);
procedure glGetBooleanv (pname : GLenum; params : access GLboolean);
procedure glGetDoublev (pname : GLenum; params : access GLdouble);
procedure glGetFloatv (pname : GLenum; params : access GLfloat);
procedure glGetIntegerv (pname : GLenum; params : access GLint);
procedure glPushAttrib (mask : GLbitfield);
procedure glPopAttrib;
procedure glPushClientAttrib (mask : GLbitfield -- 1.1
);
procedure glPopClientAttrib; -- 1.1
function glRenderMode (mode : GLenum) return GLint;
function glGetError return GLenum;
function glGetString (name : GLenum) return GLubyte_Ptr;
procedure glFinish;
procedure glFlush;
procedure glHint (target : GLenum; mode : GLenum);
--
-- Depth Buffer
--
procedure glClearDepth (depth : GLclampd);
procedure glDepthFunc (func : GLenum);
procedure glDepthMask (flag : GLboolean);
procedure glDepthRange (near_val : GLclampd; far_val : GLclampd);
--
-- Accumulation Buffer
--
procedure glClearAccum (red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glAccum (op : GLenum; value : GLfloat);
--
-- Transformation
--
procedure glMatrixMode (mode : GLenum);
procedure glOrtho (left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glFrustum (left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glViewport (x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glPushMatrix;
procedure glPopMatrix;
procedure glLoadIdentity;
procedure glLoadMatrixd (m : access GLdouble);
procedure glLoadMatrixf (m : access GLfloat);
procedure glMultMatrixd (m : access GLdouble);
procedure glMultMatrixf (m : access GLfloat);
procedure glRotated (angle : GLdouble;
x : GLdouble;
y : GLdouble;
z : GLdouble);
procedure glRotatef (angle : GLfloat;
x : GLfloat;
y : GLfloat;
z : GLfloat);
procedure glScaled (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glScalef (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glTranslated (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glTranslatef (x : GLfloat; y : GLfloat; z : GLfloat);
--
-- Display Lists
--
function glIsList (list : GLuint) return GLboolean;
procedure glDeleteLists (list : GLuint; range_Id : GLsizei);
function glGenLists (range_Id : GLsizei) return GLuint;
procedure glNewList (list : GLuint; mode : GLenum);
procedure glEndList;
procedure glCallList (list : GLuint);
procedure glCallLists (n : GLsizei;
type_Id : GLenum;
lists : access GLvoid);
procedure glListBase (base : GLuint);
--
-- Drawing Functions
--
procedure glBegin (mode : GLenum);
procedure glEnd;
procedure glVertex2d (x : GLdouble; y : GLdouble);
procedure glVertex2f (x : GLfloat; y : GLfloat);
procedure glVertex2i (x : GLint; y : GLint);
procedure glVertex2s (x : GLshort; y : GLshort);
procedure glVertex3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glVertex3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glVertex3i (x : GLint; y : GLint; z : GLint);
procedure glVertex3s (x : GLshort; y : GLshort; z : GLshort);
procedure glVertex4d (x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glVertex4f (x : GLfloat; y : GLfloat; z : GLfloat; w : GLfloat);
procedure glVertex4i (x : GLint; y : GLint; z : GLint; w : GLint);
procedure glVertex4s (x : GLshort; y : GLshort; z : GLshort; w : GLshort);
procedure glVertex2dv (v : access GLdouble);
procedure glVertex2fv (v : access GLfloat);
procedure glVertex2iv (v : access GLint);
procedure glVertex2sv (v : access GLshort);
procedure glVertex3dv (v : access GLdouble);
procedure glVertex3fv (v : access GLfloat);
procedure glVertex3iv (v : access GLint);
procedure glVertex3sv (v : access GLshort);
procedure glVertex4dv (v : access GLdouble);
procedure glVertex4fv (v : access GLfloat);
procedure glVertex4iv (v : access GLint);
procedure glVertex4sv (v : access GLshort);
procedure glNormal3b (nx : GLbyte; ny : GLbyte; nz : GLbyte);
procedure glNormal3d (nx : GLdouble; ny : GLdouble; nz : GLdouble);
procedure glNormal3f (nx : GLfloat; ny : GLfloat; nz : GLfloat);
procedure glNormal3i (nx : GLint; ny : GLint; nz : GLint);
procedure glNormal3s (nx : GLshort; ny : GLshort; nz : GLshort);
procedure glNormal3bv (v : access GLbyte);
procedure glNormal3dv (v : access GLdouble);
procedure glNormal3fv (v : access GLfloat);
procedure glNormal3iv (v : access GLint);
procedure glNormal3sv (v : access GLshort);
procedure glIndexd (c : GLdouble);
procedure glIndexf (c : GLfloat);
procedure glIndexi (c : GLint);
procedure glIndexs (c : GLshort);
procedure glIndexub (c : GLubyte -- 1.1
);
procedure glIndexdv (c : access GLdouble);
procedure glIndexfv (c : access GLfloat);
procedure glIndexiv (c : access GLint);
procedure glIndexsv (c : access GLshort);
procedure glIndexubv (c : access GLubyte -- 1.1
);
procedure glColor3b (red : GLbyte; green : GLbyte; blue : GLbyte);
procedure glColor3d (red : GLdouble; green : GLdouble; blue : GLdouble);
procedure glColor3f (red : GLfloat; green : GLfloat; blue : GLfloat);
procedure glColor3i (red : GLint; green : GLint; blue : GLint);
procedure glColor3s (red : GLshort; green : GLshort; blue : GLshort);
procedure glColor3ub (red : GLubyte; green : GLubyte; blue : GLubyte);
procedure glColor3ui (red : GLuint; green : GLuint; blue : GLuint);
procedure glColor3us (red : GLushort; green : GLushort; blue : GLushort);
procedure glColor4b (red : GLbyte;
green : GLbyte;
blue : GLbyte;
alpha : GLbyte);
procedure glColor4d (red : GLdouble;
green : GLdouble;
blue : GLdouble;
alpha : GLdouble);
procedure glColor4f (red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glColor4i (red : GLint;
green : GLint;
blue : GLint;
alpha : GLint);
procedure glColor4s (red : GLshort;
green : GLshort;
blue : GLshort;
alpha : GLshort);
procedure glColor4ub (red : GLubyte;
green : GLubyte;
blue : GLubyte;
alpha : GLubyte);
procedure glColor4ui (red : GLuint;
green : GLuint;
blue : GLuint;
alpha : GLuint);
procedure glColor4us (red : GLushort;
green : GLushort;
blue : GLushort;
alpha : GLushort);
procedure glColor3bv (v : access GLbyte);
procedure glColor3dv (v : access GLdouble);
procedure glColor3fv (v : access GLfloat);
procedure glColor3iv (v : access GLint);
procedure glColor3sv (v : access GLshort);
procedure glColor3ubv (v : access GLubyte);
procedure glColor3uiv (v : access GLuint);
procedure glColor3usv (v : access GLushort);
procedure glColor4bv (v : access GLbyte);
procedure glColor4dv (v : access GLdouble);
procedure glColor4fv (v : access GLfloat);
procedure glColor4iv (v : access GLint);
procedure glColor4sv (v : access GLshort);
procedure glColor4ubv (v : access GLubyte);
procedure glColor4uiv (v : access GLuint);
procedure glColor4usv (v : access GLushort);
procedure glTexCoord1d (s : GLdouble);
procedure glTexCoord1f (s : GLfloat);
procedure glTexCoord1i (s : GLint);
procedure glTexCoord1s (s : GLshort);
procedure glTexCoord2d (s : GLdouble; t : GLdouble);
procedure glTexCoord2f (s : GLfloat; t : GLfloat);
procedure glTexCoord2i (s : GLint; t : GLint);
procedure glTexCoord2s (s : GLshort; t : GLshort);
procedure glTexCoord3d (s : GLdouble; t : GLdouble; r : GLdouble);
procedure glTexCoord3f (s : GLfloat; t : GLfloat; r : GLfloat);
procedure glTexCoord3i (s : GLint; t : GLint; r : GLint);
procedure glTexCoord3s (s : GLshort; t : GLshort; r : GLshort);
procedure glTexCoord4d (s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glTexCoord4f
(s : GLfloat; t : GLfloat; r : GLfloat; q : GLfloat);
procedure glTexCoord4i (s : GLint; t : GLint; r : GLint; q : GLint);
procedure glTexCoord4s
(s : GLshort; t : GLshort; r : GLshort; q : GLshort);
procedure glTexCoord1dv (v : access GLdouble);
procedure glTexCoord1fv (v : access GLfloat);
procedure glTexCoord1iv (v : access GLint);
procedure glTexCoord1sv (v : access GLshort);
procedure glTexCoord2dv (v : access GLdouble);
procedure glTexCoord2fv (v : access GLfloat);
procedure glTexCoord2iv (v : access GLint);
procedure glTexCoord2sv (v : access GLshort);
procedure glTexCoord3dv (v : access GLdouble);
procedure glTexCoord3fv (v : access GLfloat);
procedure glTexCoord3iv (v : access GLint);
procedure glTexCoord3sv (v : access GLshort);
procedure glTexCoord4dv (v : access GLdouble);
procedure glTexCoord4fv (v : access GLfloat);
procedure glTexCoord4iv (v : access GLint);
procedure glTexCoord4sv (v : access GLshort);
procedure glRasterPos2d (x : GLdouble; y : GLdouble);
procedure glRasterPos2f (x : GLfloat; y : GLfloat);
procedure glRasterPos2i (x : GLint; y : GLint);
procedure glRasterPos2s (x : GLshort; y : GLshort);
procedure glRasterPos3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glRasterPos3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glRasterPos3i (x : GLint; y : GLint; z : GLint);
procedure glRasterPos3s (x : GLshort; y : GLshort; z : GLshort);
procedure glRasterPos4d (x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glRasterPos4f (x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glRasterPos4i (x : GLint; y : GLint; z : GLint; w : GLint);
procedure glRasterPos4s (x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glRasterPos2dv (v : access GLdouble);
procedure glRasterPos2fv (v : access GLfloat);
procedure glRasterPos2iv (v : access GLint);
procedure glRasterPos2sv (v : access GLshort);
procedure glRasterPos3dv (v : access GLdouble);
procedure glRasterPos3fv (v : access GLfloat);
procedure glRasterPos3iv (v : access GLint);
procedure glRasterPos3sv (v : access GLshort);
procedure glRasterPos4dv (v : access GLdouble);
procedure glRasterPos4fv (v : access GLfloat);
procedure glRasterPos4iv (v : access GLint);
procedure glRasterPos4sv (v : access GLshort);
procedure glRectd (x1 : GLdouble;
y1 : GLdouble;
x2 : GLdouble;
y2 : GLdouble);
procedure glRectf (x1 : GLfloat; y1 : GLfloat; x2 : GLfloat; y2 : GLfloat);
procedure glRecti (x1 : GLint; y1 : GLint; x2 : GLint; y2 : GLint);
procedure glRects (x1 : GLshort; y1 : GLshort; x2 : GLshort; y2 : GLshort);
procedure glRectdv (v1 : access GLdouble; v2 : access GLdouble);
procedure glRectfv (v1 : access GLfloat; v2 : access GLfloat);
procedure glRectiv (v1 : access GLint; v2 : access GLint);
procedure glRectsv (v1 : access GLshort; v2 : access GLshort);
--
-- Vertex Arrays (1.1)
--
procedure glVertexPointer (size : GLint;
type_Id : GLenum;
stride : GLsizei;
ptr : access GLvoid);
procedure glNormalPointer (type_Id : GLenum;
stride : GLsizei;
ptr : access GLvoid);
procedure glColorPointer (size : GLint;
type_Id : GLenum;
stride : GLsizei;
ptr : access GLvoid);
procedure glIndexPointer (type_Id : GLenum;
stride : GLsizei;
ptr : access GLvoid);
procedure glTexCoordPointer (size : GLint;
type_Id : GLenum;
stride : GLsizei;
ptr : access GLvoid);
procedure glEdgeFlagPointer (stride : GLsizei; ptr : access GLboolean);
procedure glGetPointerv (pname : GLenum;
params : access Interfaces.C.Extensions.Void_Ptr);
procedure glArrayElement (i : GLint);
procedure glDrawArrays (mode : GLenum; first : GLint; count : GLsizei);
procedure glDrawElements (mode : GLenum;
count : GLsizei;
type_Id : GLenum;
indices : access GLvoid);
procedure glInterleavedArrays (format : GLenum;
stride : GLsizei;
pointer : access GLvoid);
--
-- Lighting
--
procedure glShadeModel (mode : GLenum);
procedure glLightf (light : GLenum; pname : GLenum; param : GLfloat);
procedure glLighti (light : GLenum; pname : GLenum; param : GLint);
procedure glLightfv (light : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glLightiv
(light : GLenum; pname : GLenum; params : access GLint);
procedure glGetLightfv (light : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetLightiv (light : GLenum;
pname : GLenum;
params : access GLint);
procedure glLightModelf (pname : GLenum; param : GLfloat);
procedure glLightModeli (pname : GLenum; param : GLint);
procedure glLightModelfv (pname : GLenum; params : access GLfloat);
procedure glLightModeliv (pname : GLenum; params : access GLint);
procedure glMaterialf (face : GLenum; pname : GLenum; param : GLfloat);
procedure glMateriali (face : GLenum; pname : GLenum; param : GLint);
procedure glMaterialfv (face : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glMaterialiv (face : GLenum;
pname : GLenum;
params : access GLint);
procedure glGetMaterialfv (face : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetMaterialiv (face : GLenum;
pname : GLenum;
params : access GLint);
procedure glColorMaterial (face : GLenum; mode : GLenum);
--
-- Raster functions
--
procedure glPixelZoom (xfactor : GLfloat; yfactor : GLfloat);
procedure glPixelStoref (pname : GLenum; param : GLfloat);
procedure glPixelStorei (pname : GLenum; param : GLint);
procedure glPixelTransferf (pname : GLenum; param : GLfloat);
procedure glPixelTransferi (pname : GLenum; param : GLint);
procedure glPixelMapfv (map : GLenum;
mapsize : GLint;
values : access GLfloat);
procedure glPixelMapuiv (map : GLenum;
mapsize : GLint;
values : access GLuint);
procedure glPixelMapusv (map : GLenum;
mapsize : GLint;
values : access GLushort);
procedure glGetPixelMapfv (map : GLenum; values : access GLfloat);
procedure glGetPixelMapuiv (map : GLenum; values : access GLuint);
procedure glGetPixelMapusv (map : GLenum; values : access GLushort);
procedure glBitmap (width : GLsizei;
height : GLsizei;
xorig : GLfloat;
yorig : GLfloat;
xmove : GLfloat;
ymove : GLfloat;
bitmap : access GLubyte);
procedure glReadPixels (x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glDrawPixels (width : GLsizei;
height : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glCopyPixels (x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
type_Id : GLenum);
--
-- Stenciling
--
procedure glStencilFunc (func : GLenum; ref : GLint; mask : GLuint);
procedure glStencilMask (mask : GLuint);
procedure glStencilOp (fail : GLenum; zfail : GLenum; zpass : GLenum);
procedure glClearStencil (s : GLint);
--
-- Texture mapping
--
procedure glTexGend (coord : GLenum; pname : GLenum; param : GLdouble);
procedure glTexGenf (coord : GLenum; pname : GLenum; param : GLfloat);
procedure glTexGeni (coord : GLenum; pname : GLenum; param : GLint);
procedure glTexGendv (coord : GLenum;
pname : GLenum;
params : access GLdouble);
procedure glTexGenfv (coord : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glTexGeniv (coord : GLenum;
pname : GLenum;
params : access GLint);
procedure glGetTexGendv (coord : GLenum;
pname : GLenum;
params : access GLdouble);
procedure glGetTexGenfv (coord : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetTexGeniv (coord : GLenum;
pname : GLenum;
params : access GLint);
procedure glTexEnvf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexEnvi (target : GLenum; pname : GLenum; param : GLint);
procedure glTexEnvfv (target : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glTexEnviv (target : GLenum;
pname : GLenum;
params : access GLint);
procedure glGetTexEnvfv (target : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetTexEnviv (target : GLenum;
pname : GLenum;
params : access GLint);
procedure glTexParameterf (target : GLenum;
pname : GLenum;
param : GLfloat);
procedure glTexParameteri (target : GLenum; pname : GLenum; param : GLint);
procedure glTexParameterfv (target : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glTexParameteriv (target : GLenum;
pname : GLenum;
params : access GLint);
procedure glGetTexParameterfv (target : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetTexParameteriv (target : GLenum;
pname : GLenum;
params : access GLint);
procedure glGetTexLevelParameterfv (target : GLenum;
level : GLint;
pname : GLenum;
params : access GLfloat);
procedure glGetTexLevelParameteriv (target : GLenum;
level : GLint;
pname : GLenum;
params : access GLint);
procedure glTexImage1D (target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
border : GLint;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glTexImage2D (target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
height : GLsizei;
border : GLint;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glGetTexImage (target : GLenum;
level : GLint;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
-- 1.1 functions
procedure glGenTextures (n : GLsizei; textures : access GLuint);
procedure glDeleteTextures (n : GLsizei; textures : access GLuint);
procedure glBindTexture (target : GLenum; texture : GLuint);
procedure glPrioritizeTextures (n : GLsizei;
textures : access GLuint;
priorities : access GLclampf);
function glAreTexturesResident
(n : GLsizei; textures : access GLuint; residences : access GLboolean)
return GLboolean;
function glIsTexture (texture : GLuint) return GLboolean;
procedure glTexSubImage1D (target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glTexSubImage2D (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glCopyTexImage1D (target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
border : GLint);
procedure glCopyTexImage2D (target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
border : GLint);
procedure glCopyTexSubImage1D (target : GLenum;
level : GLint;
xoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyTexSubImage2D (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
--
-- Evaluators
--
procedure glMap1d (target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
stride : GLint;
order : GLint;
points : access GLdouble);
procedure glMap1f (target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
stride : GLint;
order : GLint;
points : access GLfloat);
procedure glMap2d (target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
ustride : GLint;
uorder : GLint;
v1 : GLdouble;
v2 : GLdouble;
vstride : GLint;
vorder : GLint;
points : access GLdouble);
procedure glMap2f (target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
ustride : GLint;
uorder : GLint;
v1 : GLfloat;
v2 : GLfloat;
vstride : GLint;
vorder : GLint;
points : access GLfloat);
procedure glGetMapdv
(target : GLenum; query : GLenum; v : access GLdouble);
procedure glGetMapfv (target : GLenum; query : GLenum; v : access GLfloat);
procedure glGetMapiv (target : GLenum; query : GLenum; v : access GLint);
procedure glEvalCoord1d (u : GLdouble);
procedure glEvalCoord1f (u : GLfloat);
procedure glEvalCoord1dv (u : access GLdouble);
procedure glEvalCoord1fv (u : access GLfloat);
procedure glEvalCoord2d (u : GLdouble; v : GLdouble);
procedure glEvalCoord2f (u : GLfloat; v : GLfloat);
procedure glEvalCoord2dv (u : access GLdouble);
procedure glEvalCoord2fv (u : access GLfloat);
procedure glMapGrid1d (un : GLint; u1 : GLdouble; u2 : GLdouble);
procedure glMapGrid1f (un : GLint; u1 : GLfloat; u2 : GLfloat);
procedure glMapGrid2d (un : GLint;
u1 : GLdouble;
u2 : GLdouble;
vn : GLint;
v1 : GLdouble;
v2 : GLdouble);
procedure glMapGrid2f (un : GLint;
u1 : GLfloat;
u2 : GLfloat;
vn : GLint;
v1 : GLfloat;
v2 : GLfloat);
procedure glEvalPoint1 (i : GLint);
procedure glEvalPoint2 (i : GLint; j : GLint);
procedure glEvalMesh1 (mode : GLenum; i1 : GLint; i2 : GLint);
procedure glEvalMesh2 (mode : GLenum;
i1 : GLint;
i2 : GLint;
j1 : GLint;
j2 : GLint);
--
-- Fog
--
procedure glFogf (pname : GLenum; param : GLfloat);
procedure glFogi (pname : GLenum; param : GLint);
procedure glFogfv (pname : GLenum; params : access GLfloat);
procedure glFogiv (pname : GLenum; params : access GLint);
--
-- Selection and Feedback
--
procedure glFeedbackBuffer (size : GLsizei;
type_Id : GLenum;
buffer : access GLfloat);
procedure glPassThrough (token : GLfloat);
procedure glSelectBuffer (size : GLsizei; buffer : access GLuint);
procedure glInitNames;
procedure glLoadName (name : GLuint);
procedure glPushName (name : GLuint);
procedure glPopName;
--
-- 1.0 Extensions
--
-- GL_EXT_blend_minmax
procedure glBlendEquationEXT (mode : GLenum);
-- GL_EXT_blend_color
procedure glBlendColorEXT (red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
-- GL_EXT_polygon_offset
procedure glPolygonOffsetEXT (factor : GLfloat; bias : GLfloat);
-- GL_EXT_vertex_array
procedure glVertexPointerEXT (size : GLint;
type_Id : GLenum;
stride : GLsizei;
count : GLsizei;
ptr : access GLvoid);
procedure glNormalPointerEXT (type_Id : GLenum;
stride : GLsizei;
count : GLsizei;
ptr : access GLvoid);
procedure glColorPointerEXT (size : GLint;
type_Id : GLenum;
stride : GLsizei;
count : GLsizei;
ptr : access GLvoid);
procedure glIndexPointerEXT (type_Id : GLenum;
stride : GLsizei;
count : GLsizei;
ptr : access GLvoid);
procedure glTexCoordPointerEXT (size : GLint;
type_Id : GLenum;
stride : GLsizei;
count : GLsizei;
ptr : access GLvoid);
procedure glEdgeFlagPointerEXT (stride : GLsizei;
count : GLsizei;
ptr : access GLboolean);
procedure glGetPointervEXT
(pname : GLenum;
params : access Interfaces.C.Extensions.Void_Ptr);
procedure glArrayElementEXT (i : GLint);
procedure glDrawArraysEXT (mode : GLenum; first : GLint; count : GLsizei);
-- GL_EXT_texture_object
procedure glGenTexturesEXT (n : GLsizei; textures : access GLuint);
procedure glDeleteTexturesEXT (n : GLsizei; textures : access GLuint);
procedure glBindTextureEXT (target : GLenum; texture : GLuint);
procedure glPrioritizeTexturesEXT (n : GLsizei;
textures : access GLuint;
priorities : access GLclampf);
function glAreTexturesResidentEXT
(n : GLsizei; textures : access GLuint; residences : access GLboolean)
return GLboolean;
function glIsTextureEXT (texture : GLuint) return GLboolean;
-- GL_EXT_texture3D
procedure glTexImage3DEXT (target : GLenum;
level : GLint;
internalFormat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glTexSubImage3DEXT (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glCopyTexSubImage3DEXT (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
-- GL_EXT_color_table
procedure glColorTableEXT (target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
type_Id : GLenum;
table : access GLvoid);
procedure glColorSubTableEXT (target : GLenum;
start : GLsizei;
count : GLsizei;
format : GLenum;
type_Id : GLenum;
data : access GLvoid);
procedure glGetColorTableEXT (target : GLenum;
format : GLenum;
type_Id : GLenum;
table : access GLvoid);
procedure glGetColorTableParameterfvEXT (target : GLenum;
pname : GLenum;
params : access GLfloat);
procedure glGetColorTableParameterivEXT (target : GLenum;
pname : GLenum;
params : access GLint);
-- GL_SGIS_multitexture
procedure glMultiTexCoord1dSGIS (target : GLenum; s : GLdouble);
procedure glMultiTexCoord1dvSGIS (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord1fSGIS (target : GLenum; s : GLfloat);
procedure glMultiTexCoord1fvSGIS (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord1iSGIS (target : GLenum; s : GLint);
procedure glMultiTexCoord1ivSGIS (target : GLenum; v : access GLint);
procedure glMultiTexCoord1sSGIS (target : GLenum; s : GLshort);
procedure glMultiTexCoord1svSGIS (target : GLenum; v : access GLshort);
procedure glMultiTexCoord2dSGIS (target : GLenum;
s : GLdouble;
t : GLdouble);
procedure glMultiTexCoord2dvSGIS (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord2fSGIS
(target : GLenum; s : GLfloat; t : GLfloat);
procedure glMultiTexCoord2fvSGIS (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord2iSGIS (target : GLenum; s : GLint; t : GLint);
procedure glMultiTexCoord2ivSGIS (target : GLenum; v : access GLint);
procedure glMultiTexCoord2sSGIS
(target : GLenum; s : GLshort; t : GLshort);
procedure glMultiTexCoord2svSGIS (target : GLenum; v : access GLshort);
procedure glMultiTexCoord3dSGIS (target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble);
procedure glMultiTexCoord3dvSGIS (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord3fSGIS (target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat);
procedure glMultiTexCoord3fvSGIS (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord3iSGIS (target : GLenum;
s : GLint;
t : GLint;
r : GLint);
procedure glMultiTexCoord3ivSGIS (target : GLenum; v : access GLint);
procedure glMultiTexCoord3sSGIS (target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort);
procedure glMultiTexCoord3svSGIS (target : GLenum; v : access GLshort);
procedure glMultiTexCoord4dSGIS (target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glMultiTexCoord4dvSGIS (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord4fSGIS (target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glMultiTexCoord4fvSGIS (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord4iSGIS (target : GLenum;
s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glMultiTexCoord4ivSGIS (target : GLenum; v : access GLint);
procedure glMultiTexCoord4sSGIS (target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glMultiTexCoord4svSGIS (target : GLenum; v : access GLshort);
procedure glMultiTexCoordPointerSGIS (target : GLenum;
size : GLint;
type_Id : GLenum;
stride : GLsizei;
pointer : access GLvoid);
procedure glSelectTextureSGIS (target : GLenum);
procedure glSelectTextureCoordSetSGIS (target : GLenum);
-- GL_EXT_multitexture
procedure glMultiTexCoord1dEXT (target : GLenum; s : GLdouble);
procedure glMultiTexCoord1dvEXT (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord1fEXT (target : GLenum; s : GLfloat);
procedure glMultiTexCoord1fvEXT (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord1iEXT (target : GLenum; s : GLint);
procedure glMultiTexCoord1ivEXT (target : GLenum; v : access GLint);
procedure glMultiTexCoord1sEXT (target : GLenum; s : GLshort);
procedure glMultiTexCoord1svEXT (target : GLenum; v : access GLshort);
procedure glMultiTexCoord2dEXT (target : GLenum;
s : GLdouble;
t : GLdouble);
procedure glMultiTexCoord2dvEXT (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord2fEXT (target : GLenum; s : GLfloat; t : GLfloat);
procedure glMultiTexCoord2fvEXT (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord2iEXT (target : GLenum; s : GLint; t : GLint);
procedure glMultiTexCoord2ivEXT (target : GLenum; v : access GLint);
procedure glMultiTexCoord2sEXT (target : GLenum; s : GLshort; t : GLshort);
procedure glMultiTexCoord2svEXT (target : GLenum; v : access GLshort);
procedure glMultiTexCoord3dEXT (target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble);
procedure glMultiTexCoord3dvEXT (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord3fEXT (target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat);
procedure glMultiTexCoord3fvEXT (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord3iEXT (target : GLenum;
s : GLint;
t : GLint;
r : GLint);
procedure glMultiTexCoord3ivEXT (target : GLenum; v : access GLint);
procedure glMultiTexCoord3sEXT (target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort);
procedure glMultiTexCoord3svEXT (target : GLenum; v : access GLshort);
procedure glMultiTexCoord4dEXT (target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glMultiTexCoord4dvEXT (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord4fEXT (target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glMultiTexCoord4fvEXT (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord4iEXT (target : GLenum;
s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glMultiTexCoord4ivEXT (target : GLenum; v : access GLint);
procedure glMultiTexCoord4sEXT (target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glMultiTexCoord4svEXT (target : GLenum; v : access GLshort);
procedure glInterleavedTextureCoordSetsEXT (factor : GLint);
procedure glSelectTextureEXT (target : GLenum);
procedure glSelectTextureCoordSetEXT (target : GLenum);
procedure glSelectTextureTransformEXT (target : GLenum);
-- GL_EXT_point_parameters
procedure glPointParameterfEXT (pname : GLenum; param : GLfloat);
procedure glPointParameterfvEXT (pname : GLenum; params : access GLfloat);
-- GL_MESA_window_pos
procedure glWindowPos2iMESA (x : GLint; y : GLint);
procedure glWindowPos2sMESA (x : GLshort; y : GLshort);
procedure glWindowPos2fMESA (x : GLfloat; y : GLfloat);
procedure glWindowPos2dMESA (x : GLdouble; y : GLdouble);
procedure glWindowPos2ivMESA (p : access GLint);
procedure glWindowPos2svMESA (p : access GLshort);
procedure glWindowPos2fvMESA (p : access GLfloat);
procedure glWindowPos2dvMESA (p : access GLdouble);
procedure glWindowPos3iMESA (x : GLint; y : GLint; z : GLint);
procedure glWindowPos3sMESA (x : GLshort; y : GLshort; z : GLshort);
procedure glWindowPos3fMESA (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glWindowPos3dMESA (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glWindowPos3ivMESA (p : access GLint);
procedure glWindowPos3svMESA (p : access GLshort);
procedure glWindowPos3fvMESA (p : access GLfloat);
procedure glWindowPos3dvMESA (p : access GLdouble);
procedure glWindowPos4iMESA (x : GLint; y : GLint; z : GLint; w : GLint);
procedure glWindowPos4sMESA (x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glWindowPos4fMESA (x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glWindowPos4dMESA (x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glWindowPos4ivMESA (p : access GLint);
procedure glWindowPos4svMESA (p : access GLshort);
procedure glWindowPos4fvMESA (p : access GLfloat);
procedure glWindowPos4dvMESA (p : access GLdouble);
-- GL_MESA_resize_buffers
procedure glResizeBuffersMESA;
-- 1.2 functions
procedure glDrawRangeElements (mode : GLenum;
start : GLuint;
end_Id : GLuint;
count : GLsizei;
type_Id : GLenum;
indices : access GLvoid);
procedure glTexImage3D (target : GLenum;
level : GLint;
internalFormat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glTexSubImage3D (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
type_Id : GLenum;
pixels : access GLvoid);
procedure glCopyTexSubImage3D (target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
--
-- Compile-time tests for extensions:
--
GL_EXT_blend_color : constant := 1;
GL_EXT_blend_logic_op : constant := 1;
GL_EXT_blend_minmax : constant := 1;
GL_EXT_blend_subtract : constant := 1;
GL_EXT_polygon_offset : constant := 1;
GL_EXT_vertex_array : constant := 1;
GL_EXT_texture_object : constant := 1;
GL_EXT_texture3D : constant := 1;
GL_EXT_paletted_texture : constant := 1;
GL_EXT_shared_texture_palette : constant := 1;
GL_EXT_point_parameters : constant := 1;
GL_EXT_rescale_normal : constant := 1;
GL_EXT_abgr : constant := 1;
GL_EXT_multitexture : constant := 1;
GL_MESA_window_pos : constant := 1;
GL_MESA_resize_buffers : constant := 1;
GL_SGIS_multitexture : constant := 1;
GL_SGIS_texture_edge_clamp : constant := 1;
private
pragma Import (Stdcall, glClearIndex, "glClearIndex");
pragma Import (Stdcall, glClearColor, "glClearColor");
pragma Import (Stdcall, glClear, "glClear");
pragma Import (Stdcall, glIndexMask, "glIndexMask");
pragma Import (Stdcall, glColorMask, "glColorMask");
pragma Import (Stdcall, glAlphaFunc, "glAlphaFunc");
pragma Import (Stdcall, glBlendFunc, "glBlendFunc");
pragma Import (Stdcall, glLogicOp, "glLogicOp");
pragma Import (Stdcall, glCullFace, "glCullFace");
pragma Import (Stdcall, glFrontFace, "glFrontFace");
pragma Import (Stdcall, glPointSize, "glPointSize");
pragma Import (Stdcall, glLineWidth, "glLineWidth");
pragma Import (Stdcall, glLineStipple, "glLineStipple");
pragma Import (Stdcall, glPolygonMode, "glPolygonMode");
pragma Import (Stdcall, glPolygonOffset, "glPolygonOffset");
pragma Import (Stdcall, glPolygonStipple, "glPolygonStipple");
pragma Import (Stdcall, glGetPolygonStipple, "glGetPolygonStipple");
pragma Import (Stdcall, glEdgeFlag, "glEdgeFlag");
pragma Import (Stdcall, glEdgeFlagv, "glEdgeFlagv");
pragma Import (Stdcall, glScissor, "glScissor");
pragma Import (Stdcall, glClipPlane, "glClipPlane");
pragma Import (Stdcall, glGetClipPlane, "glGetClipPlane");
pragma Import (Stdcall, glDrawBuffer, "glDrawBuffer");
pragma Import (Stdcall, glReadBuffer, "glReadBuffer");
pragma Import (Stdcall, glEnable, "glEnable");
pragma Import (Stdcall, glDisable, "glDisable");
pragma Import (Stdcall, glIsEnabled, "glIsEnabled");
pragma Import (Stdcall, glEnableClientState, "glEnableClientState");
pragma Import (Stdcall, glDisableClientState, "glDisableClientState");
pragma Import (Stdcall, glGetBooleanv, "glGetBooleanv");
pragma Import (Stdcall, glGetDoublev, "glGetDoublev");
pragma Import (Stdcall, glGetFloatv, "glGetFloatv");
pragma Import (Stdcall, glGetIntegerv, "glGetIntegerv");
pragma Import (Stdcall, glPushAttrib, "glPushAttrib");
pragma Import (Stdcall, glPopAttrib, "glPopAttrib");
pragma Import (Stdcall, glPushClientAttrib, "glPushClientAttrib");
pragma Import (Stdcall, glPopClientAttrib, "glPopClientAttrib");
pragma Import (Stdcall, glRenderMode, "glRenderMode");
pragma Import (Stdcall, glGetError, "glGetError");
pragma Import (Stdcall, glGetString, "glGetString");
pragma Import (Stdcall, glFinish, "glFinish");
pragma Import (Stdcall, glFlush, "glFlush");
pragma Import (Stdcall, glHint, "glHint");
pragma Import (Stdcall, glClearDepth, "glClearDepth");
pragma Import (Stdcall, glDepthFunc, "glDepthFunc");
pragma Import (Stdcall, glDepthMask, "glDepthMask");
pragma Import (Stdcall, glDepthRange, "glDepthRange");
pragma Import (Stdcall, glClearAccum, "glClearAccum");
pragma Import (Stdcall, glAccum, "glAccum");
pragma Import (Stdcall, glMatrixMode, "glMatrixMode");
pragma Import (Stdcall, glOrtho, "glOrtho");
pragma Import (Stdcall, glFrustum, "glFrustum");
pragma Import (Stdcall, glViewport, "glViewport");
pragma Import (Stdcall, glPushMatrix, "glPushMatrix");
pragma Import (Stdcall, glPopMatrix, "glPopMatrix");
pragma Import (Stdcall, glLoadIdentity, "glLoadIdentity");
pragma Import (Stdcall, glLoadMatrixd, "glLoadMatrixd");
pragma Import (Stdcall, glLoadMatrixf, "glLoadMatrixf");
pragma Import (Stdcall, glMultMatrixd, "glMultMatrixd");
pragma Import (Stdcall, glMultMatrixf, "glMultMatrixf");
pragma Import (Stdcall, glRotated, "glRotated");
pragma Import (Stdcall, glRotatef, "glRotatef");
pragma Import (Stdcall, glScaled, "glScaled");
pragma Import (Stdcall, glScalef, "glScalef");
pragma Import (Stdcall, glTranslated, "glTranslated");
pragma Import (Stdcall, glTranslatef, "glTranslatef");
pragma Import (Stdcall, glIsList, "glIsList");
pragma Import (Stdcall, glDeleteLists, "glDeleteLists");
pragma Import (Stdcall, glGenLists, "glGenLists");
pragma Import (Stdcall, glNewList, "glNewList");
pragma Import (Stdcall, glEndList, "glEndList");
pragma Import (Stdcall, glCallList, "glCallList");
pragma Import (Stdcall, glCallLists, "glCallLists");
pragma Import (Stdcall, glListBase, "glListBase");
pragma Import (Stdcall, glBegin, "glBegin");
pragma Import (Stdcall, glEnd, "glEnd");
pragma Import (Stdcall, glVertex2d, "glVertex2d");
pragma Import (Stdcall, glVertex2f, "glVertex2f");
pragma Import (Stdcall, glVertex2i, "glVertex2i");
pragma Import (Stdcall, glVertex2s, "glVertex2s");
pragma Import (Stdcall, glVertex3d, "glVertex3d");
pragma Import (Stdcall, glVertex3f, "glVertex3f");
pragma Import (Stdcall, glVertex3i, "glVertex3i");
pragma Import (Stdcall, glVertex3s, "glVertex3s");
pragma Import (Stdcall, glVertex4d, "glVertex4d");
pragma Import (Stdcall, glVertex4f, "glVertex4f");
pragma Import (Stdcall, glVertex4i, "glVertex4i");
pragma Import (Stdcall, glVertex4s, "glVertex4s");
pragma Import (Stdcall, glVertex2dv, "glVertex2dv");
pragma Import (Stdcall, glVertex2fv, "glVertex2fv");
pragma Import (Stdcall, glVertex2iv, "glVertex2iv");
pragma Import (Stdcall, glVertex2sv, "glVertex2sv");
pragma Import (Stdcall, glVertex3dv, "glVertex3dv");
pragma Import (Stdcall, glVertex3fv, "glVertex3fv");
pragma Import (Stdcall, glVertex3iv, "glVertex3iv");
pragma Import (Stdcall, glVertex3sv, "glVertex3sv");
pragma Import (Stdcall, glVertex4dv, "glVertex4dv");
pragma Import (Stdcall, glVertex4fv, "glVertex4fv");
pragma Import (Stdcall, glVertex4iv, "glVertex4iv");
pragma Import (Stdcall, glVertex4sv, "glVertex4sv");
pragma Import (Stdcall, glNormal3b, "glNormal3b");
pragma Import (Stdcall, glNormal3d, "glNormal3d");
pragma Import (Stdcall, glNormal3f, "glNormal3f");
pragma Import (Stdcall, glNormal3i, "glNormal3i");
pragma Import (Stdcall, glNormal3s, "glNormal3s");
pragma Import (Stdcall, glNormal3bv, "glNormal3bv");
pragma Import (Stdcall, glNormal3dv, "glNormal3dv");
pragma Import (Stdcall, glNormal3fv, "glNormal3fv");
pragma Import (Stdcall, glNormal3iv, "glNormal3iv");
pragma Import (Stdcall, glNormal3sv, "glNormal3sv");
pragma Import (Stdcall, glIndexd, "glIndexd");
pragma Import (Stdcall, glIndexf, "glIndexf");
pragma Import (Stdcall, glIndexi, "glIndexi");
pragma Import (Stdcall, glIndexs, "glIndexs");
pragma Import (Stdcall, glIndexub, "glIndexub");
pragma Import (Stdcall, glIndexdv, "glIndexdv");
pragma Import (Stdcall, glIndexfv, "glIndexfv");
pragma Import (Stdcall, glIndexiv, "glIndexiv");
pragma Import (Stdcall, glIndexsv, "glIndexsv");
pragma Import (Stdcall, glIndexubv, "glIndexubv");
pragma Import (Stdcall, glColor3b, "glColor3b");
pragma Import (Stdcall, glColor3d, "glColor3d");
pragma Import (Stdcall, glColor3f, "glColor3f");
pragma Import (Stdcall, glColor3i, "glColor3i");
pragma Import (Stdcall, glColor3s, "glColor3s");
pragma Import (Stdcall, glColor3ub, "glColor3ub");
pragma Import (Stdcall, glColor3ui, "glColor3ui");
pragma Import (Stdcall, glColor3us, "glColor3us");
pragma Import (Stdcall, glColor4b, "glColor4b");
pragma Import (Stdcall, glColor4d, "glColor4d");
pragma Import (Stdcall, glColor4f, "glColor4f");
pragma Import (Stdcall, glColor4i, "glColor4i");
pragma Import (Stdcall, glColor4s, "glColor4s");
pragma Import (Stdcall, glColor4ub, "glColor4ub");
pragma Import (Stdcall, glColor4ui, "glColor4ui");
pragma Import (Stdcall, glColor4us, "glColor4us");
pragma Import (Stdcall, glColor3bv, "glColor3bv");
pragma Import (Stdcall, glColor3dv, "glColor3dv");
pragma Import (Stdcall, glColor3fv, "glColor3fv");
pragma Import (Stdcall, glColor3iv, "glColor3iv");
pragma Import (Stdcall, glColor3sv, "glColor3sv");
pragma Import (Stdcall, glColor3ubv, "glColor3ubv");
pragma Import (Stdcall, glColor3uiv, "glColor3uiv");
pragma Import (Stdcall, glColor3usv, "glColor3usv");
pragma Import (Stdcall, glColor4bv, "glColor4bv");
pragma Import (Stdcall, glColor4dv, "glColor4dv");
pragma Import (Stdcall, glColor4fv, "glColor4fv");
pragma Import (Stdcall, glColor4iv, "glColor4iv");
pragma Import (Stdcall, glColor4sv, "glColor4sv");
pragma Import (Stdcall, glColor4ubv, "glColor4ubv");
pragma Import (Stdcall, glColor4uiv, "glColor4uiv");
pragma Import (Stdcall, glColor4usv, "glColor4usv");
pragma Import (Stdcall, glTexCoord1d, "glTexCoord1d");
pragma Import (Stdcall, glTexCoord1f, "glTexCoord1f");
pragma Import (Stdcall, glTexCoord1i, "glTexCoord1i");
pragma Import (Stdcall, glTexCoord1s, "glTexCoord1s");
pragma Import (Stdcall, glTexCoord2d, "glTexCoord2d");
pragma Import (Stdcall, glTexCoord2f, "glTexCoord2f");
pragma Import (Stdcall, glTexCoord2i, "glTexCoord2i");
pragma Import (Stdcall, glTexCoord2s, "glTexCoord2s");
pragma Import (Stdcall, glTexCoord3d, "glTexCoord3d");
pragma Import (Stdcall, glTexCoord3f, "glTexCoord3f");
pragma Import (Stdcall, glTexCoord3i, "glTexCoord3i");
pragma Import (Stdcall, glTexCoord3s, "glTexCoord3s");
pragma Import (Stdcall, glTexCoord4d, "glTexCoord4d");
pragma Import (Stdcall, glTexCoord4f, "glTexCoord4f");
pragma Import (Stdcall, glTexCoord4i, "glTexCoord4i");
pragma Import (Stdcall, glTexCoord4s, "glTexCoord4s");
pragma Import (Stdcall, glTexCoord1dv, "glTexCoord1dv");
pragma Import (Stdcall, glTexCoord1fv, "glTexCoord1fv");
pragma Import (Stdcall, glTexCoord1iv, "glTexCoord1iv");
pragma Import (Stdcall, glTexCoord1sv, "glTexCoord1sv");
pragma Import (Stdcall, glTexCoord2dv, "glTexCoord2dv");
pragma Import (Stdcall, glTexCoord2fv, "glTexCoord2fv");
pragma Import (Stdcall, glTexCoord2iv, "glTexCoord2iv");
pragma Import (Stdcall, glTexCoord2sv, "glTexCoord2sv");
pragma Import (Stdcall, glTexCoord3dv, "glTexCoord3dv");
pragma Import (Stdcall, glTexCoord3fv, "glTexCoord3fv");
pragma Import (Stdcall, glTexCoord3iv, "glTexCoord3iv");
pragma Import (Stdcall, glTexCoord3sv, "glTexCoord3sv");
pragma Import (Stdcall, glTexCoord4dv, "glTexCoord4dv");
pragma Import (Stdcall, glTexCoord4fv, "glTexCoord4fv");
pragma Import (Stdcall, glTexCoord4iv, "glTexCoord4iv");
pragma Import (Stdcall, glTexCoord4sv, "glTexCoord4sv");
pragma Import (Stdcall, glRasterPos2d, "glRasterPos2d");
pragma Import (Stdcall, glRasterPos2f, "glRasterPos2f");
pragma Import (Stdcall, glRasterPos2i, "glRasterPos2i");
pragma Import (Stdcall, glRasterPos2s, "glRasterPos2s");
pragma Import (Stdcall, glRasterPos3d, "glRasterPos3d");
pragma Import (Stdcall, glRasterPos3f, "glRasterPos3f");
pragma Import (Stdcall, glRasterPos3i, "glRasterPos3i");
pragma Import (Stdcall, glRasterPos3s, "glRasterPos3s");
pragma Import (Stdcall, glRasterPos4d, "glRasterPos4d");
pragma Import (Stdcall, glRasterPos4f, "glRasterPos4f");
pragma Import (Stdcall, glRasterPos4i, "glRasterPos4i");
pragma Import (Stdcall, glRasterPos4s, "glRasterPos4s");
pragma Import (Stdcall, glRasterPos2dv, "glRasterPos2dv");
pragma Import (Stdcall, glRasterPos2fv, "glRasterPos2fv");
pragma Import (Stdcall, glRasterPos2iv, "glRasterPos2iv");
pragma Import (Stdcall, glRasterPos2sv, "glRasterPos2sv");
pragma Import (Stdcall, glRasterPos3dv, "glRasterPos3dv");
pragma Import (Stdcall, glRasterPos3fv, "glRasterPos3fv");
pragma Import (Stdcall, glRasterPos3iv, "glRasterPos3iv");
pragma Import (Stdcall, glRasterPos3sv, "glRasterPos3sv");
pragma Import (Stdcall, glRasterPos4dv, "glRasterPos4dv");
pragma Import (Stdcall, glRasterPos4fv, "glRasterPos4fv");
pragma Import (Stdcall, glRasterPos4iv, "glRasterPos4iv");
pragma Import (Stdcall, glRasterPos4sv, "glRasterPos4sv");
pragma Import (Stdcall, glRectd, "glRectd");
pragma Import (Stdcall, glRectf, "glRectf");
pragma Import (Stdcall, glRecti, "glRecti");
pragma Import (Stdcall, glRects, "glRects");
pragma Import (Stdcall, glRectdv, "glRectdv");
pragma Import (Stdcall, glRectfv, "glRectfv");
pragma Import (Stdcall, glRectiv, "glRectiv");
pragma Import (Stdcall, glRectsv, "glRectsv");
pragma Import (Stdcall, glVertexPointer, "glVertexPointer");
pragma Import (Stdcall, glNormalPointer, "glNormalPointer");
pragma Import (Stdcall, glColorPointer, "glColorPointer");
pragma Import (Stdcall, glIndexPointer, "glIndexPointer");
pragma Import (Stdcall, glTexCoordPointer, "glTexCoordPointer");
pragma Import (Stdcall, glEdgeFlagPointer, "glEdgeFlagPointer");
pragma Import (Stdcall, glGetPointerv, "glGetPointerv");
pragma Import (Stdcall, glArrayElement, "glArrayElement");
pragma Import (Stdcall, glDrawArrays, "glDrawArrays");
pragma Import (Stdcall, glDrawElements, "glDrawElements");
pragma Import (Stdcall, glInterleavedArrays, "glInterleavedArrays");
pragma Import (Stdcall, glShadeModel, "glShadeModel");
pragma Import (Stdcall, glLightf, "glLightf");
pragma Import (Stdcall, glLighti, "glLighti");
pragma Import (Stdcall, glLightfv, "glLightfv");
pragma Import (Stdcall, glLightiv, "glLightiv");
pragma Import (Stdcall, glGetLightfv, "glGetLightfv");
pragma Import (Stdcall, glGetLightiv, "glGetLightiv");
pragma Import (Stdcall, glLightModelf, "glLightModelf");
pragma Import (Stdcall, glLightModeli, "glLightModeli");
pragma Import (Stdcall, glLightModelfv, "glLightModelfv");
pragma Import (Stdcall, glLightModeliv, "glLightModeliv");
pragma Import (Stdcall, glMaterialf, "glMaterialf");
pragma Import (Stdcall, glMateriali, "glMateriali");
pragma Import (Stdcall, glMaterialfv, "glMaterialfv");
pragma Import (Stdcall, glMaterialiv, "glMaterialiv");
pragma Import (Stdcall, glGetMaterialfv, "glGetMaterialfv");
pragma Import (Stdcall, glGetMaterialiv, "glGetMaterialiv");
pragma Import (Stdcall, glColorMaterial, "glColorMaterial");
pragma Import (Stdcall, glPixelZoom, "glPixelZoom");
pragma Import (Stdcall, glPixelStoref, "glPixelStoref");
pragma Import (Stdcall, glPixelStorei, "glPixelStorei");
pragma Import (Stdcall, glPixelTransferf, "glPixelTransferf");
pragma Import (Stdcall, glPixelTransferi, "glPixelTransferi");
pragma Import (Stdcall, glPixelMapfv, "glPixelMapfv");
pragma Import (Stdcall, glPixelMapuiv, "glPixelMapuiv");
pragma Import (Stdcall, glPixelMapusv, "glPixelMapusv");
pragma Import (Stdcall, glGetPixelMapfv, "glGetPixelMapfv");
pragma Import (Stdcall, glGetPixelMapuiv, "glGetPixelMapuiv");
pragma Import (Stdcall, glGetPixelMapusv, "glGetPixelMapusv");
pragma Import (Stdcall, glBitmap, "glBitmap");
pragma Import (Stdcall, glReadPixels, "glReadPixels");
pragma Import (Stdcall, glDrawPixels, "glDrawPixels");
pragma Import (Stdcall, glCopyPixels, "glCopyPixels");
pragma Import (Stdcall, glStencilFunc, "glStencilFunc");
pragma Import (Stdcall, glStencilMask, "glStencilMask");
pragma Import (Stdcall, glStencilOp, "glStencilOp");
pragma Import (Stdcall, glClearStencil, "glClearStencil");
pragma Import (Stdcall, glTexGend, "glTexGend");
pragma Import (Stdcall, glTexGenf, "glTexGenf");
pragma Import (Stdcall, glTexGeni, "glTexGeni");
pragma Import (Stdcall, glTexGendv, "glTexGendv");
pragma Import (Stdcall, glTexGenfv, "glTexGenfv");
pragma Import (Stdcall, glTexGeniv, "glTexGeniv");
pragma Import (Stdcall, glGetTexGendv, "glGetTexGendv");
pragma Import (Stdcall, glGetTexGenfv, "glGetTexGenfv");
pragma Import (Stdcall, glGetTexGeniv, "glGetTexGeniv");
pragma Import (Stdcall, glTexEnvf, "glTexEnvf");
pragma Import (Stdcall, glTexEnvi, "glTexEnvi");
pragma Import (Stdcall, glTexEnvfv, "glTexEnvfv");
pragma Import (Stdcall, glTexEnviv, "glTexEnviv");
pragma Import (Stdcall, glGetTexEnvfv, "glGetTexEnvfv");
pragma Import (Stdcall, glGetTexEnviv, "glGetTexEnviv");
pragma Import (Stdcall, glTexParameterf, "glTexParameterf");
pragma Import (Stdcall, glTexParameteri, "glTexParameteri");
pragma Import (Stdcall, glTexParameterfv, "glTexParameterfv");
pragma Import (Stdcall, glTexParameteriv, "glTexParameteriv");
pragma Import (Stdcall, glGetTexParameterfv, "glGetTexParameterfv");
pragma Import (Stdcall, glGetTexParameteriv, "glGetTexParameteriv");
pragma Import (Stdcall, glGetTexLevelParameterfv, "glGetTexLevelParameterfv");
pragma Import (Stdcall, glGetTexLevelParameteriv, "glGetTexLevelParameteriv");
pragma Import (Stdcall, glTexImage1D, "glTexImage1D");
pragma Import (Stdcall, glTexImage2D, "glTexImage2D");
pragma Import (Stdcall, glGetTexImage, "glGetTexImage");
pragma Import (Stdcall, glGenTextures, "glGenTextures");
pragma Import (Stdcall, glDeleteTextures, "glDeleteTextures");
pragma Import (Stdcall, glBindTexture, "glBindTexture");
pragma Import (Stdcall, glPrioritizeTextures, "glPrioritizeTextures");
pragma Import (Stdcall, glAreTexturesResident, "glAreTexturesResident");
pragma Import (Stdcall, glIsTexture, "glIsTexture");
pragma Import (Stdcall, glTexSubImage1D, "glTexSubImage1D");
pragma Import (Stdcall, glTexSubImage2D, "glTexSubImage2D");
pragma Import (Stdcall, glCopyTexImage1D, "glCopyTexImage1D");
pragma Import (Stdcall, glCopyTexImage2D, "glCopyTexImage2D");
pragma Import (Stdcall, glCopyTexSubImage1D, "glCopyTexSubImage1D");
pragma Import (Stdcall, glCopyTexSubImage2D, "glCopyTexSubImage2D");
pragma Import (Stdcall, glMap1d, "glMap1d");
pragma Import (Stdcall, glMap1f, "glMap1f");
pragma Import (Stdcall, glMap2d, "glMap2d");
pragma Import (Stdcall, glMap2f, "glMap2f");
pragma Import (Stdcall, glGetMapdv, "glGetMapdv");
pragma Import (Stdcall, glGetMapfv, "glGetMapfv");
pragma Import (Stdcall, glGetMapiv, "glGetMapiv");
pragma Import (Stdcall, glEvalCoord1d, "glEvalCoord1d");
pragma Import (Stdcall, glEvalCoord1f, "glEvalCoord1f");
pragma Import (Stdcall, glEvalCoord1dv, "glEvalCoord1dv");
pragma Import (Stdcall, glEvalCoord1fv, "glEvalCoord1fv");
pragma Import (Stdcall, glEvalCoord2d, "glEvalCoord2d");
pragma Import (Stdcall, glEvalCoord2f, "glEvalCoord2f");
pragma Import (Stdcall, glEvalCoord2dv, "glEvalCoord2dv");
pragma Import (Stdcall, glEvalCoord2fv, "glEvalCoord2fv");
pragma Import (Stdcall, glMapGrid1d, "glMapGrid1d");
pragma Import (Stdcall, glMapGrid1f, "glMapGrid1f");
pragma Import (Stdcall, glMapGrid2d, "glMapGrid2d");
pragma Import (Stdcall, glMapGrid2f, "glMapGrid2f");
pragma Import (Stdcall, glEvalPoint1, "glEvalPoint1");
pragma Import (Stdcall, glEvalPoint2, "glEvalPoint2");
pragma Import (Stdcall, glEvalMesh1, "glEvalMesh1");
pragma Import (Stdcall, glEvalMesh2, "glEvalMesh2");
pragma Import (Stdcall, glFogf, "glFogf");
pragma Import (Stdcall, glFogi, "glFogi");
pragma Import (Stdcall, glFogfv, "glFogfv");
pragma Import (Stdcall, glFogiv, "glFogiv");
pragma Import (Stdcall, glFeedbackBuffer, "glFeedbackBuffer");
pragma Import (Stdcall, glPassThrough, "glPassThrough");
pragma Import (Stdcall, glSelectBuffer, "glSelectBuffer");
pragma Import (Stdcall, glInitNames, "glInitNames");
pragma Import (Stdcall, glLoadName, "glLoadName");
pragma Import (Stdcall, glPushName, "glPushName");
pragma Import (Stdcall, glPopName, "glPopName");
pragma Import (Stdcall, glBlendEquationEXT, "glBlendEquationEXT");
pragma Import (Stdcall, glBlendColorEXT, "glBlendColorEXT");
pragma Import (Stdcall, glPolygonOffsetEXT, "glPolygonOffsetEXT");
pragma Import (Stdcall, glVertexPointerEXT, "glVertexPointerEXT");
pragma Import (Stdcall, glNormalPointerEXT, "glNormalPointerEXT");
pragma Import (Stdcall, glColorPointerEXT, "glColorPointerEXT");
pragma Import (Stdcall, glIndexPointerEXT, "glIndexPointerEXT");
pragma Import (Stdcall, glTexCoordPointerEXT, "glTexCoordPointerEXT");
pragma Import (Stdcall, glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT");
pragma Import (Stdcall, glGetPointervEXT, "glGetPointervEXT");
pragma Import (Stdcall, glArrayElementEXT, "glArrayElementEXT");
pragma Import (Stdcall, glDrawArraysEXT, "glDrawArraysEXT");
pragma Import (Stdcall, glGenTexturesEXT, "glGenTexturesEXT");
pragma Import (Stdcall, glDeleteTexturesEXT, "glDeleteTexturesEXT");
pragma Import (Stdcall, glBindTextureEXT, "glBindTextureEXT");
pragma Import (Stdcall, glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT");
pragma Import (Stdcall, glAreTexturesResidentEXT, "glAreTexturesResidentEXT");
pragma Import (Stdcall, glIsTextureEXT, "glIsTextureEXT");
pragma Import (Stdcall, glTexImage3DEXT, "glTexImage3DEXT");
pragma Import (Stdcall, glTexSubImage3DEXT, "glTexSubImage3DEXT");
pragma Import (Stdcall, glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT");
pragma Import (Stdcall, glColorTableEXT, "glColorTableEXT");
pragma Import (Stdcall, glColorSubTableEXT, "glColorSubTableEXT");
pragma Import (Stdcall, glGetColorTableEXT, "glGetColorTableEXT");
pragma Import (Stdcall,
glGetColorTableParameterfvEXT,
"glGetColorTableParameterfvEXT");
pragma Import (Stdcall,
glGetColorTableParameterivEXT,
"glGetColorTableParameterivEXT");
pragma Import (Stdcall, glMultiTexCoord1dSGIS, "glMultiTexCoord1dSGIS");
pragma Import (Stdcall, glMultiTexCoord1dvSGIS, "glMultiTexCoord1dvSGIS");
pragma Import (Stdcall, glMultiTexCoord1fSGIS, "glMultiTexCoord1fSGIS");
pragma Import (Stdcall, glMultiTexCoord1fvSGIS, "glMultiTexCoord1fvSGIS");
pragma Import (Stdcall, glMultiTexCoord1iSGIS, "glMultiTexCoord1iSGIS");
pragma Import (Stdcall, glMultiTexCoord1ivSGIS, "glMultiTexCoord1ivSGIS");
pragma Import (Stdcall, glMultiTexCoord1sSGIS, "glMultiTexCoord1sSGIS");
pragma Import (Stdcall, glMultiTexCoord1svSGIS, "glMultiTexCoord1svSGIS");
pragma Import (Stdcall, glMultiTexCoord2dSGIS, "glMultiTexCoord2dSGIS");
pragma Import (Stdcall, glMultiTexCoord2dvSGIS, "glMultiTexCoord2dvSGIS");
pragma Import (Stdcall, glMultiTexCoord2fSGIS, "glMultiTexCoord2fSGIS");
pragma Import (Stdcall, glMultiTexCoord2fvSGIS, "glMultiTexCoord2fvSGIS");
pragma Import (Stdcall, glMultiTexCoord2iSGIS, "glMultiTexCoord2iSGIS");
pragma Import (Stdcall, glMultiTexCoord2ivSGIS, "glMultiTexCoord2ivSGIS");
pragma Import (Stdcall, glMultiTexCoord2sSGIS, "glMultiTexCoord2sSGIS");
pragma Import (Stdcall, glMultiTexCoord2svSGIS, "glMultiTexCoord2svSGIS");
pragma Import (Stdcall, glMultiTexCoord3dSGIS, "glMultiTexCoord3dSGIS");
pragma Import (Stdcall, glMultiTexCoord3dvSGIS, "glMultiTexCoord3dvSGIS");
pragma Import (Stdcall, glMultiTexCoord3fSGIS, "glMultiTexCoord3fSGIS");
pragma Import (Stdcall, glMultiTexCoord3fvSGIS, "glMultiTexCoord3fvSGIS");
pragma Import (Stdcall, glMultiTexCoord3iSGIS, "glMultiTexCoord3iSGIS");
pragma Import (Stdcall, glMultiTexCoord3ivSGIS, "glMultiTexCoord3ivSGIS");
pragma Import (Stdcall, glMultiTexCoord3sSGIS, "glMultiTexCoord3sSGIS");
pragma Import (Stdcall, glMultiTexCoord3svSGIS, "glMultiTexCoord3svSGIS");
pragma Import (Stdcall, glMultiTexCoord4dSGIS, "glMultiTexCoord4dSGIS");
pragma Import (Stdcall, glMultiTexCoord4dvSGIS, "glMultiTexCoord4dvSGIS");
pragma Import (Stdcall, glMultiTexCoord4fSGIS, "glMultiTexCoord4fSGIS");
pragma Import (Stdcall, glMultiTexCoord4fvSGIS, "glMultiTexCoord4fvSGIS");
pragma Import (Stdcall, glMultiTexCoord4iSGIS, "glMultiTexCoord4iSGIS");
pragma Import (Stdcall, glMultiTexCoord4ivSGIS, "glMultiTexCoord4ivSGIS");
pragma Import (Stdcall, glMultiTexCoord4sSGIS, "glMultiTexCoord4sSGIS");
pragma Import (Stdcall, glMultiTexCoord4svSGIS, "glMultiTexCoord4svSGIS");
pragma Import (Stdcall,
glMultiTexCoordPointerSGIS,
"glMultiTexCoordPointerSGIS");
pragma Import (Stdcall, glSelectTextureSGIS, "glSelectTextureSGIS");
pragma Import (Stdcall,
glSelectTextureCoordSetSGIS,
"glSelectTextureCoordSetSGIS");
pragma Import (Stdcall, glMultiTexCoord1dEXT, "glMultiTexCoord1dEXT");
pragma Import (Stdcall, glMultiTexCoord1dvEXT, "glMultiTexCoord1dvEXT");
pragma Import (Stdcall, glMultiTexCoord1fEXT, "glMultiTexCoord1fEXT");
pragma Import (Stdcall, glMultiTexCoord1fvEXT, "glMultiTexCoord1fvEXT");
pragma Import (Stdcall, glMultiTexCoord1iEXT, "glMultiTexCoord1iEXT");
pragma Import (Stdcall, glMultiTexCoord1ivEXT, "glMultiTexCoord1ivEXT");
pragma Import (Stdcall, glMultiTexCoord1sEXT, "glMultiTexCoord1sEXT");
pragma Import (Stdcall, glMultiTexCoord1svEXT, "glMultiTexCoord1svEXT");
pragma Import (Stdcall, glMultiTexCoord2dEXT, "glMultiTexCoord2dEXT");
pragma Import (Stdcall, glMultiTexCoord2dvEXT, "glMultiTexCoord2dvEXT");
pragma Import (Stdcall, glMultiTexCoord2fEXT, "glMultiTexCoord2fEXT");
pragma Import (Stdcall, glMultiTexCoord2fvEXT, "glMultiTexCoord2fvEXT");
pragma Import (Stdcall, glMultiTexCoord2iEXT, "glMultiTexCoord2iEXT");
pragma Import (Stdcall, glMultiTexCoord2ivEXT, "glMultiTexCoord2ivEXT");
pragma Import (Stdcall, glMultiTexCoord2sEXT, "glMultiTexCoord2sEXT");
pragma Import (Stdcall, glMultiTexCoord2svEXT, "glMultiTexCoord2svEXT");
pragma Import (Stdcall, glMultiTexCoord3dEXT, "glMultiTexCoord3dEXT");
pragma Import (Stdcall, glMultiTexCoord3dvEXT, "glMultiTexCoord3dvEXT");
pragma Import (Stdcall, glMultiTexCoord3fEXT, "glMultiTexCoord3fEXT");
pragma Import (Stdcall, glMultiTexCoord3fvEXT, "glMultiTexCoord3fvEXT");
pragma Import (Stdcall, glMultiTexCoord3iEXT, "glMultiTexCoord3iEXT");
pragma Import (Stdcall, glMultiTexCoord3ivEXT, "glMultiTexCoord3ivEXT");
pragma Import (Stdcall, glMultiTexCoord3sEXT, "glMultiTexCoord3sEXT");
pragma Import (Stdcall, glMultiTexCoord3svEXT, "glMultiTexCoord3svEXT");
pragma Import (Stdcall, glMultiTexCoord4dEXT, "glMultiTexCoord4dEXT");
pragma Import (Stdcall, glMultiTexCoord4dvEXT, "glMultiTexCoord4dvEXT");
pragma Import (Stdcall, glMultiTexCoord4fEXT, "glMultiTexCoord4fEXT");
pragma Import (Stdcall, glMultiTexCoord4fvEXT, "glMultiTexCoord4fvEXT");
pragma Import (Stdcall, glMultiTexCoord4iEXT, "glMultiTexCoord4iEXT");
pragma Import (Stdcall, glMultiTexCoord4ivEXT, "glMultiTexCoord4ivEXT");
pragma Import (Stdcall, glMultiTexCoord4sEXT, "glMultiTexCoord4sEXT");
pragma Import (Stdcall, glMultiTexCoord4svEXT, "glMultiTexCoord4svEXT");
pragma Import (Stdcall,
glInterleavedTextureCoordSetsEXT,
"glInterleavedTextureCoordSetsEXT");
pragma Import (Stdcall, glSelectTextureEXT, "glSelectTextureEXT");
pragma Import (Stdcall,
glSelectTextureCoordSetEXT,
"glSelectTextureCoordSetEXT");
pragma Import (Stdcall,
glSelectTextureTransformEXT,
"glSelectTextureTransformEXT");
pragma Import (Stdcall, glPointParameterfEXT, "glPointParameterfEXT");
pragma Import (Stdcall, glPointParameterfvEXT, "glPointParameterfvEXT");
pragma Import (Stdcall, glWindowPos2iMESA, "glWindowPos2iMESA");
pragma Import (Stdcall, glWindowPos2sMESA, "glWindowPos2sMESA");
pragma Import (Stdcall, glWindowPos2fMESA, "glWindowPos2fMESA");
pragma Import (Stdcall, glWindowPos2dMESA, "glWindowPos2dMESA");
pragma Import (Stdcall, glWindowPos2ivMESA, "glWindowPos2ivMESA");
pragma Import (Stdcall, glWindowPos2svMESA, "glWindowPos2svMESA");
pragma Import (Stdcall, glWindowPos2fvMESA, "glWindowPos2fvMESA");
pragma Import (Stdcall, glWindowPos2dvMESA, "glWindowPos2dvMESA");
pragma Import (Stdcall, glWindowPos3iMESA, "glWindowPos3iMESA");
pragma Import (Stdcall, glWindowPos3sMESA, "glWindowPos3sMESA");
pragma Import (Stdcall, glWindowPos3fMESA, "glWindowPos3fMESA");
pragma Import (Stdcall, glWindowPos3dMESA, "glWindowPos3dMESA");
pragma Import (Stdcall, glWindowPos3ivMESA, "glWindowPos3ivMESA");
pragma Import (Stdcall, glWindowPos3svMESA, "glWindowPos3svMESA");
pragma Import (Stdcall, glWindowPos3fvMESA, "glWindowPos3fvMESA");
pragma Import (Stdcall, glWindowPos3dvMESA, "glWindowPos3dvMESA");
pragma Import (Stdcall, glWindowPos4iMESA, "glWindowPos4iMESA");
pragma Import (Stdcall, glWindowPos4sMESA, "glWindowPos4sMESA");
pragma Import (Stdcall, glWindowPos4fMESA, "glWindowPos4fMESA");
pragma Import (Stdcall, glWindowPos4dMESA, "glWindowPos4dMESA");
pragma Import (Stdcall, glWindowPos4ivMESA, "glWindowPos4ivMESA");
pragma Import (Stdcall, glWindowPos4svMESA, "glWindowPos4svMESA");
pragma Import (Stdcall, glWindowPos4fvMESA, "glWindowPos4fvMESA");
pragma Import (Stdcall, glWindowPos4dvMESA, "glWindowPos4dvMESA");
pragma Import (Stdcall, glResizeBuffersMESA, "glResizeBuffersMESA");
pragma Import (Stdcall, glDrawRangeElements, "glDrawRangeElements");
pragma Import (Stdcall, glTexImage3D, "glTexImage3D");
pragma Import (Stdcall, glTexSubImage3D, "glTexSubImage3D");
pragma Import (Stdcall, glCopyTexSubImage3D, "glCopyTexSubImage3D");
end gl_h;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M . C H 8 --
-- --
-- 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 Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Fname; use Fname;
with Freeze; use Freeze;
with Lib; use Lib;
with Lib.Load; use Lib.Load;
with Lib.Xref; use Lib.Xref;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Output; use Output;
with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Cat; use Sem_Cat;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch4; use Sem_Ch4;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch12; use Sem_Ch12;
with Sem_Disp; use Sem_Disp;
with Sem_Dist; use Sem_Dist;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Type; use Sem_Type;
with Stand; use Stand;
with Sinfo; use Sinfo;
with Sinfo.CN; use Sinfo.CN;
with Snames; use Snames;
with Style; use Style;
with Table;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
package body Sem_Ch8 is
------------------------------------
-- Visibility and Name Resolution --
------------------------------------
-- This package handles name resolution and the collection of
-- interpretations for overloaded names, prior to overload resolution.
-- Name resolution is the process that establishes a mapping between source
-- identifiers and the entities they denote at each point in the program.
-- Each entity is represented by a defining occurrence. Each identifier
-- that denotes an entity points to the corresponding defining occurrence.
-- This is the entity of the applied occurrence. Each occurrence holds
-- an index into the names table, where source identifiers are stored.
-- Each entry in the names table for an identifier or designator uses the
-- Info pointer to hold a link to the currently visible entity that has
-- this name (see subprograms Get_Name_Entity_Id and Set_Name_Entity_Id
-- in package Sem_Util). The visibility is initialized at the beginning of
-- semantic processing to make entities in package Standard immediately
-- visible. The visibility table is used in a more subtle way when
-- compiling subunits (see below).
-- Entities that have the same name (i.e. homonyms) are chained. In the
-- case of overloaded entities, this chain holds all the possible meanings
-- of a given identifier. The process of overload resolution uses type
-- information to select from this chain the unique meaning of a given
-- identifier.
-- Entities are also chained in their scope, through the Next_Entity link.
-- As a consequence, the name space is organized as a sparse matrix, where
-- each row corresponds to a scope, and each column to a source identifier.
-- Open scopes, that is to say scopes currently being compiled, have their
-- corresponding rows of entities in order, innermost scope first.
-- The scopes of packages that are mentioned in context clauses appear in
-- no particular order, interspersed among open scopes. This is because
-- in the course of analyzing the context of a compilation, a package
-- declaration is first an open scope, and subsequently an element of the
-- context. If subunits or child units are present, a parent unit may
-- appear under various guises at various times in the compilation.
-- When the compilation of the innermost scope is complete, the entities
-- defined therein are no longer visible. If the scope is not a package
-- declaration, these entities are never visible subsequently, and can be
-- removed from visibility chains. If the scope is a package declaration,
-- its visible declarations may still be accessible. Therefore the entities
-- defined in such a scope are left on the visibility chains, and only
-- their visibility (immediately visibility or potential use-visibility)
-- is affected.
-- The ordering of homonyms on their chain does not necessarily follow
-- the order of their corresponding scopes on the scope stack. For
-- example, if package P and the enclosing scope both contain entities
-- named E, then when compiling the package body the chain for E will
-- hold the global entity first, and the local one (corresponding to
-- the current inner scope) next. As a result, name resolution routines
-- do not assume any relative ordering of the homonym chains, either
-- for scope nesting or to order of appearance of context clauses.
-- When compiling a child unit, entities in the parent scope are always
-- immediately visible. When compiling the body of a child unit, private
-- entities in the parent must also be made immediately visible. There
-- are separate routines to make the visible and private declarations
-- visible at various times (see package Sem_Ch7).
-- +--------+ +-----+
-- | In use |-------->| EU1 |-------------------------->
-- +--------+ +-----+
-- | |
-- +--------+ +-----+ +-----+
-- | Stand. |---------------->| ES1 |--------------->| ES2 |--->
-- +--------+ +-----+ +-----+
-- | |
-- +---------+ | +-----+
-- | with'ed |------------------------------>| EW2 |--->
-- +---------+ | +-----+
-- | |
-- +--------+ +-----+ +-----+
-- | Scope2 |---------------->| E12 |--------------->| E22 |--->
-- +--------+ +-----+ +-----+
-- | |
-- +--------+ +-----+ +-----+
-- | Scope1 |---------------->| E11 |--------------->| E12 |--->
-- +--------+ +-----+ +-----+
-- ^ | |
-- | | |
-- | +---------+ | |
-- | | with'ed |----------------------------------------->
-- | +---------+ | |
-- | | |
-- Scope stack | |
-- (innermost first) | |
-- +----------------------------+
-- Names table => | Id1 | | | | Id2 |
-- +----------------------------+
-- Name resolution must deal with several syntactic forms: simple names,
-- qualified names, indexed names, and various forms of calls.
-- Each identifier points to an entry in the names table. The resolution
-- of a simple name consists in traversing the homonym chain, starting
-- from the names table. If an entry is immediately visible, it is the one
-- designated by the identifier. If only potentially use-visible entities
-- are on the chain, we must verify that they do not hide each other. If
-- the entity we find is overloadable, we collect all other overloadable
-- entities on the chain as long as they are not hidden.
--
-- To resolve expanded names, we must find the entity at the intersection
-- of the entity chain for the scope (the prefix) and the homonym chain
-- for the selector. In general, homonym chains will be much shorter than
-- entity chains, so it is preferable to start from the names table as
-- well. If the entity found is overloadable, we must collect all other
-- interpretations that are defined in the scope denoted by the prefix.
-- For records, protected types, and tasks, their local entities are
-- removed from visibility chains on exit from the corresponding scope.
-- From the outside, these entities are always accessed by selected
-- notation, and the entity chain for the record type, protected type,
-- etc. is traversed sequentially in order to find the designated entity.
-- The discriminants of a type and the operations of a protected type or
-- task are unchained on exit from the first view of the type, (such as
-- a private or incomplete type declaration, or a protected type speci-
-- fication) and re-chained when compiling the second view.
-- In the case of operators, we do not make operators on derived types
-- explicit. As a result, the notation P."+" may denote either a user-
-- defined function with name "+", or else an implicit declaration of the
-- operator "+" in package P. The resolution of expanded names always
-- tries to resolve an operator name as such an implicitly defined entity,
-- in addition to looking for explicit declarations.
-- All forms of names that denote entities (simple names, expanded names,
-- character literals in some cases) have a Entity attribute, which
-- identifies the entity denoted by the name.
---------------------
-- The Scope Stack --
---------------------
-- The Scope stack keeps track of the scopes currently been compiled.
-- Every entity that contains declarations (including records) is placed
-- on the scope stack while it is being processed, and removed at the end.
-- Whenever a non-package scope is exited, the entities defined therein
-- are removed from the visibility table, so that entities in outer scopes
-- become visible (see previous description). On entry to Sem, the scope
-- stack only contains the package Standard. As usual, subunits complicate
-- this picture ever so slightly.
-- The Rtsfind mechanism can force a call to Semantics while another
-- compilation is in progress. The unit retrieved by Rtsfind must be
-- compiled in its own context, and has no access to the visibility of
-- the unit currently being compiled. The procedures Save_Scope_Stack and
-- Restore_Scope_Stack make entities in current open scopes invisible
-- before compiling the retrieved unit, and restore the compilation
-- environment afterwards.
------------------------
-- Compiling subunits --
------------------------
-- Subunits must be compiled in the environment of the corresponding
-- stub, that is to say with the same visibility into the parent (and its
-- context) that is available at the point of the stub declaration, but
-- with the additional visibility provided by the context clause of the
-- subunit itself. As a result, compilation of a subunit forces compilation
-- of the parent (see description in lib-). At the point of the stub
-- declaration, Analyze is called recursively to compile the proper body
-- of the subunit, but without reinitializing the names table, nor the
-- scope stack (i.e. standard is not pushed on the stack). In this fashion
-- the context of the subunit is added to the context of the parent, and
-- the subunit is compiled in the correct environment. Note that in the
-- course of processing the context of a subunit, Standard will appear
-- twice on the scope stack: once for the parent of the subunit, and
-- once for the unit in the context clause being compiled. However, the
-- two sets of entities are not linked by homonym chains, so that the
-- compilation of any context unit happens in a fresh visibility
-- environment.
-------------------------------
-- Processing of USE Clauses --
-------------------------------
-- Every defining occurrence has a flag indicating if it is potentially use
-- visible. Resolution of simple names examines this flag. The processing
-- of use clauses consists in setting this flag on all visible entities
-- defined in the corresponding package. On exit from the scope of the use
-- clause, the corresponding flag must be reset. However, a package may
-- appear in several nested use clauses (pathological but legal, alas!)
-- which forces us to use a slightly more involved scheme:
-- a) The defining occurrence for a package holds a flag -In_Use- to
-- indicate that it is currently in the scope of a use clause. If a
-- redundant use clause is encountered, then the corresponding occurrence
-- of the package name is flagged -Redundant_Use-.
-- b) On exit from a scope, the use clauses in its declarative part are
-- scanned. The visibility flag is reset in all entities declared in
-- package named in a use clause, as long as the package is not flagged
-- as being in a redundant use clause (in which case the outer use
-- clause is still in effect, and the direct visibility of its entities
-- must be retained).
-- Note that entities are not removed from their homonym chains on exit
-- from the package specification. A subsequent use clause does not need
-- to rechain the visible entities, but only to establish their direct
-- visibility.
-----------------------------------
-- Handling private declarations --
-----------------------------------
-- The principle that each entity has a single defining occurrence clashes
-- with the presence of two separate definitions for private types: the
-- first is the private type declaration, and second is the full type
-- declaration. It is important that all references to the type point to
-- the same defining occurrence, namely the first one. To enforce the two
-- separate views of the entity, the corresponding information is swapped
-- between the two declarations. Outside of the package, the defining
-- occurrence only contains the private declaration information, while in
-- the private part and the body of the package the defining occurrence
-- contains the full declaration. To simplify the swap, the defining
-- occurrence that currently holds the private declaration points to the
-- full declaration. During semantic processing the defining occurrence
-- also points to a list of private dependents, that is to say access
-- types or composite types whose designated types or component types are
-- subtypes or derived types of the private type in question. After the
-- full declaration has been seen, the private dependents are updated to
-- indicate that they have full definitions.
------------------------------------
-- Handling of Undefined Messages --
------------------------------------
-- In normal mode, only the first use of an undefined identifier generates
-- a message. The table Urefs is used to record error messages that have
-- been issued so that second and subsequent ones do not generate further
-- messages. However, the second reference causes text to be added to the
-- original undefined message noting "(more references follow)". The
-- full error list option (-gnatf) forces messages to be generated for
-- every reference and disconnects the use of this table.
type Uref_Entry is record
Node : Node_Id;
-- Node for identifier for which original message was posted. The
-- Chars field of this identifier is used to detect later references
-- to the same identifier.
Err : Error_Msg_Id;
-- Records error message Id of original undefined message. Reset to
-- No_Error_Msg after the second occurrence, where it is used to add
-- text to the original message as described above.
Nvis : Boolean;
-- Set if the message is not visible rather than undefined
Loc : Source_Ptr;
-- Records location of error message. Used to make sure that we do
-- not consider a, b : undefined as two separate instances, which
-- would otherwise happen, since the parser converts this sequence
-- to a : undefined; b : undefined.
end record;
package Urefs is new Table.Table (
Table_Component_Type => Uref_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Urefs");
Candidate_Renaming : Entity_Id;
-- Holds a candidate interpretation that appears in a subprogram renaming
-- declaration and does not match the given specification, but matches at
-- least on the first formal. Allows better error message when given
-- specification omits defaulted parameters, a common error.
-----------------------
-- Local Subprograms --
-----------------------
procedure Analyze_Generic_Renaming
(N : Node_Id;
K : Entity_Kind);
-- Common processing for all three kinds of generic renaming declarations.
-- Enter new name and indicate that it renames the generic unit.
procedure Analyze_Renamed_Character
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean);
-- Renamed entity is given by a character literal, which must belong
-- to the return type of the new entity. Is_Body indicates whether the
-- declaration is a renaming_as_body. If the original declaration has
-- already been frozen (because of an intervening body, e.g.) the body of
-- the function must be built now. The same applies to the following
-- various renaming procedures.
procedure Analyze_Renamed_Dereference
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean);
-- Renamed entity is given by an explicit dereference. Prefix must be a
-- conformant access_to_subprogram type.
procedure Analyze_Renamed_Entry
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean);
-- If the renamed entity in a subprogram renaming is an entry or protected
-- subprogram, build a body for the new entity whose only statement is a
-- call to the renamed entity.
procedure Analyze_Renamed_Family_Member
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean);
-- Used when the renamed entity is an indexed component. The prefix must
-- denote an entry family.
function Applicable_Use (Pack_Name : Node_Id) return Boolean;
-- Common code to Use_One_Package and Set_Use, to determine whether
-- use clause must be processed. Pack_Name is an entity name that
-- references the package in question.
procedure Attribute_Renaming (N : Node_Id);
-- Analyze renaming of attribute as function. The renaming declaration N
-- is rewritten as a function body that returns the attribute reference
-- applied to the formals of the function.
procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id);
-- A renaming_as_body may occur after the entity of the original decla-
-- ration has been frozen. In that case, the body of the new entity must
-- be built now, because the usual mechanism of building the renamed
-- body at the point of freezing will not work. Subp is the subprogram
-- for which N provides the Renaming_As_Body.
procedure Check_In_Previous_With_Clause
(N : Node_Id;
Nam : Node_Id);
-- N is a use_package clause and Nam the package name, or N is a use_type
-- clause and Nam is the prefix of the type name. In either case, verify
-- that the package is visible at that point in the context: either it
-- appears in a previous with_clause, or because it is a fully qualified
-- name and the root ancestor appears in a previous with_clause.
procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id);
-- Verify that the entity in a renaming declaration that is a library unit
-- is itself a library unit and not a nested unit or subunit. Also check
-- that if the renaming is a child unit of a generic parent, then the
-- renamed unit must also be a child unit of that parent. Finally, verify
-- that a renamed generic unit is not an implicit child declared within
-- an instance of the parent.
procedure Chain_Use_Clause (N : Node_Id);
-- Chain use clause onto list of uses clauses headed by First_Use_Clause in
-- the proper scope table entry. This is usually the current scope, but it
-- will be an inner scope when installing the use clauses of the private
-- declarations of a parent unit prior to compiling the private part of a
-- child unit. This chain is traversed when installing/removing use clauses
-- when compiling a subunit or instantiating a generic body on the fly,
-- when it is necessary to save and restore full environments.
function Has_Implicit_Character_Literal (N : Node_Id) return Boolean;
-- Find a type derived from Character or Wide_Character in the prefix of N.
-- Used to resolved qualified names whose selector is a character literal.
function Has_Private_With (E : Entity_Id) return Boolean;
-- Ada 2005 (AI-262): Determines if the current compilation unit has a
-- private with on E.
procedure Find_Expanded_Name (N : Node_Id);
-- Selected component is known to be expanded name. Verify legality
-- of selector given the scope denoted by prefix.
function Find_Renamed_Entity
(N : Node_Id;
Nam : Node_Id;
New_S : Entity_Id;
Is_Actual : Boolean := False) return Entity_Id;
-- Find the renamed entity that corresponds to the given parameter profile
-- in a subprogram renaming declaration. The renamed entity may be an
-- operator, a subprogram, an entry, or a protected operation. Is_Actual
-- indicates that the renaming is the one generated for an actual subpro-
-- gram in an instance, for which special visibility checks apply.
function Has_Implicit_Operator (N : Node_Id) return Boolean;
-- N is an expanded name whose selector is an operator name (eg P."+").
-- A declarative part contains an implicit declaration of an operator
-- if it has a declaration of a type to which one of the predefined
-- operators apply. The existence of this routine is an artifact of
-- our implementation: a more straightforward but more space-consuming
-- choice would be to make all inherited operators explicit in the
-- symbol table.
procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id);
-- A subprogram defined by a renaming declaration inherits the parameter
-- profile of the renamed entity. The subtypes given in the subprogram
-- specification are discarded and replaced with those of the renamed
-- subprogram, which are then used to recheck the default values.
function Is_Appropriate_For_Record (T : Entity_Id) return Boolean;
-- Prefix is appropriate for record if it is of a record type, or
-- an access to such.
function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean;
-- True if it is of a task type, a protected type, or else an access
-- to one of these types.
procedure Note_Redundant_Use (Clause : Node_Id);
-- Mark the name in a use clause as redundant if the corresponding
-- entity is already use-visible. Emit a warning if the use clause
-- comes from source and the proper warnings are enabled.
procedure Premature_Usage (N : Node_Id);
-- Diagnose usage of an entity before it is visible
procedure Use_One_Package (P : Entity_Id; N : Node_Id);
-- Make visible entities declared in package P potentially use-visible
-- in the current context. Also used in the analysis of subunits, when
-- re-installing use clauses of parent units. N is the use_clause that
-- names P (and possibly other packages).
procedure Use_One_Type (Id : Node_Id);
-- Id is the subtype mark from a use type clause. This procedure makes
-- the primitive operators of the type potentially use-visible.
procedure Write_Info;
-- Write debugging information on entities declared in current scope
procedure Write_Scopes;
pragma Warnings (Off, Write_Scopes);
-- Debugging information: dump all entities on scope stack
--------------------------------
-- Analyze_Exception_Renaming --
--------------------------------
-- The language only allows a single identifier, but the tree holds
-- an identifier list. The parser has already issued an error message
-- if there is more than one element in the list.
procedure Analyze_Exception_Renaming (N : Node_Id) is
Id : constant Node_Id := Defining_Identifier (N);
Nam : constant Node_Id := Name (N);
begin
Enter_Name (Id);
Analyze (Nam);
Set_Ekind (Id, E_Exception);
Set_Exception_Code (Id, Uint_0);
Set_Etype (Id, Standard_Exception_Type);
Set_Is_Pure (Id, Is_Pure (Current_Scope));
if not Is_Entity_Name (Nam) or else
Ekind (Entity (Nam)) /= E_Exception
then
Error_Msg_N ("invalid exception name in renaming", Nam);
else
if Present (Renamed_Object (Entity (Nam))) then
Set_Renamed_Object (Id, Renamed_Object (Entity (Nam)));
else
Set_Renamed_Object (Id, Entity (Nam));
end if;
end if;
end Analyze_Exception_Renaming;
---------------------------
-- Analyze_Expanded_Name --
---------------------------
procedure Analyze_Expanded_Name (N : Node_Id) is
begin
-- If the entity pointer is already set, this is an internal node, or
-- a node that is analyzed more than once, after a tree modification.
-- In such a case there is no resolution to perform, just set the type.
-- For completeness, analyze prefix as well.
if Present (Entity (N)) then
if Is_Type (Entity (N)) then
Set_Etype (N, Entity (N));
else
Set_Etype (N, Etype (Entity (N)));
end if;
Analyze (Prefix (N));
return;
else
Find_Expanded_Name (N);
end if;
end Analyze_Expanded_Name;
---------------------------------------
-- Analyze_Generic_Function_Renaming --
---------------------------------------
procedure Analyze_Generic_Function_Renaming (N : Node_Id) is
begin
Analyze_Generic_Renaming (N, E_Generic_Function);
end Analyze_Generic_Function_Renaming;
--------------------------------------
-- Analyze_Generic_Package_Renaming --
--------------------------------------
procedure Analyze_Generic_Package_Renaming (N : Node_Id) is
begin
-- Apply the Text_IO Kludge here, since we may be renaming
-- one of the subpackages of Text_IO, then join common routine.
Text_IO_Kludge (Name (N));
Analyze_Generic_Renaming (N, E_Generic_Package);
end Analyze_Generic_Package_Renaming;
----------------------------------------
-- Analyze_Generic_Procedure_Renaming --
----------------------------------------
procedure Analyze_Generic_Procedure_Renaming (N : Node_Id) is
begin
Analyze_Generic_Renaming (N, E_Generic_Procedure);
end Analyze_Generic_Procedure_Renaming;
------------------------------
-- Analyze_Generic_Renaming --
------------------------------
procedure Analyze_Generic_Renaming
(N : Node_Id;
K : Entity_Kind)
is
New_P : constant Entity_Id := Defining_Entity (N);
Old_P : Entity_Id;
Inst : Boolean := False; -- prevent junk warning
begin
if Name (N) = Error then
return;
end if;
Generate_Definition (New_P);
if Current_Scope /= Standard_Standard then
Set_Is_Pure (New_P, Is_Pure (Current_Scope));
end if;
if Nkind (Name (N)) = N_Selected_Component then
Check_Generic_Child_Unit (Name (N), Inst);
else
Analyze (Name (N));
end if;
if not Is_Entity_Name (Name (N)) then
Error_Msg_N ("expect entity name in renaming declaration", Name (N));
Old_P := Any_Id;
else
Old_P := Entity (Name (N));
end if;
Enter_Name (New_P);
Set_Ekind (New_P, K);
if Etype (Old_P) = Any_Type then
null;
elsif Ekind (Old_P) /= K then
Error_Msg_N ("invalid generic unit name", Name (N));
else
if Present (Renamed_Object (Old_P)) then
Set_Renamed_Object (New_P, Renamed_Object (Old_P));
else
Set_Renamed_Object (New_P, Old_P);
end if;
Set_Etype (New_P, Etype (Old_P));
Set_Has_Completion (New_P);
if In_Open_Scopes (Old_P) then
Error_Msg_N ("within its scope, generic denotes its instance", N);
end if;
Check_Library_Unit_Renaming (N, Old_P);
end if;
end Analyze_Generic_Renaming;
-----------------------------
-- Analyze_Object_Renaming --
-----------------------------
procedure Analyze_Object_Renaming (N : Node_Id) is
Id : constant Entity_Id := Defining_Identifier (N);
Dec : Node_Id;
Nam : constant Node_Id := Name (N);
T : Entity_Id;
T2 : Entity_Id;
begin
if Nam = Error then
return;
end if;
Set_Is_Pure (Id, Is_Pure (Current_Scope));
Enter_Name (Id);
-- The renaming of a component that depends on a discriminant
-- requires an actual subtype, because in subsequent use of the object
-- Gigi will be unable to locate the actual bounds. This explicit step
-- is required when the renaming is generated in removing side effects
-- of an already-analyzed expression.
if Nkind (Nam) = N_Selected_Component
and then Analyzed (Nam)
then
T := Etype (Nam);
Dec := Build_Actual_Subtype_Of_Component (Etype (Nam), Nam);
if Present (Dec) then
Insert_Action (N, Dec);
T := Defining_Identifier (Dec);
Set_Etype (Nam, T);
end if;
elsif Present (Subtype_Mark (N)) then
Find_Type (Subtype_Mark (N));
T := Entity (Subtype_Mark (N));
Analyze_And_Resolve (Nam, T);
-- Ada 2005 (AI-230/AI-254): Access renaming
else pragma Assert (Present (Access_Definition (N)));
T := Access_Definition
(Related_Nod => N,
N => Access_Definition (N));
Analyze_And_Resolve (Nam, T);
-- Ada 2005 (AI-231): "In the case where the type is defined by an
-- access_definition, the renamed entity shall be of an access-to-
-- constant type if and only if the access_definition defines an
-- access-to-constant type" ARM 8.5.1(4)
if Constant_Present (Access_Definition (N))
and then not Is_Access_Constant (Etype (Nam))
then
Error_Msg_N ("(Ada 2005): the renamed object is not "
& "access-to-constant ('R'M 8.5.1(6))", N);
elsif Null_Exclusion_Present (Access_Definition (N)) then
Error_Msg_N ("(Ada 2005): null-excluding attribute ignored "
& "('R'M 8.5.1(6))?", N);
end if;
end if;
-- An object renaming requires an exact match of the type;
-- class-wide matching is not allowed.
if Is_Class_Wide_Type (T)
and then Base_Type (Etype (Nam)) /= Base_Type (T)
then
Wrong_Type (Nam, T);
end if;
T2 := Etype (Nam);
-- (Ada 2005: AI-326): Handle wrong use of incomplete type
if Nkind (Nam) = N_Explicit_Dereference
and then Ekind (Etype (T2)) = E_Incomplete_Type
then
Error_Msg_N ("invalid use of incomplete type", Id);
return;
end if;
Set_Ekind (Id, E_Variable);
Init_Size_Align (Id);
if T = Any_Type or else Etype (Nam) = Any_Type then
return;
-- Verify that the renamed entity is an object or a function call.
-- It may have been rewritten in several ways.
elsif Is_Object_Reference (Nam) then
if Comes_From_Source (N)
and then Is_Dependent_Component_Of_Mutable_Object (Nam)
then
Error_Msg_N
("illegal renaming of discriminant-dependent component", Nam);
else
null;
end if;
-- A static function call may have been folded into a literal
elsif Nkind (Original_Node (Nam)) = N_Function_Call
-- When expansion is disabled, attribute reference is not
-- rewritten as function call. Otherwise it may be rewritten
-- as a conversion, so check original node.
or else (Nkind (Original_Node (Nam)) = N_Attribute_Reference
and then Is_Function_Attribute_Name
(Attribute_Name (Original_Node (Nam))))
-- Weird but legal, equivalent to renaming a function call
-- Illegal if the literal is the result of constant-folding
-- an attribute reference that is not a function.
or else (Is_Entity_Name (Nam)
and then Ekind (Entity (Nam)) = E_Enumeration_Literal
and then
Nkind (Original_Node (Nam)) /= N_Attribute_Reference)
or else (Nkind (Nam) = N_Type_Conversion
and then Is_Tagged_Type (Entity (Subtype_Mark (Nam))))
then
null;
else
if Nkind (Nam) = N_Type_Conversion then
Error_Msg_N
("renaming of conversion only allowed for tagged types", Nam);
else
Error_Msg_N ("expect object name in renaming", Nam);
end if;
end if;
Set_Etype (Id, T2);
if not Is_Variable (Nam) then
Set_Ekind (Id, E_Constant);
Set_Never_Set_In_Source (Id, True);
Set_Is_True_Constant (Id, True);
end if;
Set_Renamed_Object (Id, Nam);
end Analyze_Object_Renaming;
------------------------------
-- Analyze_Package_Renaming --
------------------------------
procedure Analyze_Package_Renaming (N : Node_Id) is
New_P : constant Entity_Id := Defining_Entity (N);
Old_P : Entity_Id;
Spec : Node_Id;
begin
if Name (N) = Error then
return;
end if;
-- Apply Text_IO kludge here, since we may be renaming one of
-- the children of Text_IO
Text_IO_Kludge (Name (N));
if Current_Scope /= Standard_Standard then
Set_Is_Pure (New_P, Is_Pure (Current_Scope));
end if;
Enter_Name (New_P);
Analyze (Name (N));
if Is_Entity_Name (Name (N)) then
Old_P := Entity (Name (N));
else
Old_P := Any_Id;
end if;
if Etype (Old_P) = Any_Type then
Error_Msg_N
("expect package name in renaming", Name (N));
-- Ada 2005 (AI-50217): Limited withed packages cannot be renamed
elsif Ekind (Old_P) = E_Package
and then From_With_Type (Old_P)
then
Error_Msg_N
("limited withed package cannot be renamed", Name (N));
elsif Ekind (Old_P) /= E_Package
and then not (Ekind (Old_P) = E_Generic_Package
and then In_Open_Scopes (Old_P))
then
if Ekind (Old_P) = E_Generic_Package then
Error_Msg_N
("generic package cannot be renamed as a package", Name (N));
else
Error_Msg_Sloc := Sloc (Old_P);
Error_Msg_NE
("expect package name in renaming, found& declared#",
Name (N), Old_P);
end if;
-- Set basic attributes to minimize cascaded errors
Set_Ekind (New_P, E_Package);
Set_Etype (New_P, Standard_Void_Type);
else
-- Entities in the old package are accessible through the
-- renaming entity. The simplest implementation is to have
-- both packages share the entity list.
Set_Ekind (New_P, E_Package);
Set_Etype (New_P, Standard_Void_Type);
if Present (Renamed_Object (Old_P)) then
Set_Renamed_Object (New_P, Renamed_Object (Old_P));
else
Set_Renamed_Object (New_P, Old_P);
end if;
Set_Has_Completion (New_P);
Set_First_Entity (New_P, First_Entity (Old_P));
Set_Last_Entity (New_P, Last_Entity (Old_P));
Set_First_Private_Entity (New_P, First_Private_Entity (Old_P));
Check_Library_Unit_Renaming (N, Old_P);
Generate_Reference (Old_P, Name (N));
-- If this is the renaming declaration of a package instantiation
-- within itself, it is the declaration that ends the list of actuals
-- for the instantiation. At this point, the subtypes that rename
-- the actuals are flagged as generic, to avoid spurious ambiguities
-- if the actuals for two distinct formals happen to coincide. If
-- the actual is a private type, the subtype has a private completion
-- that is flagged in the same fashion.
-- Resolution is identical to what is was in the original generic.
-- On exit from the generic instance, these are turned into regular
-- subtypes again, so they are compatible with types in their class.
if not Is_Generic_Instance (Old_P) then
return;
else
Spec := Specification (Unit_Declaration_Node (Old_P));
end if;
if Nkind (Spec) = N_Package_Specification
and then Present (Generic_Parent (Spec))
and then Old_P = Current_Scope
and then Chars (New_P) = Chars (Generic_Parent (Spec))
then
declare
E : Entity_Id := First_Entity (Old_P);
begin
while Present (E)
and then E /= New_P
loop
if Is_Type (E)
and then Nkind (Parent (E)) = N_Subtype_Declaration
then
Set_Is_Generic_Actual_Type (E);
if Is_Private_Type (E)
and then Present (Full_View (E))
then
Set_Is_Generic_Actual_Type (Full_View (E));
end if;
end if;
Next_Entity (E);
end loop;
end;
end if;
end if;
end Analyze_Package_Renaming;
-------------------------------
-- Analyze_Renamed_Character --
-------------------------------
procedure Analyze_Renamed_Character
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean)
is
C : constant Node_Id := Name (N);
begin
if Ekind (New_S) = E_Function then
Resolve (C, Etype (New_S));
if Is_Body then
Check_Frozen_Renaming (N, New_S);
end if;
else
Error_Msg_N ("character literal can only be renamed as function", N);
end if;
end Analyze_Renamed_Character;
---------------------------------
-- Analyze_Renamed_Dereference --
---------------------------------
procedure Analyze_Renamed_Dereference
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean)
is
Nam : constant Node_Id := Name (N);
P : constant Node_Id := Prefix (Nam);
Typ : Entity_Id;
Ind : Interp_Index;
It : Interp;
begin
if not Is_Overloaded (P) then
if Ekind (Etype (Nam)) /= E_Subprogram_Type
or else not Type_Conformant (Etype (Nam), New_S) then
Error_Msg_N ("designated type does not match specification", P);
else
Resolve (P);
end if;
return;
else
Typ := Any_Type;
Get_First_Interp (Nam, Ind, It);
while Present (It.Nam) loop
if Ekind (It.Nam) = E_Subprogram_Type
and then Type_Conformant (It.Nam, New_S) then
if Typ /= Any_Id then
Error_Msg_N ("ambiguous renaming", P);
return;
else
Typ := It.Nam;
end if;
end if;
Get_Next_Interp (Ind, It);
end loop;
if Typ = Any_Type then
Error_Msg_N ("designated type does not match specification", P);
else
Resolve (N, Typ);
if Is_Body then
Check_Frozen_Renaming (N, New_S);
end if;
end if;
end if;
end Analyze_Renamed_Dereference;
---------------------------
-- Analyze_Renamed_Entry --
---------------------------
procedure Analyze_Renamed_Entry
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean)
is
Nam : constant Node_Id := Name (N);
Sel : constant Node_Id := Selector_Name (Nam);
Old_S : Entity_Id;
begin
if Entity (Sel) = Any_Id then
-- Selector is undefined on prefix. Error emitted already
Set_Has_Completion (New_S);
return;
end if;
-- Otherwise, find renamed entity, and build body of New_S as a call
-- to it.
Old_S := Find_Renamed_Entity (N, Selector_Name (Nam), New_S);
if Old_S = Any_Id then
Error_Msg_N (" no subprogram or entry matches specification", N);
else
if Is_Body then
Check_Subtype_Conformant (New_S, Old_S, N);
Generate_Reference (New_S, Defining_Entity (N), 'b');
Style.Check_Identifier (Defining_Entity (N), New_S);
else
-- Only mode conformance required for a renaming_as_declaration
Check_Mode_Conformant (New_S, Old_S, N);
end if;
Inherit_Renamed_Profile (New_S, Old_S);
end if;
Set_Convention (New_S, Convention (Old_S));
Set_Has_Completion (New_S, Inside_A_Generic);
if Is_Body then
Check_Frozen_Renaming (N, New_S);
end if;
end Analyze_Renamed_Entry;
-----------------------------------
-- Analyze_Renamed_Family_Member --
-----------------------------------
procedure Analyze_Renamed_Family_Member
(N : Node_Id;
New_S : Entity_Id;
Is_Body : Boolean)
is
Nam : constant Node_Id := Name (N);
P : constant Node_Id := Prefix (Nam);
Old_S : Entity_Id;
begin
if (Is_Entity_Name (P) and then Ekind (Entity (P)) = E_Entry_Family)
or else (Nkind (P) = N_Selected_Component
and then
Ekind (Entity (Selector_Name (P))) = E_Entry_Family)
then
if Is_Entity_Name (P) then
Old_S := Entity (P);
else
Old_S := Entity (Selector_Name (P));
end if;
if not Entity_Matches_Spec (Old_S, New_S) then
Error_Msg_N ("entry family does not match specification", N);
elsif Is_Body then
Check_Subtype_Conformant (New_S, Old_S, N);
Generate_Reference (New_S, Defining_Entity (N), 'b');
Style.Check_Identifier (Defining_Entity (N), New_S);
end if;
else
Error_Msg_N ("no entry family matches specification", N);
end if;
Set_Has_Completion (New_S, Inside_A_Generic);
if Is_Body then
Check_Frozen_Renaming (N, New_S);
end if;
end Analyze_Renamed_Family_Member;
---------------------------------
-- Analyze_Subprogram_Renaming --
---------------------------------
procedure Analyze_Subprogram_Renaming (N : Node_Id) is
Spec : constant Node_Id := Specification (N);
Save_AV : constant Ada_Version_Type := Ada_Version;
Save_AV_Exp : constant Ada_Version_Type := Ada_Version_Explicit;
Nam : constant Node_Id := Name (N);
New_S : Entity_Id;
Old_S : Entity_Id := Empty;
Rename_Spec : Entity_Id;
Formal_Spec : constant Node_Id := Corresponding_Formal_Spec (N);
Is_Actual : constant Boolean := Present (Formal_Spec);
Inst_Node : Node_Id := Empty;
function Original_Subprogram (Subp : Entity_Id) return Entity_Id;
-- Find renamed entity when the declaration is a renaming_as_body
-- and the renamed entity may itself be a renaming_as_body. Used to
-- enforce rule that a renaming_as_body is illegal if the declaration
-- occurs before the subprogram it completes is frozen, and renaming
-- indirectly renames the subprogram itself.(Defect Report 8652/0027).
-------------------------
-- Original_Subprogram --
-------------------------
function Original_Subprogram (Subp : Entity_Id) return Entity_Id is
Orig_Decl : Node_Id;
Orig_Subp : Entity_Id;
begin
-- First case: renamed entity is itself a renaming
if Present (Alias (Subp)) then
return Alias (Subp);
elsif
Nkind (Unit_Declaration_Node (Subp)) = N_Subprogram_Declaration
and then Present
(Corresponding_Body (Unit_Declaration_Node (Subp)))
then
-- Check if renamed entity is a renaming_as_body
Orig_Decl :=
Unit_Declaration_Node
(Corresponding_Body (Unit_Declaration_Node (Subp)));
if Nkind (Orig_Decl) = N_Subprogram_Renaming_Declaration then
Orig_Subp := Entity (Name (Orig_Decl));
if Orig_Subp = Rename_Spec then
-- Circularity detected
return Orig_Subp;
else
return (Original_Subprogram (Orig_Subp));
end if;
else
return Subp;
end if;
else
return Subp;
end if;
end Original_Subprogram;
-- Start of processing for Analyze_Subprogram_Renaming
begin
-- We must test for the attribute renaming case before the Analyze
-- call because otherwise Sem_Attr will complain that the attribute
-- is missing an argument when it is analyzed.
if Nkind (Nam) = N_Attribute_Reference then
-- In the case of an abstract formal subprogram association,
-- rewrite an actual given by a stream attribute as the name
-- of the corresponding stream primitive of the type.
-- In a generic context the stream operations are not generated,
-- and this must be treated as a normal attribute reference, to
-- be expanded in subsequent instantiations.
if Is_Actual and then Is_Abstract (Formal_Spec)
and then Expander_Active
then
declare
Stream_Prim : Entity_Id;
Prefix_Type : constant Entity_Id := Entity (Prefix (Nam));
begin
-- The class-wide forms of the stream attributes are not
-- primitive dispatching operations (even though they
-- internally dispatch to a stream attribute).
if Is_Class_Wide_Type (Prefix_Type) then
Error_Msg_N
("attribute must be a primitive dispatching operation",
Nam);
return;
end if;
-- Retrieve the primitive subprogram associated with the
-- attribute. This can only be a stream attribute, since
-- those are the only ones that are dispatching (and the
-- actual for an abstract formal subprogram must be a
-- dispatching operation).
case Attribute_Name (Nam) is
when Name_Input =>
Stream_Prim :=
Find_Prim_Op (Prefix_Type, TSS_Stream_Input);
when Name_Output =>
Stream_Prim :=
Find_Prim_Op (Prefix_Type, TSS_Stream_Output);
when Name_Read =>
Stream_Prim :=
Find_Prim_Op (Prefix_Type, TSS_Stream_Read);
when Name_Write =>
Stream_Prim :=
Find_Prim_Op (Prefix_Type, TSS_Stream_Write);
when others =>
Error_Msg_N
("attribute must be a primitive dispatching operation",
Nam);
return;
end case;
-- Rewrite the attribute into the name of its corresponding
-- primitive dispatching subprogram. We can then proceed with
-- the usual processing for subprogram renamings.
declare
Prim_Name : constant Node_Id :=
Make_Identifier (Sloc (Nam),
Chars => Chars (Stream_Prim));
begin
Set_Entity (Prim_Name, Stream_Prim);
Rewrite (Nam, Prim_Name);
Analyze (Nam);
end;
end;
-- Normal processing for a renaming of an attribute
else
Attribute_Renaming (N);
return;
end if;
end if;
-- Check whether this declaration corresponds to the instantiation
-- of a formal subprogram.
-- If this is an instantiation, the corresponding actual is frozen
-- and error messages can be made more precise. If this is a default
-- subprogram, the entity is already established in the generic, and
-- is not retrieved by visibility. If it is a default with a box, the
-- candidate interpretations, if any, have been collected when building
-- the renaming declaration. If overloaded, the proper interpretation
-- is determined in Find_Renamed_Entity. If the entity is an operator,
-- Find_Renamed_Entity applies additional visibility checks.
if Is_Actual then
Inst_Node := Unit_Declaration_Node (Formal_Spec);
if Is_Entity_Name (Nam)
and then Present (Entity (Nam))
and then not Comes_From_Source (Nam)
and then not Is_Overloaded (Nam)
then
Old_S := Entity (Nam);
New_S := Analyze_Subprogram_Specification (Spec);
-- Operator case
if Ekind (Entity (Nam)) = E_Operator then
-- Box present
if Box_Present (Inst_Node) then
Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual);
-- If there is an immediately visible homonym of the operator
-- and the declaration has a default, this is worth a warning
-- because the user probably did not intend to get the pre-
-- defined operator, visible in the generic declaration.
-- To find if there is an intended candidate, analyze the
-- renaming again in the current context.
elsif Scope (Old_S) = Standard_Standard
and then Present (Default_Name (Inst_Node))
then
declare
Decl : constant Node_Id := New_Copy_Tree (N);
Hidden : Entity_Id;
begin
Set_Entity (Name (Decl), Empty);
Analyze (Name (Decl));
Hidden :=
Find_Renamed_Entity (Decl, Name (Decl), New_S, True);
if Present (Hidden)
and then In_Open_Scopes (Scope (Hidden))
and then Is_Immediately_Visible (Hidden)
and then Comes_From_Source (Hidden)
and then Hidden /= Old_S
then
Error_Msg_Sloc := Sloc (Hidden);
Error_Msg_N ("?default subprogram is resolved " &
"in the generic declaration " &
"('R'M 12.6(17))", N);
Error_Msg_NE ("\?and will not use & #", N, Hidden);
end if;
end;
end if;
end if;
else
Analyze (Nam);
New_S := Analyze_Subprogram_Specification (Spec);
end if;
else
-- Renamed entity must be analyzed first, to avoid being hidden by
-- new name (which might be the same in a generic instance).
Analyze (Nam);
-- The renaming defines a new overloaded entity, which is analyzed
-- like a subprogram declaration.
New_S := Analyze_Subprogram_Specification (Spec);
end if;
if Current_Scope /= Standard_Standard then
Set_Is_Pure (New_S, Is_Pure (Current_Scope));
end if;
Rename_Spec := Find_Corresponding_Spec (N);
if Present (Rename_Spec) then
-- Renaming_As_Body. Renaming declaration is the completion of
-- the declaration of Rename_Spec. We will build an actual body
-- for it at the freezing point.
Set_Corresponding_Spec (N, Rename_Spec);
if Nkind (Unit_Declaration_Node (Rename_Spec)) =
N_Abstract_Subprogram_Declaration
then
-- Input and Output stream functions are abstract if the object
-- type is abstract. However, these functions may receive explicit
-- declarations in representation clauses, making the attribute
-- subprograms usable as defaults in subsequent type extensions.
-- In this case we rewrite the declaration to make the subprogram
-- non-abstract. We remove the previous declaration, and insert
-- the new one at the point of the renaming, to prevent premature
-- access to unfrozen types. The new declaration reuses the
-- specification of the previous one, and must not be analyzed.
pragma Assert (Is_TSS (Rename_Spec, TSS_Stream_Output)
or else Is_TSS (Rename_Spec, TSS_Stream_Input));
declare
Old_Decl : constant Node_Id :=
Unit_Declaration_Node (Rename_Spec);
New_Decl : constant Node_Id :=
Make_Subprogram_Declaration (Sloc (N),
Specification =>
Relocate_Node (Specification (Old_Decl)));
begin
Remove (Old_Decl);
Insert_After (N, New_Decl);
Set_Is_Abstract (Rename_Spec, False);
Set_Analyzed (New_Decl);
end;
end if;
Set_Corresponding_Body (Unit_Declaration_Node (Rename_Spec), New_S);
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Error_Msg_N ("(Ada 83) renaming cannot serve as a body", N);
end if;
Set_Convention (New_S, Convention (Rename_Spec));
Check_Fully_Conformant (New_S, Rename_Spec);
Set_Public_Status (New_S);
-- Indicate that the entity in the declaration functions like the
-- corresponding body, and is not a new entity. The body will be
-- constructed later at the freeze point, so indicate that the
-- completion has not been seen yet.
Set_Ekind (New_S, E_Subprogram_Body);
New_S := Rename_Spec;
Set_Has_Completion (Rename_Spec, False);
-- Ada 2005: check overriding indicator
if Must_Override (Specification (N))
and then not Is_Overriding_Operation (Rename_Spec)
then
Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec);
elsif Must_Not_Override (Specification (N))
and then Is_Overriding_Operation (Rename_Spec)
then
Error_Msg_NE
("subprogram& overrides inherited operation", N, Rename_Spec);
end if;
else
Generate_Definition (New_S);
New_Overloaded_Entity (New_S);
if Is_Entity_Name (Nam)
and then Is_Intrinsic_Subprogram (Entity (Nam))
then
null;
else
Check_Delayed_Subprogram (New_S);
end if;
end if;
-- There is no need for elaboration checks on the new entity, which may
-- be called before the next freezing point where the body will appear.
-- Elaboration checks refer to the real entity, not the one created by
-- the renaming declaration.
Set_Kill_Elaboration_Checks (New_S, True);
if Etype (Nam) = Any_Type then
Set_Has_Completion (New_S);
return;
elsif Nkind (Nam) = N_Selected_Component then
-- Renamed entity is an entry or protected subprogram. For those
-- cases an explicit body is built (at the point of freezing of this
-- entity) that contains a call to the renamed entity.
Analyze_Renamed_Entry (N, New_S, Present (Rename_Spec));
return;
elsif Nkind (Nam) = N_Explicit_Dereference then
-- Renamed entity is designated by access_to_subprogram expression.
-- Must build body to encapsulate call, as in the entry case.
Analyze_Renamed_Dereference (N, New_S, Present (Rename_Spec));
return;
elsif Nkind (Nam) = N_Indexed_Component then
Analyze_Renamed_Family_Member (N, New_S, Present (Rename_Spec));
return;
elsif Nkind (Nam) = N_Character_Literal then
Analyze_Renamed_Character (N, New_S, Present (Rename_Spec));
return;
elsif (not Is_Entity_Name (Nam)
and then Nkind (Nam) /= N_Operator_Symbol)
or else not Is_Overloadable (Entity (Nam))
then
Error_Msg_N ("expect valid subprogram name in renaming", N);
return;
end if;
-- Most common case: subprogram renames subprogram. No body is generated
-- in this case, so we must indicate the declaration is complete as is.
if No (Rename_Spec) then
Set_Has_Completion (New_S);
end if;
-- Find the renamed entity that matches the given specification. Disable
-- Ada_83 because there is no requirement of full conformance between
-- renamed entity and new entity, even though the same circuit is used.
-- This is a bit of a kludge, which introduces a really irregular use of
-- Ada_Version[_Explicit]. Would be nice to find cleaner way to do this
-- ???
Ada_Version := Ada_Version_Type'Max (Ada_Version, Ada_95);
Ada_Version_Explicit := Ada_Version;
if No (Old_S) then
Old_S := Find_Renamed_Entity (N, Name (N), New_S, Is_Actual);
end if;
if Old_S /= Any_Id then
if Is_Actual
and then From_Default (N)
then
-- This is an implicit reference to the default actual
Generate_Reference (Old_S, Nam, Typ => 'i', Force => True);
else
Generate_Reference (Old_S, Nam);
end if;
-- For a renaming-as-body, require subtype conformance, but if the
-- declaration being completed has not been frozen, then inherit the
-- convention of the renamed subprogram prior to checking conformance
-- (unless the renaming has an explicit convention established; the
-- rule stated in the RM doesn't seem to address this ???).
if Present (Rename_Spec) then
Generate_Reference (Rename_Spec, Defining_Entity (Spec), 'b');
Style.Check_Identifier (Defining_Entity (Spec), Rename_Spec);
if not Is_Frozen (Rename_Spec) then
if not Has_Convention_Pragma (Rename_Spec) then
Set_Convention (New_S, Convention (Old_S));
end if;
if Ekind (Old_S) /= E_Operator then
Check_Mode_Conformant (New_S, Old_S, Spec);
end if;
if Original_Subprogram (Old_S) = Rename_Spec then
Error_Msg_N ("unfrozen subprogram cannot rename itself ", N);
end if;
else
Check_Subtype_Conformant (New_S, Old_S, Spec);
end if;
Check_Frozen_Renaming (N, Rename_Spec);
-- Check explicitly that renamed entity is not intrinsic, because
-- in in a generic the renamed body is not built. In this case,
-- the renaming_as_body is a completion.
if Inside_A_Generic then
if Is_Frozen (Rename_Spec)
and then Is_Intrinsic_Subprogram (Old_S)
then
Error_Msg_N
("subprogram in renaming_as_body cannot be intrinsic",
Name (N));
end if;
Set_Has_Completion (Rename_Spec);
end if;
elsif Ekind (Old_S) /= E_Operator then
Check_Mode_Conformant (New_S, Old_S);
if Is_Actual
and then Error_Posted (New_S)
then
Error_Msg_NE ("invalid actual subprogram: & #!", N, Old_S);
end if;
end if;
if No (Rename_Spec) then
-- The parameter profile of the new entity is that of the renamed
-- entity: the subtypes given in the specification are irrelevant.
Inherit_Renamed_Profile (New_S, Old_S);
-- A call to the subprogram is transformed into a call to the
-- renamed entity. This is transitive if the renamed entity is
-- itself a renaming.
if Present (Alias (Old_S)) then
Set_Alias (New_S, Alias (Old_S));
else
Set_Alias (New_S, Old_S);
end if;
-- Note that we do not set Is_Intrinsic_Subprogram if we have a
-- renaming as body, since the entity in this case is not an
-- intrinsic (it calls an intrinsic, but we have a real body for
-- this call, and it is in this body that the required intrinsic
-- processing will take place).
-- Also, if this is a renaming of inequality, the renamed operator
-- is intrinsic, but what matters is the corresponding equality
-- operator, which may be user-defined.
Set_Is_Intrinsic_Subprogram
(New_S,
Is_Intrinsic_Subprogram (Old_S)
and then
(Chars (Old_S) /= Name_Op_Ne
or else Ekind (Old_S) = E_Operator
or else
Is_Intrinsic_Subprogram
(Corresponding_Equality (Old_S))));
if Ekind (Alias (New_S)) = E_Operator then
Set_Has_Delayed_Freeze (New_S, False);
end if;
-- If the renaming corresponds to an association for an abstract
-- formal subprogram, then various attributes must be set to
-- indicate that the renaming is an abstract dispatching operation
-- with a controlling type.
if Is_Actual and then Is_Abstract (Formal_Spec) then
-- Mark the renaming as abstract here, so Find_Dispatching_Type
-- see it as corresponding to a generic association for a
-- formal abstract subprogram
Set_Is_Abstract (New_S);
declare
New_S_Ctrl_Type : constant Entity_Id :=
Find_Dispatching_Type (New_S);
Old_S_Ctrl_Type : constant Entity_Id :=
Find_Dispatching_Type (Old_S);
begin
if Old_S_Ctrl_Type /= New_S_Ctrl_Type then
Error_Msg_NE
("actual must be dispatching subprogram for type&",
Nam, New_S_Ctrl_Type);
else
Set_Is_Dispatching_Operation (New_S);
Check_Controlling_Formals (New_S_Ctrl_Type, New_S);
-- In the case where the actual in the formal subprogram
-- is itself a formal abstract subprogram association,
-- there's no dispatch table component or position to
-- inherit.
if Present (DTC_Entity (Old_S)) then
Set_DTC_Entity (New_S, DTC_Entity (Old_S));
Set_DT_Position (New_S, DT_Position (Old_S));
end if;
end if;
end;
end if;
end if;
if not Is_Actual
and then (Old_S = New_S
or else (Nkind (Nam) /= N_Expanded_Name
and then Chars (Old_S) = Chars (New_S)))
then
Error_Msg_N ("subprogram cannot rename itself", N);
end if;
Set_Convention (New_S, Convention (Old_S));
Set_Is_Abstract (New_S, Is_Abstract (Old_S));
Check_Library_Unit_Renaming (N, Old_S);
-- Pathological case: procedure renames entry in the scope of its
-- task. Entry is given by simple name, but body must be built for
-- procedure. Of course if called it will deadlock.
if Ekind (Old_S) = E_Entry then
Set_Has_Completion (New_S, False);
Set_Alias (New_S, Empty);
end if;
if Is_Actual then
Freeze_Before (N, Old_S);
Set_Has_Delayed_Freeze (New_S, False);
Freeze_Before (N, New_S);
-- An abstract subprogram is only allowed as an actual in the case
-- where the formal subprogram is also abstract.
if (Ekind (Old_S) = E_Procedure or else Ekind (Old_S) = E_Function)
and then Is_Abstract (Old_S)
and then not Is_Abstract (Formal_Spec)
then
Error_Msg_N
("abstract subprogram not allowed as generic actual", Nam);
end if;
end if;
else
-- A common error is to assume that implicit operators for types are
-- defined in Standard, or in the scope of a subtype. In those cases
-- where the renamed entity is given with an expanded name, it is
-- worth mentioning that operators for the type are not declared in
-- the scope given by the prefix.
if Nkind (Nam) = N_Expanded_Name
and then Nkind (Selector_Name (Nam)) = N_Operator_Symbol
and then Scope (Entity (Nam)) = Standard_Standard
then
declare
T : constant Entity_Id :=
Base_Type (Etype (First_Formal (New_S)));
begin
Error_Msg_Node_2 := Prefix (Nam);
Error_Msg_NE
("operator for type& is not declared in&", Prefix (Nam), T);
end;
else
Error_Msg_NE
("no visible subprogram matches the specification for&",
Spec, New_S);
end if;
if Present (Candidate_Renaming) then
declare
F1 : Entity_Id;
F2 : Entity_Id;
begin
F1 := First_Formal (Candidate_Renaming);
F2 := First_Formal (New_S);
while Present (F1) and then Present (F2) loop
Next_Formal (F1);
Next_Formal (F2);
end loop;
if Present (F1) and then Present (Default_Value (F1)) then
if Present (Next_Formal (F1)) then
Error_Msg_NE
("\missing specification for &" &
" and other formals with defaults", Spec, F1);
else
Error_Msg_NE
("\missing specification for &", Spec, F1);
end if;
end if;
end;
end if;
end if;
-- Ada 2005 AI 404: if the new subprogram is dispatching, verify that
-- controlling access parameters are known non-null for the renamed
-- subprogram. Test also applies to a subprogram instantiation that
-- is dispatching. Test is skipped if some previous error was detected
-- that set Old_S to Any_Id.
if Ada_Version >= Ada_05
and then Old_S /= Any_Id
and then not Is_Dispatching_Operation (Old_S)
and then Is_Dispatching_Operation (New_S)
then
declare
Old_F : Entity_Id;
New_F : Entity_Id;
begin
Old_F := First_Formal (Old_S);
New_F := First_Formal (New_S);
while Present (Old_F) loop
if Ekind (Etype (Old_F)) = E_Anonymous_Access_Type
and then Is_Controlling_Formal (New_F)
and then not Can_Never_Be_Null (Old_F)
then
Error_Msg_N ("access parameter is controlling,", New_F);
Error_Msg_NE ("\corresponding parameter of& " &
" must be explicitly null excluding", New_F, Old_S);
end if;
Next_Formal (Old_F);
Next_Formal (New_F);
end loop;
end;
end if;
-- A useful warning, suggested by Ada Bug Finder (Ada-Europe 2005)
if Comes_From_Source (N)
and then Present (Old_S)
and then Nkind (Old_S) = N_Defining_Operator_Symbol
and then Nkind (New_S) = N_Defining_Operator_Symbol
and then Chars (Old_S) /= Chars (New_S)
then
Error_Msg_NE
("?& is being renamed as a different operator",
New_S, Old_S);
end if;
Ada_Version := Save_AV;
Ada_Version_Explicit := Save_AV_Exp;
end Analyze_Subprogram_Renaming;
-------------------------
-- Analyze_Use_Package --
-------------------------
-- Resolve the package names in the use clause, and make all the visible
-- entities defined in the package potentially use-visible. If the package
-- is already in use from a previous use clause, its visible entities are
-- already use-visible. In that case, mark the occurrence as a redundant
-- use. If the package is an open scope, i.e. if the use clause occurs
-- within the package itself, ignore it.
procedure Analyze_Use_Package (N : Node_Id) is
Pack_Name : Node_Id;
Pack : Entity_Id;
-- Start of processing for Analyze_Use_Package
begin
Set_Hidden_By_Use_Clause (N, No_Elist);
-- Use clause is not allowed in a spec of a predefined package
-- declaration except that packages whose file name starts a-n are OK
-- (these are children of Ada.Numerics, and such packages are never
-- loaded by Rtsfind).
if Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
and then Name_Buffer (1 .. 3) /= "a-n"
and then
Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration
then
Error_Msg_N ("use clause not allowed in predefined spec", N);
end if;
-- Chain clause to list of use clauses in current scope
if Nkind (Parent (N)) /= N_Compilation_Unit then
Chain_Use_Clause (N);
end if;
-- Loop through package names to identify referenced packages
Pack_Name := First (Names (N));
while Present (Pack_Name) loop
Analyze (Pack_Name);
if Nkind (Parent (N)) = N_Compilation_Unit
and then Nkind (Pack_Name) = N_Expanded_Name
then
declare
Pref : Node_Id := Prefix (Pack_Name);
begin
while Nkind (Pref) = N_Expanded_Name loop
Pref := Prefix (Pref);
end loop;
if Entity (Pref) = Standard_Standard then
Error_Msg_N
("predefined package Standard cannot appear"
& " in a context clause", Pref);
end if;
end;
end if;
Next (Pack_Name);
end loop;
-- Loop through package names to mark all entities as potentially
-- use visible.
Pack_Name := First (Names (N));
while Present (Pack_Name) loop
if Is_Entity_Name (Pack_Name) then
Pack := Entity (Pack_Name);
if Ekind (Pack) /= E_Package
and then Etype (Pack) /= Any_Type
then
if Ekind (Pack) = E_Generic_Package then
Error_Msg_N
("a generic package is not allowed in a use clause",
Pack_Name);
else
Error_Msg_N ("& is not a usable package", Pack_Name);
end if;
else
if Nkind (Parent (N)) = N_Compilation_Unit then
Check_In_Previous_With_Clause (N, Pack_Name);
end if;
if Applicable_Use (Pack_Name) then
Use_One_Package (Pack, N);
end if;
end if;
end if;
Next (Pack_Name);
end loop;
end Analyze_Use_Package;
----------------------
-- Analyze_Use_Type --
----------------------
procedure Analyze_Use_Type (N : Node_Id) is
Id : Entity_Id;
begin
Set_Hidden_By_Use_Clause (N, No_Elist);
-- Chain clause to list of use clauses in current scope
if Nkind (Parent (N)) /= N_Compilation_Unit then
Chain_Use_Clause (N);
end if;
Id := First (Subtype_Marks (N));
while Present (Id) loop
Find_Type (Id);
if Entity (Id) /= Any_Type then
Use_One_Type (Id);
if Nkind (Parent (N)) = N_Compilation_Unit then
if Nkind (Id) = N_Identifier then
Error_Msg_N ("type is not directly visible", Id);
elsif Is_Child_Unit (Scope (Entity (Id)))
and then Scope (Entity (Id)) /= System_Aux_Id
then
Check_In_Previous_With_Clause (N, Prefix (Id));
end if;
end if;
end if;
Next (Id);
end loop;
end Analyze_Use_Type;
--------------------
-- Applicable_Use --
--------------------
function Applicable_Use (Pack_Name : Node_Id) return Boolean is
Pack : constant Entity_Id := Entity (Pack_Name);
begin
if In_Open_Scopes (Pack) then
return False;
elsif In_Use (Pack) then
Note_Redundant_Use (Pack_Name);
return False;
elsif Present (Renamed_Object (Pack))
and then In_Use (Renamed_Object (Pack))
then
Note_Redundant_Use (Pack_Name);
return False;
else
return True;
end if;
end Applicable_Use;
------------------------
-- Attribute_Renaming --
------------------------
procedure Attribute_Renaming (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Nam : constant Node_Id := Name (N);
Spec : constant Node_Id := Specification (N);
New_S : constant Entity_Id := Defining_Unit_Name (Spec);
Aname : constant Name_Id := Attribute_Name (Nam);
Form_Num : Nat := 0;
Expr_List : List_Id := No_List;
Attr_Node : Node_Id;
Body_Node : Node_Id;
Param_Spec : Node_Id;
begin
Generate_Definition (New_S);
-- This procedure is called in the context of subprogram renaming,
-- and thus the attribute must be one that is a subprogram. All of
-- those have at least one formal parameter, with the singular
-- exception of AST_Entry (which is a real oddity, it is odd that
-- this can be renamed at all!)
if not Is_Non_Empty_List (Parameter_Specifications (Spec)) then
if Aname /= Name_AST_Entry then
Error_Msg_N
("subprogram renaming an attribute must have formals", N);
return;
end if;
else
Param_Spec := First (Parameter_Specifications (Spec));
while Present (Param_Spec) loop
Form_Num := Form_Num + 1;
if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then
Find_Type (Parameter_Type (Param_Spec));
-- The profile of the new entity denotes the base type (s) of
-- the types given in the specification. For access parameters
-- there are no subtypes involved.
Rewrite (Parameter_Type (Param_Spec),
New_Reference_To
(Base_Type (Entity (Parameter_Type (Param_Spec))), Loc));
end if;
if No (Expr_List) then
Expr_List := New_List;
end if;
Append_To (Expr_List,
Make_Identifier (Loc,
Chars => Chars (Defining_Identifier (Param_Spec))));
-- The expressions in the attribute reference are not freeze
-- points. Neither is the attribute as a whole, see below.
Set_Must_Not_Freeze (Last (Expr_List));
Next (Param_Spec);
end loop;
end if;
-- Immediate error if too many formals. Other mismatches in numbers
-- of number of types of parameters are detected when we analyze the
-- body of the subprogram that we construct.
if Form_Num > 2 then
Error_Msg_N ("too many formals for attribute", N);
-- Error if the attribute reference has expressions that look
-- like formal parameters.
elsif Present (Expressions (Nam)) then
Error_Msg_N ("illegal expressions in attribute reference", Nam);
elsif
Aname = Name_Compose or else
Aname = Name_Exponent or else
Aname = Name_Leading_Part or else
Aname = Name_Pos or else
Aname = Name_Round or else
Aname = Name_Scaling or else
Aname = Name_Val
then
if Nkind (N) = N_Subprogram_Renaming_Declaration
and then Present (Corresponding_Formal_Spec (N))
then
Error_Msg_N
("generic actual cannot be attribute involving universal type",
Nam);
else
Error_Msg_N
("attribute involving a universal type cannot be renamed",
Nam);
end if;
end if;
-- AST_Entry is an odd case. It doesn't really make much sense to
-- allow it to be renamed, but that's the DEC rule, so we have to
-- do it right. The point is that the AST_Entry call should be made
-- now, and what the function will return is the returned value.
-- Note that there is no Expr_List in this case anyway
if Aname = Name_AST_Entry then
declare
Ent : Entity_Id;
Decl : Node_Id;
begin
Ent := Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Ent,
Object_Definition =>
New_Occurrence_Of (RTE (RE_AST_Handler), Loc),
Expression => Nam,
Constant_Present => True);
Set_Assignment_OK (Decl, True);
Insert_Action (N, Decl);
Attr_Node := Make_Identifier (Loc, Chars (Ent));
end;
-- For all other attributes, we rewrite the attribute node to have
-- a list of expressions corresponding to the subprogram formals.
-- A renaming declaration is not a freeze point, and the analysis of
-- the attribute reference should not freeze the type of the prefix.
else
Attr_Node :=
Make_Attribute_Reference (Loc,
Prefix => Prefix (Nam),
Attribute_Name => Aname,
Expressions => Expr_List);
Set_Must_Not_Freeze (Attr_Node);
Set_Must_Not_Freeze (Prefix (Nam));
end if;
-- Case of renaming a function
if Nkind (Spec) = N_Function_Specification then
if Is_Procedure_Attribute_Name (Aname) then
Error_Msg_N ("attribute can only be renamed as procedure", Nam);
return;
end if;
Find_Type (Result_Definition (Spec));
Rewrite (Result_Definition (Spec),
New_Reference_To (
Base_Type (Entity (Result_Definition (Spec))), Loc));
Body_Node :=
Make_Subprogram_Body (Loc,
Specification => Spec,
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (
Make_Return_Statement (Loc,
Expression => Attr_Node))));
-- Case of renaming a procedure
else
if not Is_Procedure_Attribute_Name (Aname) then
Error_Msg_N ("attribute can only be renamed as function", Nam);
return;
end if;
Body_Node :=
Make_Subprogram_Body (Loc,
Specification => Spec,
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Attr_Node)));
end if;
Rewrite (N, Body_Node);
Analyze (N);
if Is_Compilation_Unit (New_S) then
Error_Msg_N
("a library unit can only rename another library unit", N);
end if;
Set_Etype (New_S, Base_Type (Etype (New_S)));
-- We suppress elaboration warnings for the resulting entity, since
-- clearly they are not needed, and more particularly, in the case
-- of a generic formal subprogram, the resulting entity can appear
-- after the instantiation itself, and thus look like a bogus case
-- of access before elaboration.
Set_Suppress_Elaboration_Warnings (New_S);
end Attribute_Renaming;
----------------------
-- Chain_Use_Clause --
----------------------
procedure Chain_Use_Clause (N : Node_Id) is
Pack : Entity_Id;
Level : Int := Scope_Stack.Last;
begin
if not Is_Compilation_Unit (Current_Scope)
or else not Is_Child_Unit (Current_Scope)
then
null; -- Common case
elsif Defining_Entity (Parent (N)) = Current_Scope then
null; -- Common case for compilation unit
else
-- If declaration appears in some other scope, it must be in some
-- parent unit when compiling a child.
Pack := Defining_Entity (Parent (N));
if not In_Open_Scopes (Pack) then
null; -- default as well
else
-- Find entry for parent unit in scope stack
while Scope_Stack.Table (Level).Entity /= Pack loop
Level := Level - 1;
end loop;
end if;
end if;
Set_Next_Use_Clause (N,
Scope_Stack.Table (Level).First_Use_Clause);
Scope_Stack.Table (Level).First_Use_Clause := N;
end Chain_Use_Clause;
---------------------------
-- Check_Frozen_Renaming --
---------------------------
procedure Check_Frozen_Renaming (N : Node_Id; Subp : Entity_Id) is
B_Node : Node_Id;
Old_S : Entity_Id;
begin
if Is_Frozen (Subp)
and then not Has_Completion (Subp)
then
B_Node :=
Build_Renamed_Body
(Parent (Declaration_Node (Subp)), Defining_Entity (N));
if Is_Entity_Name (Name (N)) then
Old_S := Entity (Name (N));
if not Is_Frozen (Old_S)
and then Operating_Mode /= Check_Semantics
then
Append_Freeze_Action (Old_S, B_Node);
else
Insert_After (N, B_Node);
Analyze (B_Node);
end if;
if Is_Intrinsic_Subprogram (Old_S)
and then not In_Instance
then
Error_Msg_N
("subprogram used in renaming_as_body cannot be intrinsic",
Name (N));
end if;
else
Insert_After (N, B_Node);
Analyze (B_Node);
end if;
end if;
end Check_Frozen_Renaming;
-----------------------------------
-- Check_In_Previous_With_Clause --
-----------------------------------
procedure Check_In_Previous_With_Clause
(N : Node_Id;
Nam : Entity_Id)
is
Pack : constant Entity_Id := Entity (Original_Node (Nam));
Item : Node_Id;
Par : Node_Id;
begin
Item := First (Context_Items (Parent (N)));
while Present (Item)
and then Item /= N
loop
if Nkind (Item) = N_With_Clause
-- Protect the frontend against previously reported
-- critical errors
and then Nkind (Name (Item)) /= N_Selected_Component
and then Entity (Name (Item)) = Pack
then
Par := Nam;
-- Find root library unit in with_clause
while Nkind (Par) = N_Expanded_Name loop
Par := Prefix (Par);
end loop;
if Is_Child_Unit (Entity (Original_Node (Par))) then
Error_Msg_NE
("& is not directly visible", Par, Entity (Par));
else
return;
end if;
end if;
Next (Item);
end loop;
-- On exit, package is not mentioned in a previous with_clause.
-- Check if its prefix is.
if Nkind (Nam) = N_Expanded_Name then
Check_In_Previous_With_Clause (N, Prefix (Nam));
elsif Pack /= Any_Id then
Error_Msg_NE ("& is not visible", Nam, Pack);
end if;
end Check_In_Previous_With_Clause;
---------------------------------
-- Check_Library_Unit_Renaming --
---------------------------------
procedure Check_Library_Unit_Renaming (N : Node_Id; Old_E : Entity_Id) is
New_E : Entity_Id;
begin
if Nkind (Parent (N)) /= N_Compilation_Unit then
return;
elsif Scope (Old_E) /= Standard_Standard
and then not Is_Child_Unit (Old_E)
then
Error_Msg_N ("renamed unit must be a library unit", Name (N));
-- Entities defined in Standard (operators and boolean literals) cannot
-- be renamed as library units.
elsif Scope (Old_E) = Standard_Standard
and then Sloc (Old_E) = Standard_Location
then
Error_Msg_N ("renamed unit must be a library unit", Name (N));
elsif Present (Parent_Spec (N))
and then Nkind (Unit (Parent_Spec (N))) = N_Generic_Package_Declaration
and then not Is_Child_Unit (Old_E)
then
Error_Msg_N
("renamed unit must be a child unit of generic parent", Name (N));
elsif Nkind (N) in N_Generic_Renaming_Declaration
and then Nkind (Name (N)) = N_Expanded_Name
and then Is_Generic_Instance (Entity (Prefix (Name (N))))
and then Is_Generic_Unit (Old_E)
then
Error_Msg_N
("renamed generic unit must be a library unit", Name (N));
elsif Ekind (Old_E) = E_Package
or else Ekind (Old_E) = E_Generic_Package
then
-- Inherit categorization flags
New_E := Defining_Entity (N);
Set_Is_Pure (New_E, Is_Pure (Old_E));
Set_Is_Preelaborated (New_E, Is_Preelaborated (Old_E));
Set_Is_Remote_Call_Interface (New_E,
Is_Remote_Call_Interface (Old_E));
Set_Is_Remote_Types (New_E, Is_Remote_Types (Old_E));
Set_Is_Shared_Passive (New_E, Is_Shared_Passive (Old_E));
end if;
end Check_Library_Unit_Renaming;
---------------
-- End_Scope --
---------------
procedure End_Scope is
Id : Entity_Id;
Prev : Entity_Id;
Outer : Entity_Id;
begin
Id := First_Entity (Current_Scope);
while Present (Id) loop
-- An entity in the current scope is not necessarily the first one
-- on its homonym chain. Find its predecessor if any,
-- If it is an internal entity, it will not be in the visibility
-- chain altogether, and there is nothing to unchain.
if Id /= Current_Entity (Id) then
Prev := Current_Entity (Id);
while Present (Prev)
and then Present (Homonym (Prev))
and then Homonym (Prev) /= Id
loop
Prev := Homonym (Prev);
end loop;
-- Skip to end of loop if Id is not in the visibility chain
if No (Prev) or else Homonym (Prev) /= Id then
goto Next_Ent;
end if;
else
Prev := Empty;
end if;
Outer := Homonym (Id);
Set_Is_Immediately_Visible (Id, False);
while Present (Outer) and then Scope (Outer) = Current_Scope loop
Outer := Homonym (Outer);
end loop;
-- Reset homonym link of other entities, but do not modify link
-- between entities in current scope, so that the back-end can have
-- a proper count of local overloadings.
if No (Prev) then
Set_Name_Entity_Id (Chars (Id), Outer);
elsif Scope (Prev) /= Scope (Id) then
Set_Homonym (Prev, Outer);
end if;
<<Next_Ent>>
Next_Entity (Id);
end loop;
-- If the scope generated freeze actions, place them before the
-- current declaration and analyze them. Type declarations and
-- the bodies of initialization procedures can generate such nodes.
-- We follow the parent chain until we reach a list node, which is
-- the enclosing list of declarations. If the list appears within
-- a protected definition, move freeze nodes outside the protected
-- type altogether.
if Present
(Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions)
then
declare
Decl : Node_Id;
L : constant List_Id := Scope_Stack.Table
(Scope_Stack.Last).Pending_Freeze_Actions;
begin
if Is_Itype (Current_Scope) then
Decl := Associated_Node_For_Itype (Current_Scope);
else
Decl := Parent (Current_Scope);
end if;
Pop_Scope;
while not (Is_List_Member (Decl))
or else Nkind (Parent (Decl)) = N_Protected_Definition
or else Nkind (Parent (Decl)) = N_Task_Definition
loop
Decl := Parent (Decl);
end loop;
Insert_List_Before_And_Analyze (Decl, L);
end;
else
Pop_Scope;
end if;
end End_Scope;
---------------------
-- End_Use_Clauses --
---------------------
procedure End_Use_Clauses (Clause : Node_Id) is
U : Node_Id;
begin
-- Remove Use_Type clauses first, because they affect the
-- visibility of operators in subsequent used packages.
U := Clause;
while Present (U) loop
if Nkind (U) = N_Use_Type_Clause then
End_Use_Type (U);
end if;
Next_Use_Clause (U);
end loop;
U := Clause;
while Present (U) loop
if Nkind (U) = N_Use_Package_Clause then
End_Use_Package (U);
end if;
Next_Use_Clause (U);
end loop;
end End_Use_Clauses;
---------------------
-- End_Use_Package --
---------------------
procedure End_Use_Package (N : Node_Id) is
Pack_Name : Node_Id;
Pack : Entity_Id;
Id : Entity_Id;
Elmt : Elmt_Id;
function Is_Primitive_Operator
(Op : Entity_Id;
F : Entity_Id) return Boolean;
-- Check whether Op is a primitive operator of a use-visible type
---------------------------
-- Is_Primitive_Operator --
---------------------------
function Is_Primitive_Operator
(Op : Entity_Id;
F : Entity_Id) return Boolean
is
T : constant Entity_Id := Etype (F);
begin
return In_Use (T)
and then Scope (T) = Scope (Op);
end Is_Primitive_Operator;
-- Start of processing for End_Use_Package
begin
Pack_Name := First (Names (N));
while Present (Pack_Name) loop
Pack := Entity (Pack_Name);
if Ekind (Pack) = E_Package then
if In_Open_Scopes (Pack) then
null;
elsif not Redundant_Use (Pack_Name) then
Set_In_Use (Pack, False);
Set_Current_Use_Clause (Pack, Empty);
Id := First_Entity (Pack);
while Present (Id) loop
-- Preserve use-visibility of operators that are primitive
-- operators of a type that is use_visible through an active
-- use_type clause.
if Nkind (Id) = N_Defining_Operator_Symbol
and then
(Is_Primitive_Operator (Id, First_Formal (Id))
or else
(Present (Next_Formal (First_Formal (Id)))
and then
Is_Primitive_Operator
(Id, Next_Formal (First_Formal (Id)))))
then
null;
else
Set_Is_Potentially_Use_Visible (Id, False);
end if;
if Is_Private_Type (Id)
and then Present (Full_View (Id))
then
Set_Is_Potentially_Use_Visible (Full_View (Id), False);
end if;
Next_Entity (Id);
end loop;
if Present (Renamed_Object (Pack)) then
Set_In_Use (Renamed_Object (Pack), False);
Set_Current_Use_Clause (Renamed_Object (Pack), Empty);
end if;
if Chars (Pack) = Name_System
and then Scope (Pack) = Standard_Standard
and then Present_System_Aux
then
Id := First_Entity (System_Aux_Id);
while Present (Id) loop
Set_Is_Potentially_Use_Visible (Id, False);
if Is_Private_Type (Id)
and then Present (Full_View (Id))
then
Set_Is_Potentially_Use_Visible (Full_View (Id), False);
end if;
Next_Entity (Id);
end loop;
Set_In_Use (System_Aux_Id, False);
end if;
else
Set_Redundant_Use (Pack_Name, False);
end if;
end if;
Next (Pack_Name);
end loop;
if Present (Hidden_By_Use_Clause (N)) then
Elmt := First_Elmt (Hidden_By_Use_Clause (N));
while Present (Elmt) loop
Set_Is_Immediately_Visible (Node (Elmt));
Next_Elmt (Elmt);
end loop;
Set_Hidden_By_Use_Clause (N, No_Elist);
end if;
end End_Use_Package;
------------------
-- End_Use_Type --
------------------
procedure End_Use_Type (N : Node_Id) is
Id : Entity_Id;
Op_List : Elist_Id;
Elmt : Elmt_Id;
T : Entity_Id;
begin
Id := First (Subtype_Marks (N));
while Present (Id) loop
-- A call to rtsfind may occur while analyzing a use_type clause,
-- in which case the type marks are not resolved yet, and there is
-- nothing to remove.
if not Is_Entity_Name (Id)
or else No (Entity (Id))
then
goto Continue;
end if;
T := Entity (Id);
if T = Any_Type then
null;
-- Note that the use_Type clause may mention a subtype of the
-- type whose primitive operations have been made visible. Here
-- as elsewhere, it is the base type that matters for visibility.
elsif In_Open_Scopes (Scope (Base_Type (T))) then
null;
elsif not Redundant_Use (Id) then
Set_In_Use (T, False);
Set_In_Use (Base_Type (T), False);
Op_List := Collect_Primitive_Operations (T);
Elmt := First_Elmt (Op_List);
while Present (Elmt) loop
if Nkind (Node (Elmt)) = N_Defining_Operator_Symbol then
Set_Is_Potentially_Use_Visible (Node (Elmt), False);
end if;
Next_Elmt (Elmt);
end loop;
end if;
<<Continue>>
Next (Id);
end loop;
end End_Use_Type;
----------------------
-- Find_Direct_Name --
----------------------
procedure Find_Direct_Name (N : Node_Id) is
E : Entity_Id;
E2 : Entity_Id;
Msg : Boolean;
Inst : Entity_Id := Empty;
-- Enclosing instance, if any
Homonyms : Entity_Id;
-- Saves start of homonym chain
Nvis_Entity : Boolean;
-- Set True to indicate that at there is at least one entity on the
-- homonym chain which, while not visible, is visible enough from the
-- user point of view to warrant an error message of "not visible"
-- rather than undefined.
Nvis_Is_Private_Subprg : Boolean := False;
-- Ada 2005 (AI-262): Set True to indicate that a form of Beaujolais
-- effect concerning library subprograms has been detected. Used to
-- generate the precise error message.
function From_Actual_Package (E : Entity_Id) return Boolean;
-- Returns true if the entity is declared in a package that is
-- an actual for a formal package of the current instance. Such an
-- entity requires special handling because it may be use-visible
-- but hides directly visible entities defined outside the instance.
function Known_But_Invisible (E : Entity_Id) return Boolean;
-- This function determines whether the entity E (which is not
-- visible) can reasonably be considered to be known to the writer
-- of the reference. This is a heuristic test, used only for the
-- purposes of figuring out whether we prefer to complain that an
-- entity is undefined or invisible (and identify the declaration
-- of the invisible entity in the latter case). The point here is
-- that we don't want to complain that something is invisible and
-- then point to something entirely mysterious to the writer.
procedure Nvis_Messages;
-- Called if there are no visible entries for N, but there is at least
-- one non-directly visible, or hidden declaration. This procedure
-- outputs an appropriate set of error messages.
procedure Undefined (Nvis : Boolean);
-- This function is called if the current node has no corresponding
-- visible entity or entities. The value set in Msg indicates whether
-- an error message was generated (multiple error messages for the
-- same variable are generally suppressed, see body for details).
-- Msg is True if an error message was generated, False if not. This
-- value is used by the caller to determine whether or not to output
-- additional messages where appropriate. The parameter is set False
-- to get the message "X is undefined", and True to get the message
-- "X is not visible".
-------------------------
-- From_Actual_Package --
-------------------------
function From_Actual_Package (E : Entity_Id) return Boolean is
Scop : constant Entity_Id := Scope (E);
Act : Entity_Id;
begin
if not In_Instance then
return False;
else
Inst := Current_Scope;
while Present (Inst)
and then Ekind (Inst) /= E_Package
and then not Is_Generic_Instance (Inst)
loop
Inst := Scope (Inst);
end loop;
if No (Inst) then
return False;
end if;
Act := First_Entity (Inst);
while Present (Act) loop
if Ekind (Act) = E_Package then
-- Check for end of actuals list
if Renamed_Object (Act) = Inst then
return False;
elsif Present (Associated_Formal_Package (Act))
and then Renamed_Object (Act) = Scop
then
-- Entity comes from (instance of) formal package
return True;
else
Next_Entity (Act);
end if;
else
Next_Entity (Act);
end if;
end loop;
return False;
end if;
end From_Actual_Package;
-------------------------
-- Known_But_Invisible --
-------------------------
function Known_But_Invisible (E : Entity_Id) return Boolean is
Fname : File_Name_Type;
begin
-- Entities in Standard are always considered to be known
if Sloc (E) <= Standard_Location then
return True;
-- An entity that does not come from source is always considered
-- to be unknown, since it is an artifact of code expansion.
elsif not Comes_From_Source (E) then
return False;
-- In gnat internal mode, we consider all entities known
elsif GNAT_Mode then
return True;
end if;
-- Here we have an entity that is not from package Standard, and
-- which comes from Source. See if it comes from an internal file.
Fname := Unit_File_Name (Get_Source_Unit (E));
-- Case of from internal file
if Is_Internal_File_Name (Fname) then
-- Private part entities in internal files are never considered
-- to be known to the writer of normal application code.
if Is_Hidden (E) then
return False;
end if;
-- Entities from System packages other than System and
-- System.Storage_Elements are not considered to be known.
-- System.Auxxxx files are also considered known to the user.
-- Should refine this at some point to generally distinguish
-- between known and unknown internal files ???
Get_Name_String (Fname);
return
Name_Len < 2
or else
Name_Buffer (1 .. 2) /= "s-"
or else
Name_Buffer (3 .. 8) = "stoele"
or else
Name_Buffer (3 .. 5) = "aux";
-- If not an internal file, then entity is definitely known,
-- even if it is in a private part (the message generated will
-- note that it is in a private part)
else
return True;
end if;
end Known_But_Invisible;
-------------------
-- Nvis_Messages --
-------------------
procedure Nvis_Messages is
Comp_Unit : Node_Id;
Ent : Entity_Id;
Hidden : Boolean := False;
Item : Node_Id;
begin
-- Ada 2005 (AI-262): Generate a precise error concerning the
-- Beaujolais effect that was previously detected
if Nvis_Is_Private_Subprg then
pragma Assert (Nkind (E2) = N_Defining_Identifier
and then Ekind (E2) = E_Function
and then Scope (E2) = Standard_Standard
and then Has_Private_With (E2));
-- Find the sloc corresponding to the private with'ed unit
Comp_Unit := Cunit (Current_Sem_Unit);
Item := First (Context_Items (Comp_Unit));
Error_Msg_Sloc := No_Location;
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then Private_Present (Item)
and then Entity (Name (Item)) = E2
then
Error_Msg_Sloc := Sloc (Item);
exit;
end if;
Next (Item);
end loop;
pragma Assert (Error_Msg_Sloc /= No_Location);
Error_Msg_N ("(Ada 2005): hidden by private with clause #", N);
return;
end if;
Undefined (Nvis => True);
if Msg then
-- First loop does hidden declarations
Ent := Homonyms;
while Present (Ent) loop
if Is_Potentially_Use_Visible (Ent) then
if not Hidden then
Error_Msg_N ("multiple use clauses cause hiding!", N);
Hidden := True;
end if;
Error_Msg_Sloc := Sloc (Ent);
Error_Msg_N ("hidden declaration#!", N);
end if;
Ent := Homonym (Ent);
end loop;
-- If we found hidden declarations, then that's enough, don't
-- bother looking for non-visible declarations as well.
if Hidden then
return;
end if;
-- Second loop does non-directly visible declarations
Ent := Homonyms;
while Present (Ent) loop
if not Is_Potentially_Use_Visible (Ent) then
-- Do not bother the user with unknown entities
if not Known_But_Invisible (Ent) then
goto Continue;
end if;
Error_Msg_Sloc := Sloc (Ent);
-- Output message noting that there is a non-visible
-- declaration, distinguishing the private part case.
if Is_Hidden (Ent) then
Error_Msg_N ("non-visible (private) declaration#!", N);
else
Error_Msg_N ("non-visible declaration#!", N);
if Is_Compilation_Unit (Ent)
and then
Nkind (Parent (Parent (N))) = N_Use_Package_Clause
then
Error_Msg_NE
("\possibly missing with_clause for&", N, Ent);
end if;
end if;
-- Set entity and its containing package as referenced. We
-- can't be sure of this, but this seems a better choice
-- to avoid unused entity messages.
if Comes_From_Source (Ent) then
Set_Referenced (Ent);
Set_Referenced (Cunit_Entity (Get_Source_Unit (Ent)));
end if;
end if;
<<Continue>>
Ent := Homonym (Ent);
end loop;
end if;
end Nvis_Messages;
---------------
-- Undefined --
---------------
procedure Undefined (Nvis : Boolean) is
Emsg : Error_Msg_Id;
begin
-- We should never find an undefined internal name. If we do, then
-- see if we have previous errors. If so, ignore on the grounds that
-- it is probably a cascaded message (e.g. a block label from a badly
-- formed block). If no previous errors, then we have a real internal
-- error of some kind so raise an exception.
if Is_Internal_Name (Chars (N)) then
if Total_Errors_Detected /= 0 then
return;
else
raise Program_Error;
end if;
end if;
-- A very specialized error check, if the undefined variable is
-- a case tag, and the case type is an enumeration type, check
-- for a possible misspelling, and if so, modify the identifier
-- Named aggregate should also be handled similarly ???
if Nkind (N) = N_Identifier
and then Nkind (Parent (N)) = N_Case_Statement_Alternative
then
Get_Name_String (Chars (N));
declare
Case_Str : constant String := Name_Buffer (1 .. Name_Len);
Case_Stm : constant Node_Id := Parent (Parent (N));
Case_Typ : constant Entity_Id := Etype (Expression (Case_Stm));
Case_Rtp : constant Entity_Id := Root_Type (Case_Typ);
Lit : Node_Id;
begin
if Is_Enumeration_Type (Case_Typ)
and then Case_Rtp /= Standard_Character
and then Case_Rtp /= Standard_Wide_Character
and then Case_Rtp /= Standard_Wide_Wide_Character
then
Lit := First_Literal (Case_Typ);
Get_Name_String (Chars (Lit));
if Chars (Lit) /= Chars (N)
and then Is_Bad_Spelling_Of
(Case_Str, Name_Buffer (1 .. Name_Len))
then
Error_Msg_Node_2 := Lit;
Error_Msg_N
("& is undefined, assume misspelling of &", N);
Rewrite (N, New_Occurrence_Of (Lit, Sloc (N)));
return;
end if;
Lit := Next_Literal (Lit);
end if;
end;
end if;
-- Normal processing
Set_Entity (N, Any_Id);
Set_Etype (N, Any_Type);
-- We use the table Urefs to keep track of entities for which we
-- have issued errors for undefined references. Multiple errors
-- for a single name are normally suppressed, however we modify
-- the error message to alert the programmer to this effect.
for J in Urefs.First .. Urefs.Last loop
if Chars (N) = Chars (Urefs.Table (J).Node) then
if Urefs.Table (J).Err /= No_Error_Msg
and then Sloc (N) /= Urefs.Table (J).Loc
then
Error_Msg_Node_1 := Urefs.Table (J).Node;
if Urefs.Table (J).Nvis then
Change_Error_Text (Urefs.Table (J).Err,
"& is not visible (more references follow)");
else
Change_Error_Text (Urefs.Table (J).Err,
"& is undefined (more references follow)");
end if;
Urefs.Table (J).Err := No_Error_Msg;
end if;
-- Although we will set Msg False, and thus suppress the
-- message, we also set Error_Posted True, to avoid any
-- cascaded messages resulting from the undefined reference.
Msg := False;
Set_Error_Posted (N, True);
return;
end if;
end loop;
-- If entry not found, this is first undefined occurrence
if Nvis then
Error_Msg_N ("& is not visible!", N);
Emsg := Get_Msg_Id;
else
Error_Msg_N ("& is undefined!", N);
Emsg := Get_Msg_Id;
-- A very bizarre special check, if the undefined identifier
-- is put or put_line, then add a special error message (since
-- this is a very common error for beginners to make).
if Chars (N) = Name_Put or else Chars (N) = Name_Put_Line then
Error_Msg_N ("\possible missing with of 'Text_'I'O!", N);
end if;
-- Now check for possible misspellings
Get_Name_String (Chars (N));
declare
E : Entity_Id;
Ematch : Entity_Id := Empty;
Last_Name_Id : constant Name_Id :=
Name_Id (Nat (First_Name_Id) +
Name_Entries_Count - 1);
S : constant String (1 .. Name_Len) :=
Name_Buffer (1 .. Name_Len);
begin
for N in First_Name_Id .. Last_Name_Id loop
E := Get_Name_Entity_Id (N);
if Present (E)
and then (Is_Immediately_Visible (E)
or else
Is_Potentially_Use_Visible (E))
then
Get_Name_String (N);
if Is_Bad_Spelling_Of
(Name_Buffer (1 .. Name_Len), S)
then
Ematch := E;
exit;
end if;
end if;
end loop;
if Present (Ematch) then
Error_Msg_NE ("\possible misspelling of&", N, Ematch);
end if;
end;
end if;
-- Make entry in undefined references table unless the full
-- errors switch is set, in which case by refraining from
-- generating the table entry, we guarantee that we get an
-- error message for every undefined reference.
if not All_Errors_Mode then
Urefs.Increment_Last;
Urefs.Table (Urefs.Last).Node := N;
Urefs.Table (Urefs.Last).Err := Emsg;
Urefs.Table (Urefs.Last).Nvis := Nvis;
Urefs.Table (Urefs.Last).Loc := Sloc (N);
end if;
Msg := True;
end Undefined;
-- Start of processing for Find_Direct_Name
begin
-- If the entity pointer is already set, this is an internal node, or
-- a node that is analyzed more than once, after a tree modification.
-- In such a case there is no resolution to perform, just set the type.
if Present (Entity (N)) then
if Is_Type (Entity (N)) then
Set_Etype (N, Entity (N));
else
declare
Entyp : constant Entity_Id := Etype (Entity (N));
begin
-- One special case here. If the Etype field is already set,
-- and references the packed array type corresponding to the
-- etype of the referenced entity, then leave it alone. This
-- happens for trees generated from Exp_Pakd, where expressions
-- can be deliberately "mis-typed" to the packed array type.
if Is_Array_Type (Entyp)
and then Is_Packed (Entyp)
and then Present (Etype (N))
and then Etype (N) = Packed_Array_Type (Entyp)
then
null;
-- If not that special case, then just reset the Etype
else
Set_Etype (N, Etype (Entity (N)));
end if;
end;
end if;
return;
end if;
-- Here if Entity pointer was not set, we need full visibility analysis
-- First we generate debugging output if the debug E flag is set.
if Debug_Flag_E then
Write_Str ("Looking for ");
Write_Name (Chars (N));
Write_Eol;
end if;
Homonyms := Current_Entity (N);
Nvis_Entity := False;
E := Homonyms;
while Present (E) loop
-- If entity is immediately visible or potentially use
-- visible, then process the entity and we are done.
if Is_Immediately_Visible (E) then
goto Immediately_Visible_Entity;
elsif Is_Potentially_Use_Visible (E) then
goto Potentially_Use_Visible_Entity;
-- Note if a known but invisible entity encountered
elsif Known_But_Invisible (E) then
Nvis_Entity := True;
end if;
-- Move to next entity in chain and continue search
E := Homonym (E);
end loop;
-- If no entries on homonym chain that were potentially visible,
-- and no entities reasonably considered as non-visible, then
-- we have a plain undefined reference, with no additional
-- explanation required!
if not Nvis_Entity then
Undefined (Nvis => False);
-- Otherwise there is at least one entry on the homonym chain that
-- is reasonably considered as being known and non-visible.
else
Nvis_Messages;
end if;
return;
-- Processing for a potentially use visible entry found. We must search
-- the rest of the homonym chain for two reasons. First, if there is a
-- directly visible entry, then none of the potentially use-visible
-- entities are directly visible (RM 8.4(10)). Second, we need to check
-- for the case of multiple potentially use-visible entries hiding one
-- another and as a result being non-directly visible (RM 8.4(11)).
<<Potentially_Use_Visible_Entity>> declare
Only_One_Visible : Boolean := True;
All_Overloadable : Boolean := Is_Overloadable (E);
begin
E2 := Homonym (E);
while Present (E2) loop
if Is_Immediately_Visible (E2) then
-- If the use-visible entity comes from the actual for a
-- formal package, it hides a directly visible entity from
-- outside the instance.
if From_Actual_Package (E)
and then Scope_Depth (E2) < Scope_Depth (Inst)
then
goto Found;
else
E := E2;
goto Immediately_Visible_Entity;
end if;
elsif Is_Potentially_Use_Visible (E2) then
Only_One_Visible := False;
All_Overloadable := All_Overloadable and Is_Overloadable (E2);
-- Ada 2005 (AI-262): Protect against a form of Beujolais effect
-- that can occurr in private_with clauses. Example:
-- with A;
-- private with B; package A is
-- package C is function B return Integer;
-- use A; end A;
-- V1 : Integer := B;
-- private function B return Integer;
-- V2 : Integer := B;
-- end C;
-- V1 resolves to A.B, but V2 resolves to library unit B
elsif Ekind (E2) = E_Function
and then Scope (E2) = Standard_Standard
and then Has_Private_With (E2)
then
Only_One_Visible := False;
All_Overloadable := False;
Nvis_Is_Private_Subprg := True;
exit;
end if;
E2 := Homonym (E2);
end loop;
-- On falling through this loop, we have checked that there are no
-- immediately visible entities. Only_One_Visible is set if exactly
-- one potentially use visible entity exists. All_Overloadable is
-- set if all the potentially use visible entities are overloadable.
-- The condition for legality is that either there is one potentially
-- use visible entity, or if there is more than one, then all of them
-- are overloadable.
if Only_One_Visible or All_Overloadable then
goto Found;
-- If there is more than one potentially use-visible entity and at
-- least one of them non-overloadable, we have an error (RM 8.4(11).
-- Note that E points to the first such entity on the homonym list.
-- Special case: if one of the entities is declared in an actual
-- package, it was visible in the generic, and takes precedence over
-- other entities that are potentially use-visible. Same if it is
-- declared in a local instantiation of the current instance.
else
if In_Instance then
Inst := Current_Scope;
-- Find current instance
while Present (Inst)
and then Inst /= Standard_Standard
loop
if Is_Generic_Instance (Inst) then
exit;
end if;
Inst := Scope (Inst);
end loop;
E2 := E;
while Present (E2) loop
if From_Actual_Package (E2)
or else
(Is_Generic_Instance (Scope (E2))
and then Scope_Depth (Scope (E2)) > Scope_Depth (Inst))
then
E := E2;
goto Found;
end if;
E2 := Homonym (E2);
end loop;
Nvis_Messages;
return;
elsif
Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
then
-- A use-clause in the body of a system file creates conflict
-- with some entity in a user scope, while rtsfind is active.
-- Keep only the entity coming from another predefined unit.
E2 := E;
while Present (E2) loop
if Is_Predefined_File_Name
(Unit_File_Name (Get_Source_Unit (Sloc (E2))))
then
E := E2;
goto Found;
end if;
E2 := Homonym (E2);
end loop;
-- Entity must exist because predefined unit is correct
raise Program_Error;
else
Nvis_Messages;
return;
end if;
end if;
end;
-- Come here with E set to the first immediately visible entity on
-- the homonym chain. This is the one we want unless there is another
-- immediately visible entity further on in the chain for a more
-- inner scope (RM 8.3(8)).
<<Immediately_Visible_Entity>> declare
Level : Int;
Scop : Entity_Id;
begin
-- Find scope level of initial entity. When compiling through
-- Rtsfind, the previous context is not completely invisible, and
-- an outer entity may appear on the chain, whose scope is below
-- the entry for Standard that delimits the current scope stack.
-- Indicate that the level for this spurious entry is outside of
-- the current scope stack.
Level := Scope_Stack.Last;
loop
Scop := Scope_Stack.Table (Level).Entity;
exit when Scop = Scope (E);
Level := Level - 1;
exit when Scop = Standard_Standard;
end loop;
-- Now search remainder of homonym chain for more inner entry
-- If the entity is Standard itself, it has no scope, and we
-- compare it with the stack entry directly.
E2 := Homonym (E);
while Present (E2) loop
if Is_Immediately_Visible (E2) then
-- If a generic package contains a local declaration that
-- has the same name as the generic, there may be a visibility
-- conflict in an instance, where the local declaration must
-- also hide the name of the corresponding package renaming.
-- We check explicitly for a package declared by a renaming,
-- whose renamed entity is an instance that is on the scope
-- stack, and that contains a homonym in the same scope. Once
-- we have found it, we know that the package renaming is not
-- immediately visible, and that the identifier denotes the
-- other entity (and its homonyms if overloaded).
if Scope (E) = Scope (E2)
and then Ekind (E) = E_Package
and then Present (Renamed_Object (E))
and then Is_Generic_Instance (Renamed_Object (E))
and then In_Open_Scopes (Renamed_Object (E))
and then Comes_From_Source (N)
then
Set_Is_Immediately_Visible (E, False);
E := E2;
else
for J in Level + 1 .. Scope_Stack.Last loop
if Scope_Stack.Table (J).Entity = Scope (E2)
or else Scope_Stack.Table (J).Entity = E2
then
Level := J;
E := E2;
exit;
end if;
end loop;
end if;
end if;
E2 := Homonym (E2);
end loop;
-- At the end of that loop, E is the innermost immediately
-- visible entity, so we are all set.
end;
-- Come here with entity found, and stored in E
<<Found>> begin
if Comes_From_Source (N)
and then Is_Remote_Access_To_Subprogram_Type (E)
and then Expander_Active
and then Get_PCS_Name /= Name_No_DSA
then
Rewrite (N,
New_Occurrence_Of (Equivalent_Type (E), Sloc (N)));
return;
end if;
Set_Entity (N, E);
-- Why no Style_Check here???
if Is_Type (E) then
Set_Etype (N, E);
else
Set_Etype (N, Get_Full_View (Etype (E)));
end if;
if Debug_Flag_E then
Write_Str (" found ");
Write_Entity_Info (E, " ");
end if;
-- If the Ekind of the entity is Void, it means that all homonyms
-- are hidden from all visibility (RM 8.3(5,14-20)). However, this
-- test is skipped if the current scope is a record and the name is
-- a pragma argument expression (case of Atomic and Volatile pragmas
-- and possibly other similar pragmas added later, which are allowed
-- to reference components in the current record).
if Ekind (E) = E_Void
and then
(not Is_Record_Type (Current_Scope)
or else Nkind (Parent (N)) /= N_Pragma_Argument_Association)
then
Premature_Usage (N);
-- If the entity is overloadable, collect all interpretations
-- of the name for subsequent overload resolution. We optimize
-- a bit here to do this only if we have an overloadable entity
-- that is not on its own on the homonym chain.
elsif Is_Overloadable (E)
and then (Present (Homonym (E)) or else Current_Entity (N) /= E)
then
Collect_Interps (N);
-- If no homonyms were visible, the entity is unambiguous
if not Is_Overloaded (N) then
Generate_Reference (E, N);
end if;
-- Case of non-overloadable entity, set the entity providing that
-- we do not have the case of a discriminant reference within a
-- default expression. Such references are replaced with the
-- corresponding discriminal, which is the formal corresponding to
-- to the discriminant in the initialization procedure.
else
-- Entity is unambiguous, indicate that it is referenced here
-- One slightly odd case is that we do not want to set the
-- Referenced flag if the entity is a label, and the identifier
-- is the label in the source, since this is not a reference
-- from the point of view of the user
if Nkind (Parent (N)) = N_Label then
declare
R : constant Boolean := Referenced (E);
begin
Generate_Reference (E, N);
Set_Referenced (E, R);
end;
-- Normal case, not a label. Generate reference
else
Generate_Reference (E, N);
end if;
-- Set Entity, with style check if need be. If this is a
-- discriminant reference, it must be replaced by the
-- corresponding discriminal, that is to say the parameter
-- of the initialization procedure that corresponds to the
-- discriminant. If this replacement is being performed, there
-- is no style check to perform.
-- This replacement must not be done if we are currently
-- processing a generic spec or body, because the discriminal
-- has not been not generated in this case.
if not In_Default_Expression
or else Ekind (E) /= E_Discriminant
or else Inside_A_Generic
then
Set_Entity_With_Style_Check (N, E);
-- The replacement is not done either for a task discriminant that
-- appears in a default expression of an entry parameter. See
-- Expand_Discriminant in exp_ch2 for details on their handling.
elsif Is_Concurrent_Type (Scope (E)) then
declare
P : Node_Id := Parent (N);
begin
while Present (P)
and then Nkind (P) /= N_Parameter_Specification
and then Nkind (P) /= N_Component_Declaration
loop
P := Parent (P);
end loop;
if Present (P)
and then Nkind (P) = N_Parameter_Specification
then
null;
else
Set_Entity (N, Discriminal (E));
end if;
end;
-- Otherwise, this is a discriminant in a context in which
-- it is a reference to the corresponding parameter of the
-- init proc for the enclosing type.
else
Set_Entity (N, Discriminal (E));
end if;
end if;
end;
end Find_Direct_Name;
------------------------
-- Find_Expanded_Name --
------------------------
-- This routine searches the homonym chain of the entity until it finds
-- an entity declared in the scope denoted by the prefix. If the entity
-- is private, it may nevertheless be immediately visible, if we are in
-- the scope of its declaration.
procedure Find_Expanded_Name (N : Node_Id) is
Selector : constant Node_Id := Selector_Name (N);
Candidate : Entity_Id := Empty;
P_Name : Entity_Id;
O_Name : Entity_Id;
Id : Entity_Id;
begin
P_Name := Entity (Prefix (N));
O_Name := P_Name;
-- If the prefix is a renamed package, look for the entity
-- in the original package.
if Ekind (P_Name) = E_Package
and then Present (Renamed_Object (P_Name))
then
P_Name := Renamed_Object (P_Name);
-- Rewrite node with entity field pointing to renamed object
Rewrite (Prefix (N), New_Copy (Prefix (N)));
Set_Entity (Prefix (N), P_Name);
-- If the prefix is an object of a concurrent type, look for
-- the entity in the associated task or protected type.
elsif Is_Concurrent_Type (Etype (P_Name)) then
P_Name := Etype (P_Name);
end if;
Id := Current_Entity (Selector);
while Present (Id) loop
if Scope (Id) = P_Name then
Candidate := Id;
if Is_Child_Unit (Id) then
exit when Is_Visible_Child_Unit (Id)
or else Is_Immediately_Visible (Id);
else
exit when not Is_Hidden (Id)
or else Is_Immediately_Visible (Id);
end if;
end if;
Id := Homonym (Id);
end loop;
if No (Id)
and then (Ekind (P_Name) = E_Procedure
or else
Ekind (P_Name) = E_Function)
and then Is_Generic_Instance (P_Name)
then
-- Expanded name denotes entity in (instance of) generic subprogram.
-- The entity may be in the subprogram instance, or may denote one of
-- the formals, which is declared in the enclosing wrapper package.
P_Name := Scope (P_Name);
Id := Current_Entity (Selector);
while Present (Id) loop
exit when Scope (Id) = P_Name;
Id := Homonym (Id);
end loop;
end if;
if No (Id) or else Chars (Id) /= Chars (Selector) then
Set_Etype (N, Any_Type);
-- If we are looking for an entity defined in System, try to
-- find it in the child package that may have been provided as
-- an extension to System. The Extend_System pragma will have
-- supplied the name of the extension, which may have to be loaded.
if Chars (P_Name) = Name_System
and then Scope (P_Name) = Standard_Standard
and then Present (System_Extend_Unit)
and then Present_System_Aux (N)
then
Set_Entity (Prefix (N), System_Aux_Id);
Find_Expanded_Name (N);
return;
elsif Nkind (Selector) = N_Operator_Symbol
and then Has_Implicit_Operator (N)
then
-- There is an implicit instance of the predefined operator in
-- the given scope. The operator entity is defined in Standard.
-- Has_Implicit_Operator makes the node into an Expanded_Name.
return;
elsif Nkind (Selector) = N_Character_Literal
and then Has_Implicit_Character_Literal (N)
then
-- If there is no literal defined in the scope denoted by the
-- prefix, the literal may belong to (a type derived from)
-- Standard_Character, for which we have no explicit literals.
return;
else
-- If the prefix is a single concurrent object, use its
-- name in the error message, rather than that of the
-- anonymous type.
if Is_Concurrent_Type (P_Name)
and then Is_Internal_Name (Chars (P_Name))
then
Error_Msg_Node_2 := Entity (Prefix (N));
else
Error_Msg_Node_2 := P_Name;
end if;
if P_Name = System_Aux_Id then
P_Name := Scope (P_Name);
Set_Entity (Prefix (N), P_Name);
end if;
if Present (Candidate) then
if Is_Child_Unit (Candidate) then
-- If the candidate is a private child unit and we are
-- in the visible part of a public unit, specialize the
-- error message. There might be a private with_clause for
-- it, but it is not currently active.
if Is_Private_Descendant (Candidate)
and then Ekind (Current_Scope) = E_Package
and then not In_Private_Part (Current_Scope)
and then not Is_Private_Descendant (Current_Scope)
then
Error_Msg_N ("private child unit& is not visible here",
Selector);
else
Error_Msg_N
("missing with_clause for child unit &", Selector);
end if;
else
Error_Msg_NE ("& is not a visible entity of&", N, Selector);
end if;
else
-- Within the instantiation of a child unit, the prefix may
-- denote the parent instance, but the selector has the
-- name of the original child. Find whether we are within
-- the corresponding instance, and get the proper entity, which
-- can only be an enclosing scope.
if O_Name /= P_Name
and then In_Open_Scopes (P_Name)
and then Is_Generic_Instance (P_Name)
then
declare
S : Entity_Id := Current_Scope;
P : Entity_Id;
begin
for J in reverse 0 .. Scope_Stack.Last loop
S := Scope_Stack.Table (J).Entity;
exit when S = Standard_Standard;
if Ekind (S) = E_Function
or else Ekind (S) = E_Package
or else Ekind (S) = E_Procedure
then
P := Generic_Parent (Specification
(Unit_Declaration_Node (S)));
if Present (P)
and then Chars (Scope (P)) = Chars (O_Name)
and then Chars (P) = Chars (Selector)
then
Id := S;
goto Found;
end if;
end if;
end loop;
end;
end if;
if Chars (P_Name) = Name_Ada
and then Scope (P_Name) = Standard_Standard
then
Error_Msg_Node_2 := Selector;
Error_Msg_NE ("missing with for `&.&`", N, P_Name);
-- If this is a selection from a dummy package, then
-- suppress the error message, of course the entity
-- is missing if the package is missing!
elsif Sloc (Error_Msg_Node_2) = No_Location then
null;
-- Here we have the case of an undefined component
else
Error_Msg_NE ("& not declared in&", N, Selector);
-- Check for misspelling of some entity in prefix
Id := First_Entity (P_Name);
Get_Name_String (Chars (Selector));
declare
S : constant String (1 .. Name_Len) :=
Name_Buffer (1 .. Name_Len);
begin
while Present (Id) loop
Get_Name_String (Chars (Id));
if Is_Bad_Spelling_Of
(Name_Buffer (1 .. Name_Len), S)
and then not Is_Internal_Name (Chars (Id))
then
Error_Msg_NE
("possible misspelling of&", Selector, Id);
exit;
end if;
Next_Entity (Id);
end loop;
end;
-- Specialize the message if this may be an instantiation
-- of a child unit that was not mentioned in the context.
if Nkind (Parent (N)) = N_Package_Instantiation
and then Is_Generic_Instance (Entity (Prefix (N)))
and then Is_Compilation_Unit
(Generic_Parent (Parent (Entity (Prefix (N)))))
then
Error_Msg_NE
("\possible missing with clause on child unit&",
N, Selector);
end if;
end if;
end if;
Id := Any_Id;
end if;
end if;
<<Found>>
if Comes_From_Source (N)
and then Is_Remote_Access_To_Subprogram_Type (Id)
and then Present (Equivalent_Type (Id))
then
-- If we are not actually generating distribution code (i.e.
-- the current PCS is the dummy non-distributed version), then
-- the Equivalent_Type will be missing, and Id should be treated
-- as a regular access-to-subprogram type.
Id := Equivalent_Type (Id);
Set_Chars (Selector, Chars (Id));
end if;
-- Ada 2005 (AI-50217): Check usage of entities in limited withed units
if Ekind (P_Name) = E_Package
and then From_With_Type (P_Name)
then
if From_With_Type (Id)
or else Is_Type (Id)
or else Ekind (Id) = E_Package
then
null;
else
Error_Msg_N
("limited withed package can only be used to access "
& " incomplete types",
N);
end if;
end if;
if Is_Task_Type (P_Name)
and then ((Ekind (Id) = E_Entry
and then Nkind (Parent (N)) /= N_Attribute_Reference)
or else
(Ekind (Id) = E_Entry_Family
and then
Nkind (Parent (Parent (N))) /= N_Attribute_Reference))
then
-- It is an entry call after all, either to the current task
-- (which will deadlock) or to an enclosing task.
Analyze_Selected_Component (N);
return;
end if;
Change_Selected_Component_To_Expanded_Name (N);
-- Do style check and generate reference, but skip both steps if this
-- entity has homonyms, since we may not have the right homonym set
-- yet. The proper homonym will be set during the resolve phase.
if Has_Homonym (Id) then
Set_Entity (N, Id);
else
Set_Entity_With_Style_Check (N, Id);
Generate_Reference (Id, N);
end if;
if Is_Type (Id) then
Set_Etype (N, Id);
else
Set_Etype (N, Get_Full_View (Etype (Id)));
end if;
-- If the Ekind of the entity is Void, it means that all homonyms
-- are hidden from all visibility (RM 8.3(5,14-20)).
if Ekind (Id) = E_Void then
Premature_Usage (N);
elsif Is_Overloadable (Id)
and then Present (Homonym (Id))
then
declare
H : Entity_Id := Homonym (Id);
begin
while Present (H) loop
if Scope (H) = Scope (Id)
and then
(not Is_Hidden (H)
or else Is_Immediately_Visible (H))
then
Collect_Interps (N);
exit;
end if;
H := Homonym (H);
end loop;
-- If an extension of System is present, collect possible
-- explicit overloadings declared in the extension.
if Chars (P_Name) = Name_System
and then Scope (P_Name) = Standard_Standard
and then Present (System_Extend_Unit)
and then Present_System_Aux (N)
then
H := Current_Entity (Id);
while Present (H) loop
if Scope (H) = System_Aux_Id then
Add_One_Interp (N, H, Etype (H));
end if;
H := Homonym (H);
end loop;
end if;
end;
end if;
if Nkind (Selector_Name (N)) = N_Operator_Symbol
and then Scope (Id) /= Standard_Standard
then
-- In addition to user-defined operators in the given scope,
-- there may be an implicit instance of the predefined
-- operator. The operator (defined in Standard) is found
-- in Has_Implicit_Operator, and added to the interpretations.
-- Procedure Add_One_Interp will determine which hides which.
if Has_Implicit_Operator (N) then
null;
end if;
end if;
end Find_Expanded_Name;
-------------------------
-- Find_Renamed_Entity --
-------------------------
function Find_Renamed_Entity
(N : Node_Id;
Nam : Node_Id;
New_S : Entity_Id;
Is_Actual : Boolean := False) return Entity_Id
is
Ind : Interp_Index;
I1 : Interp_Index := 0; -- Suppress junk warnings
It : Interp;
It1 : Interp;
Old_S : Entity_Id;
Inst : Entity_Id;
function Enclosing_Instance return Entity_Id;
-- If the renaming determines the entity for the default of a formal
-- subprogram nested within another instance, choose the innermost
-- candidate. This is because if the formal has a box, and we are within
-- an enclosing instance where some candidate interpretations are local
-- to this enclosing instance, we know that the default was properly
-- resolved when analyzing the generic, so we prefer the local
-- candidates to those that are external. This is not always the case
-- but is a reasonable heuristic on the use of nested generics.
-- The proper solution requires a full renaming model.
function Within (Inner, Outer : Entity_Id) return Boolean;
-- Determine whether a candidate subprogram is defined within
-- the enclosing instance. If yes, it has precedence over outer
-- candidates.
function Is_Visible_Operation (Op : Entity_Id) return Boolean;
-- If the renamed entity is an implicit operator, check whether it is
-- visible because its operand type is properly visible. This
-- check applies to explicit renamed entities that appear in the
-- source in a renaming declaration or a formal subprogram instance,
-- but not to default generic actuals with a name.
------------------------
-- Enclosing_Instance --
------------------------
function Enclosing_Instance return Entity_Id is
S : Entity_Id;
begin
if not Is_Generic_Instance (Current_Scope)
and then not Is_Actual
then
return Empty;
end if;
S := Scope (Current_Scope);
while S /= Standard_Standard loop
if Is_Generic_Instance (S) then
return S;
end if;
S := Scope (S);
end loop;
return Empty;
end Enclosing_Instance;
--------------------------
-- Is_Visible_Operation --
--------------------------
function Is_Visible_Operation (Op : Entity_Id) return Boolean is
Scop : Entity_Id;
Typ : Entity_Id;
Btyp : Entity_Id;
begin
if Ekind (Op) /= E_Operator
or else Scope (Op) /= Standard_Standard
or else (In_Instance
and then
(not Is_Actual
or else Present (Enclosing_Instance)))
then
return True;
else
-- For a fixed point type operator, check the resulting type,
-- because it may be a mixed mode integer * fixed operation.
if Present (Next_Formal (First_Formal (New_S)))
and then Is_Fixed_Point_Type (Etype (New_S))
then
Typ := Etype (New_S);
else
Typ := Etype (First_Formal (New_S));
end if;
Btyp := Base_Type (Typ);
if Nkind (Nam) /= N_Expanded_Name then
return (In_Open_Scopes (Scope (Btyp))
or else Is_Potentially_Use_Visible (Btyp)
or else In_Use (Btyp)
or else In_Use (Scope (Btyp)));
else
Scop := Entity (Prefix (Nam));
if Ekind (Scop) = E_Package
and then Present (Renamed_Object (Scop))
then
Scop := Renamed_Object (Scop);
end if;
-- Operator is visible if prefix of expanded name denotes
-- scope of type, or else type type is defined in System_Aux
-- and the prefix denotes System.
return Scope (Btyp) = Scop
or else (Scope (Btyp) = System_Aux_Id
and then Scope (Scope (Btyp)) = Scop);
end if;
end if;
end Is_Visible_Operation;
------------
-- Within --
------------
function Within (Inner, Outer : Entity_Id) return Boolean is
Sc : Entity_Id := Scope (Inner);
begin
while Sc /= Standard_Standard loop
if Sc = Outer then
return True;
else
Sc := Scope (Sc);
end if;
end loop;
return False;
end Within;
function Report_Overload return Entity_Id;
-- List possible interpretations, and specialize message in the
-- case of a generic actual.
function Report_Overload return Entity_Id is
begin
if Is_Actual then
Error_Msg_NE
("ambiguous actual subprogram&, " &
"possible interpretations: ", N, Nam);
else
Error_Msg_N
("ambiguous subprogram, " &
"possible interpretations: ", N);
end if;
List_Interps (Nam, N);
return Old_S;
end Report_Overload;
-- Start of processing for Find_Renamed_Entry
begin
Old_S := Any_Id;
Candidate_Renaming := Empty;
if not Is_Overloaded (Nam) then
if Entity_Matches_Spec (Entity (Nam), New_S)
and then Is_Visible_Operation (Entity (Nam))
then
Old_S := Entity (Nam);
elsif
Present (First_Formal (Entity (Nam)))
and then Present (First_Formal (New_S))
and then (Base_Type (Etype (First_Formal (Entity (Nam))))
= Base_Type (Etype (First_Formal (New_S))))
then
Candidate_Renaming := Entity (Nam);
end if;
else
Get_First_Interp (Nam, Ind, It);
while Present (It.Nam) loop
if Entity_Matches_Spec (It.Nam, New_S)
and then Is_Visible_Operation (It.Nam)
then
if Old_S /= Any_Id then
-- Note: The call to Disambiguate only happens if a
-- previous interpretation was found, in which case I1
-- has received a value.
It1 := Disambiguate (Nam, I1, Ind, Etype (Old_S));
if It1 = No_Interp then
Inst := Enclosing_Instance;
if Present (Inst) then
if Within (It.Nam, Inst) then
return (It.Nam);
elsif Within (Old_S, Inst) then
return (Old_S);
else
return Report_Overload;
end if;
else
return Report_Overload;
end if;
else
Old_S := It1.Nam;
exit;
end if;
else
I1 := Ind;
Old_S := It.Nam;
end if;
elsif
Present (First_Formal (It.Nam))
and then Present (First_Formal (New_S))
and then (Base_Type (Etype (First_Formal (It.Nam)))
= Base_Type (Etype (First_Formal (New_S))))
then
Candidate_Renaming := It.Nam;
end if;
Get_Next_Interp (Ind, It);
end loop;
Set_Entity (Nam, Old_S);
Set_Is_Overloaded (Nam, False);
end if;
return Old_S;
end Find_Renamed_Entity;
-----------------------------
-- Find_Selected_Component --
-----------------------------
procedure Find_Selected_Component (N : Node_Id) is
P : constant Node_Id := Prefix (N);
P_Name : Entity_Id;
-- Entity denoted by prefix
P_Type : Entity_Id;
-- and its type
Nam : Node_Id;
begin
Analyze (P);
if Nkind (P) = N_Error then
return;
-- If the selector already has an entity, the node has been
-- constructed in the course of expansion, and is known to be
-- valid. Do not verify that it is defined for the type (it may
-- be a private component used in the expansion of record equality).
elsif Present (Entity (Selector_Name (N))) then
if No (Etype (N))
or else Etype (N) = Any_Type
then
declare
Sel_Name : constant Node_Id := Selector_Name (N);
Selector : constant Entity_Id := Entity (Sel_Name);
C_Etype : Node_Id;
begin
Set_Etype (Sel_Name, Etype (Selector));
if not Is_Entity_Name (P) then
Resolve (P);
end if;
-- Build an actual subtype except for the first parameter
-- of an init proc, where this actual subtype is by
-- definition incorrect, since the object is uninitialized
-- (and does not even have defined discriminants etc.)
if Is_Entity_Name (P)
and then Ekind (Entity (P)) = E_Function
then
Nam := New_Copy (P);
if Is_Overloaded (P) then
Save_Interps (P, Nam);
end if;
Rewrite (P,
Make_Function_Call (Sloc (P), Name => Nam));
Analyze_Call (P);
Analyze_Selected_Component (N);
return;
elsif Ekind (Selector) = E_Component
and then (not Is_Entity_Name (P)
or else Chars (Entity (P)) /= Name_uInit)
then
C_Etype :=
Build_Actual_Subtype_Of_Component (
Etype (Selector), N);
else
C_Etype := Empty;
end if;
if No (C_Etype) then
C_Etype := Etype (Selector);
else
Insert_Action (N, C_Etype);
C_Etype := Defining_Identifier (C_Etype);
end if;
Set_Etype (N, C_Etype);
end;
-- If this is the name of an entry or protected operation, and
-- the prefix is an access type, insert an explicit dereference,
-- so that entry calls are treated uniformly.
if Is_Access_Type (Etype (P))
and then Is_Concurrent_Type (Designated_Type (Etype (P)))
then
declare
New_P : constant Node_Id :=
Make_Explicit_Dereference (Sloc (P),
Prefix => Relocate_Node (P));
begin
Rewrite (P, New_P);
Set_Etype (P, Designated_Type (Etype (Prefix (P))));
end;
end if;
-- If the selected component appears within a default expression
-- and it has an actual subtype, the pre-analysis has not yet
-- completed its analysis, because Insert_Actions is disabled in
-- that context. Within the init proc of the enclosing type we
-- must complete this analysis, if an actual subtype was created.
elsif Inside_Init_Proc then
declare
Typ : constant Entity_Id := Etype (N);
Decl : constant Node_Id := Declaration_Node (Typ);
begin
if Nkind (Decl) = N_Subtype_Declaration
and then not Analyzed (Decl)
and then Is_List_Member (Decl)
and then No (Parent (Decl))
then
Remove (Decl);
Insert_Action (N, Decl);
end if;
end;
end if;
return;
elsif Is_Entity_Name (P) then
P_Name := Entity (P);
-- The prefix may denote an enclosing type which is the completion
-- of an incomplete type declaration.
if Is_Type (P_Name) then
Set_Entity (P, Get_Full_View (P_Name));
Set_Etype (P, Entity (P));
P_Name := Entity (P);
end if;
P_Type := Base_Type (Etype (P));
if Debug_Flag_E then
Write_Str ("Found prefix type to be ");
Write_Entity_Info (P_Type, " "); Write_Eol;
end if;
-- First check for components of a record object (not the
-- result of a call, which is handled below).
if Is_Appropriate_For_Record (P_Type)
and then not Is_Overloadable (P_Name)
and then not Is_Type (P_Name)
then
-- Selected component of record. Type checking will validate
-- name of selector.
Analyze_Selected_Component (N);
elsif Is_Appropriate_For_Entry_Prefix (P_Type)
and then not In_Open_Scopes (P_Name)
and then (not Is_Concurrent_Type (Etype (P_Name))
or else not In_Open_Scopes (Etype (P_Name)))
then
-- Call to protected operation or entry. Type checking is
-- needed on the prefix.
Analyze_Selected_Component (N);
elsif (In_Open_Scopes (P_Name)
and then Ekind (P_Name) /= E_Void
and then not Is_Overloadable (P_Name))
or else (Is_Concurrent_Type (Etype (P_Name))
and then In_Open_Scopes (Etype (P_Name)))
then
-- Prefix denotes an enclosing loop, block, or task, i.e. an
-- enclosing construct that is not a subprogram or accept.
Find_Expanded_Name (N);
elsif Ekind (P_Name) = E_Package then
Find_Expanded_Name (N);
elsif Is_Overloadable (P_Name) then
-- The subprogram may be a renaming (of an enclosing scope) as
-- in the case of the name of the generic within an instantiation.
if (Ekind (P_Name) = E_Procedure
or else Ekind (P_Name) = E_Function)
and then Present (Alias (P_Name))
and then Is_Generic_Instance (Alias (P_Name))
then
P_Name := Alias (P_Name);
end if;
if Is_Overloaded (P) then
-- The prefix must resolve to a unique enclosing construct
declare
Found : Boolean := False;
Ind : Interp_Index;
It : Interp;
begin
Get_First_Interp (P, Ind, It);
while Present (It.Nam) loop
if In_Open_Scopes (It.Nam) then
if Found then
Error_Msg_N (
"prefix must be unique enclosing scope", N);
Set_Entity (N, Any_Id);
Set_Etype (N, Any_Type);
return;
else
Found := True;
P_Name := It.Nam;
end if;
end if;
Get_Next_Interp (Ind, It);
end loop;
end;
end if;
if In_Open_Scopes (P_Name) then
Set_Entity (P, P_Name);
Set_Is_Overloaded (P, False);
Find_Expanded_Name (N);
else
-- If no interpretation as an expanded name is possible, it
-- must be a selected component of a record returned by a
-- function call. Reformat prefix as a function call, the
-- rest is done by type resolution. If the prefix is a
-- procedure or entry, as is P.X; this is an error.
if Ekind (P_Name) /= E_Function
and then (not Is_Overloaded (P)
or else
Nkind (Parent (N)) = N_Procedure_Call_Statement)
then
-- Prefix may mention a package that is hidden by a local
-- declaration: let the user know. Scan the full homonym
-- chain, the candidate package may be anywhere on it.
if Present (Homonym (Current_Entity (P_Name))) then
P_Name := Current_Entity (P_Name);
while Present (P_Name) loop
exit when Ekind (P_Name) = E_Package;
P_Name := Homonym (P_Name);
end loop;
if Present (P_Name) then
Error_Msg_Sloc := Sloc (Entity (Prefix (N)));
Error_Msg_NE
("package& is hidden by declaration#",
N, P_Name);
Set_Entity (Prefix (N), P_Name);
Find_Expanded_Name (N);
return;
else
P_Name := Entity (Prefix (N));
end if;
end if;
Error_Msg_NE
("invalid prefix in selected component&", N, P_Name);
Change_Selected_Component_To_Expanded_Name (N);
Set_Entity (N, Any_Id);
Set_Etype (N, Any_Type);
else
Nam := New_Copy (P);
Save_Interps (P, Nam);
Rewrite (P,
Make_Function_Call (Sloc (P), Name => Nam));
Analyze_Call (P);
Analyze_Selected_Component (N);
end if;
end if;
-- Remaining cases generate various error messages
else
-- Format node as expanded name, to avoid cascaded errors
Change_Selected_Component_To_Expanded_Name (N);
Set_Entity (N, Any_Id);
Set_Etype (N, Any_Type);
-- Issue error message, but avoid this if error issued already.
-- Use identifier of prefix if one is available.
if P_Name = Any_Id then
null;
elsif Ekind (P_Name) = E_Void then
Premature_Usage (P);
elsif Nkind (P) /= N_Attribute_Reference then
Error_Msg_N (
"invalid prefix in selected component&", P);
if Is_Access_Type (P_Type)
and then Ekind (Designated_Type (P_Type)) = E_Incomplete_Type
then
Error_Msg_N
("\dereference must not be of an incomplete type " &
"('R'M 3.10.1)", P);
end if;
else
Error_Msg_N (
"invalid prefix in selected component", P);
end if;
end if;
else
-- If prefix is not the name of an entity, it must be an expression,
-- whose type is appropriate for a record. This is determined by
-- type resolution.
Analyze_Selected_Component (N);
end if;
end Find_Selected_Component;
---------------
-- Find_Type --
---------------
procedure Find_Type (N : Node_Id) is
C : Entity_Id;
Typ : Entity_Id;
T : Entity_Id;
T_Name : Entity_Id;
begin
if N = Error then
return;
elsif Nkind (N) = N_Attribute_Reference then
-- Class attribute. This is only valid in Ada 95 mode, but we don't
-- do a check, since the tagged type referenced could only exist if
-- we were in 95 mode when it was declared (or, if we were in Ada
-- 83 mode, then an error message would already have been issued).
if Attribute_Name (N) = Name_Class then
Check_Restriction (No_Dispatch, N);
Find_Type (Prefix (N));
-- Propagate error from bad prefix
if Etype (Prefix (N)) = Any_Type then
Set_Entity (N, Any_Type);
Set_Etype (N, Any_Type);
return;
end if;
T := Base_Type (Entity (Prefix (N)));
-- Case type is not known to be tagged. Its appearance in
-- the prefix of the 'Class attribute indicates that the full
-- view will be tagged.
if not Is_Tagged_Type (T) then
if Ekind (T) = E_Incomplete_Type then
-- It is legal to denote the class type of an incomplete
-- type. The full type will have to be tagged, of course.
Set_Is_Tagged_Type (T);
Set_Primitive_Operations (T, New_Elmt_List);
Make_Class_Wide_Type (T);
Set_Entity (N, Class_Wide_Type (T));
Set_Etype (N, Class_Wide_Type (T));
elsif Ekind (T) = E_Private_Type
and then not Is_Generic_Type (T)
and then In_Private_Part (Scope (T))
then
-- The Class attribute can be applied to an untagged
-- private type fulfilled by a tagged type prior to
-- the full type declaration (but only within the
-- parent package's private part). Create the class-wide
-- type now and check that the full type is tagged
-- later during its analysis. Note that we do not
-- mark the private type as tagged, unlike the case
-- of incomplete types, because the type must still
-- appear untagged to outside units.
if No (Class_Wide_Type (T)) then
Make_Class_Wide_Type (T);
end if;
Set_Entity (N, Class_Wide_Type (T));
Set_Etype (N, Class_Wide_Type (T));
else
-- Should we introduce a type Any_Tagged and use
-- Wrong_Type here, it would be a bit more consistent???
Error_Msg_NE
("tagged type required, found}",
Prefix (N), First_Subtype (T));
Set_Entity (N, Any_Type);
return;
end if;
-- Case of tagged type
else
if Is_Concurrent_Type (T) then
if No (Corresponding_Record_Type (Entity (Prefix (N)))) then
-- Previous error. Use current type, which at least
-- provides some operations.
C := Entity (Prefix (N));
else
C := Class_Wide_Type
(Corresponding_Record_Type (Entity (Prefix (N))));
end if;
else
C := Class_Wide_Type (Entity (Prefix (N)));
end if;
Set_Entity_With_Style_Check (N, C);
Generate_Reference (C, N);
Set_Etype (N, C);
end if;
-- Base attribute, not allowed in Ada 83
elsif Attribute_Name (N) = Name_Base then
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Error_Msg_N
("(Ada 83) Base attribute not allowed in subtype mark", N);
else
Find_Type (Prefix (N));
Typ := Entity (Prefix (N));
if Ada_Version >= Ada_95
and then not Is_Scalar_Type (Typ)
and then not Is_Generic_Type (Typ)
then
Error_Msg_N
("prefix of Base attribute must be scalar type",
Prefix (N));
elsif Sloc (Typ) = Standard_Location
and then Base_Type (Typ) = Typ
and then Warn_On_Redundant_Constructs
then
Error_Msg_NE
("?redudant attribute, & is its own base type", N, Typ);
end if;
T := Base_Type (Typ);
-- Rewrite attribute reference with type itself (see similar
-- processing in Analyze_Attribute, case Base). Preserve
-- prefix if present, for other legality checks.
if Nkind (Prefix (N)) = N_Expanded_Name then
Rewrite (N,
Make_Expanded_Name (Sloc (N),
Chars => Chars (Entity (N)),
Prefix => New_Copy (Prefix (Prefix (N))),
Selector_Name =>
New_Reference_To (Entity (N), Sloc (N))));
else
Rewrite (N,
New_Reference_To (Entity (N), Sloc (N)));
end if;
Set_Entity (N, T);
Set_Etype (N, T);
end if;
-- All other attributes are invalid in a subtype mark
else
Error_Msg_N ("invalid attribute in subtype mark", N);
end if;
else
Analyze (N);
if Is_Entity_Name (N) then
T_Name := Entity (N);
else
Error_Msg_N ("subtype mark required in this context", N);
Set_Etype (N, Any_Type);
return;
end if;
if T_Name = Any_Id or else Etype (N) = Any_Type then
-- Undefined id. Make it into a valid type
Set_Entity (N, Any_Type);
elsif not Is_Type (T_Name)
and then T_Name /= Standard_Void_Type
then
Error_Msg_Sloc := Sloc (T_Name);
Error_Msg_N ("subtype mark required in this context", N);
Error_Msg_NE ("\found & declared#", N, T_Name);
Set_Entity (N, Any_Type);
else
T_Name := Get_Full_View (T_Name);
if In_Open_Scopes (T_Name) then
if Ekind (Base_Type (T_Name)) = E_Task_Type then
Error_Msg_N ("task type cannot be used as type mark " &
"within its own body", N);
else
Error_Msg_N ("type declaration cannot refer to itself", N);
end if;
Set_Etype (N, Any_Type);
Set_Entity (N, Any_Type);
Set_Error_Posted (T_Name);
return;
end if;
Set_Entity (N, T_Name);
Set_Etype (N, T_Name);
end if;
end if;
if Present (Etype (N)) and then Comes_From_Source (N) then
if Is_Fixed_Point_Type (Etype (N)) then
Check_Restriction (No_Fixed_Point, N);
elsif Is_Floating_Point_Type (Etype (N)) then
Check_Restriction (No_Floating_Point, N);
end if;
end if;
end Find_Type;
-------------------
-- Get_Full_View --
-------------------
function Get_Full_View (T_Name : Entity_Id) return Entity_Id is
begin
if Ekind (T_Name) = E_Incomplete_Type
and then Present (Full_View (T_Name))
then
return Full_View (T_Name);
elsif Is_Class_Wide_Type (T_Name)
and then Ekind (Root_Type (T_Name)) = E_Incomplete_Type
and then Present (Full_View (Root_Type (T_Name)))
then
return Class_Wide_Type (Full_View (Root_Type (T_Name)));
else
return T_Name;
end if;
end Get_Full_View;
------------------------------------
-- Has_Implicit_Character_Literal --
------------------------------------
function Has_Implicit_Character_Literal (N : Node_Id) return Boolean is
Id : Entity_Id;
Found : Boolean := False;
P : constant Entity_Id := Entity (Prefix (N));
Priv_Id : Entity_Id := Empty;
begin
if Ekind (P) = E_Package
and then not In_Open_Scopes (P)
then
Priv_Id := First_Private_Entity (P);
end if;
if P = Standard_Standard then
Change_Selected_Component_To_Expanded_Name (N);
Rewrite (N, Selector_Name (N));
Analyze (N);
Set_Etype (Original_Node (N), Standard_Character);
return True;
end if;
Id := First_Entity (P);
while Present (Id)
and then Id /= Priv_Id
loop
if Is_Character_Type (Id)
and then (Root_Type (Id) = Standard_Character
or else Root_Type (Id) = Standard_Wide_Character
or else Root_Type (Id) = Standard_Wide_Wide_Character)
and then Id = Base_Type (Id)
then
-- We replace the node with the literal itself, resolve as a
-- character, and set the type correctly.
if not Found then
Change_Selected_Component_To_Expanded_Name (N);
Rewrite (N, Selector_Name (N));
Analyze (N);
Set_Etype (N, Id);
Set_Etype (Original_Node (N), Id);
Found := True;
else
-- More than one type derived from Character in given scope.
-- Collect all possible interpretations.
Add_One_Interp (N, Id, Id);
end if;
end if;
Next_Entity (Id);
end loop;
return Found;
end Has_Implicit_Character_Literal;
----------------------
-- Has_Private_With --
----------------------
function Has_Private_With (E : Entity_Id) return Boolean is
Comp_Unit : constant Node_Id := Cunit (Current_Sem_Unit);
Item : Node_Id;
begin
Item := First (Context_Items (Comp_Unit));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then Private_Present (Item)
and then Entity (Name (Item)) = E
then
return True;
end if;
Next (Item);
end loop;
return False;
end Has_Private_With;
---------------------------
-- Has_Implicit_Operator --
---------------------------
function Has_Implicit_Operator (N : Node_Id) return Boolean is
Op_Id : constant Name_Id := Chars (Selector_Name (N));
P : constant Entity_Id := Entity (Prefix (N));
Id : Entity_Id;
Priv_Id : Entity_Id := Empty;
procedure Add_Implicit_Operator
(T : Entity_Id;
Op_Type : Entity_Id := Empty);
-- Add implicit interpretation to node N, using the type for which
-- a predefined operator exists. If the operator yields a boolean
-- type, the Operand_Type is implicitly referenced by the operator,
-- and a reference to it must be generated.
---------------------------
-- Add_Implicit_Operator --
---------------------------
procedure Add_Implicit_Operator
(T : Entity_Id;
Op_Type : Entity_Id := Empty)
is
Predef_Op : Entity_Id;
begin
Predef_Op := Current_Entity (Selector_Name (N));
while Present (Predef_Op)
and then Scope (Predef_Op) /= Standard_Standard
loop
Predef_Op := Homonym (Predef_Op);
end loop;
if Nkind (N) = N_Selected_Component then
Change_Selected_Component_To_Expanded_Name (N);
end if;
Add_One_Interp (N, Predef_Op, T);
-- For operators with unary and binary interpretations, add both
if Present (Homonym (Predef_Op)) then
Add_One_Interp (N, Homonym (Predef_Op), T);
end if;
-- The node is a reference to a predefined operator, and
-- an implicit reference to the type of its operands.
if Present (Op_Type) then
Generate_Operator_Reference (N, Op_Type);
else
Generate_Operator_Reference (N, T);
end if;
end Add_Implicit_Operator;
-- Start of processing for Has_Implicit_Operator
begin
if Ekind (P) = E_Package
and then not In_Open_Scopes (P)
then
Priv_Id := First_Private_Entity (P);
end if;
Id := First_Entity (P);
case Op_Id is
-- Boolean operators: an implicit declaration exists if the scope
-- contains a declaration for a derived Boolean type, or for an
-- array of Boolean type.
when Name_Op_And | Name_Op_Not | Name_Op_Or | Name_Op_Xor =>
while Id /= Priv_Id loop
if Valid_Boolean_Arg (Id)
and then Id = Base_Type (Id)
then
Add_Implicit_Operator (Id);
return True;
end if;
Next_Entity (Id);
end loop;
-- Equality: look for any non-limited type (result is Boolean)
when Name_Op_Eq | Name_Op_Ne =>
while Id /= Priv_Id loop
if Is_Type (Id)
and then not Is_Limited_Type (Id)
and then Id = Base_Type (Id)
then
Add_Implicit_Operator (Standard_Boolean, Id);
return True;
end if;
Next_Entity (Id);
end loop;
-- Comparison operators: scalar type, or array of scalar
when Name_Op_Lt | Name_Op_Le | Name_Op_Gt | Name_Op_Ge =>
while Id /= Priv_Id loop
if (Is_Scalar_Type (Id)
or else (Is_Array_Type (Id)
and then Is_Scalar_Type (Component_Type (Id))))
and then Id = Base_Type (Id)
then
Add_Implicit_Operator (Standard_Boolean, Id);
return True;
end if;
Next_Entity (Id);
end loop;
-- Arithmetic operators: any numeric type
when Name_Op_Abs |
Name_Op_Add |
Name_Op_Mod |
Name_Op_Rem |
Name_Op_Subtract |
Name_Op_Multiply |
Name_Op_Divide |
Name_Op_Expon =>
while Id /= Priv_Id loop
if Is_Numeric_Type (Id)
and then Id = Base_Type (Id)
then
Add_Implicit_Operator (Id);
return True;
end if;
Next_Entity (Id);
end loop;
-- Concatenation: any one-dimensional array type
when Name_Op_Concat =>
while Id /= Priv_Id loop
if Is_Array_Type (Id) and then Number_Dimensions (Id) = 1
and then Id = Base_Type (Id)
then
Add_Implicit_Operator (Id);
return True;
end if;
Next_Entity (Id);
end loop;
-- What is the others condition here? Should we be using a
-- subtype of Name_Id that would restrict to operators ???
when others => null;
end case;
-- If we fall through, then we do not have an implicit operator
return False;
end Has_Implicit_Operator;
--------------------
-- In_Open_Scopes --
--------------------
function In_Open_Scopes (S : Entity_Id) return Boolean is
begin
-- Since there are several scope stacks maintained by Scope_Stack each
-- delineated by Standard (see comments by definition of Scope_Stack)
-- it is necessary to end the search when Standard is reached.
for J in reverse 0 .. Scope_Stack.Last loop
if Scope_Stack.Table (J).Entity = S then
return True;
end if;
-- We need Is_Active_Stack_Base to tell us when to stop rather
-- than checking for Standard_Standard because there are cases
-- where Standard_Standard appears in the middle of the active
-- set of scopes. This affects the declaration and overriding
-- of private inherited operations in instantiations of generic
-- child units.
exit when Scope_Stack.Table (J).Is_Active_Stack_Base;
end loop;
return False;
end In_Open_Scopes;
-----------------------------
-- Inherit_Renamed_Profile --
-----------------------------
procedure Inherit_Renamed_Profile (New_S : Entity_Id; Old_S : Entity_Id) is
New_F : Entity_Id;
Old_F : Entity_Id;
Old_T : Entity_Id;
New_T : Entity_Id;
begin
if Ekind (Old_S) = E_Operator then
New_F := First_Formal (New_S);
while Present (New_F) loop
Set_Etype (New_F, Base_Type (Etype (New_F)));
Next_Formal (New_F);
end loop;
Set_Etype (New_S, Base_Type (Etype (New_S)));
else
New_F := First_Formal (New_S);
Old_F := First_Formal (Old_S);
while Present (New_F) loop
New_T := Etype (New_F);
Old_T := Etype (Old_F);
-- If the new type is a renaming of the old one, as is the
-- case for actuals in instances, retain its name, to simplify
-- later disambiguation.
if Nkind (Parent (New_T)) = N_Subtype_Declaration
and then Is_Entity_Name (Subtype_Indication (Parent (New_T)))
and then Entity (Subtype_Indication (Parent (New_T))) = Old_T
then
null;
else
Set_Etype (New_F, Old_T);
end if;
Next_Formal (New_F);
Next_Formal (Old_F);
end loop;
if Ekind (Old_S) = E_Function
or else Ekind (Old_S) = E_Enumeration_Literal
then
Set_Etype (New_S, Etype (Old_S));
end if;
end if;
end Inherit_Renamed_Profile;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Urefs.Init;
end Initialize;
-------------------------
-- Install_Use_Clauses --
-------------------------
procedure Install_Use_Clauses
(Clause : Node_Id;
Force_Installation : Boolean := False)
is
U : Node_Id := Clause;
P : Node_Id;
Id : Entity_Id;
begin
while Present (U) loop
-- Case of USE package
if Nkind (U) = N_Use_Package_Clause then
P := First (Names (U));
while Present (P) loop
Id := Entity (P);
if Ekind (Id) = E_Package then
if In_Use (Id) then
Note_Redundant_Use (P);
elsif Present (Renamed_Object (Id))
and then In_Use (Renamed_Object (Id))
then
Note_Redundant_Use (P);
elsif Force_Installation or else Applicable_Use (P) then
Use_One_Package (Id, U);
end if;
end if;
Next (P);
end loop;
-- case of USE TYPE
else
P := First (Subtype_Marks (U));
while Present (P) loop
if not Is_Entity_Name (P)
or else No (Entity (P))
then
null;
elsif Entity (P) /= Any_Type then
Use_One_Type (P);
end if;
Next (P);
end loop;
end if;
Next_Use_Clause (U);
end loop;
end Install_Use_Clauses;
-------------------------------------
-- Is_Appropriate_For_Entry_Prefix --
-------------------------------------
function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean is
P_Type : Entity_Id := T;
begin
if Is_Access_Type (P_Type) then
P_Type := Designated_Type (P_Type);
end if;
return Is_Task_Type (P_Type) or else Is_Protected_Type (P_Type);
end Is_Appropriate_For_Entry_Prefix;
-------------------------------
-- Is_Appropriate_For_Record --
-------------------------------
function Is_Appropriate_For_Record (T : Entity_Id) return Boolean is
function Has_Components (T1 : Entity_Id) return Boolean;
-- Determine if given type has components (i.e. is either a record
-- type or a type that has discriminants).
function Has_Components (T1 : Entity_Id) return Boolean is
begin
return Is_Record_Type (T1)
or else (Is_Private_Type (T1) and then Has_Discriminants (T1))
or else (Is_Task_Type (T1) and then Has_Discriminants (T1));
end Has_Components;
-- Start of processing for Is_Appropriate_For_Record
begin
return
Present (T)
and then (Has_Components (T)
or else (Is_Access_Type (T)
and then
Has_Components (Designated_Type (T))));
end Is_Appropriate_For_Record;
---------------
-- New_Scope --
---------------
procedure New_Scope (S : Entity_Id) is
E : Entity_Id;
begin
if Ekind (S) = E_Void then
null;
-- Set scope depth if not a non-concurrent type, and we have not
-- yet set the scope depth. This means that we have the first
-- occurrence of the scope, and this is where the depth is set.
elsif (not Is_Type (S) or else Is_Concurrent_Type (S))
and then not Scope_Depth_Set (S)
then
if S = Standard_Standard then
Set_Scope_Depth_Value (S, Uint_0);
elsif Is_Child_Unit (S) then
Set_Scope_Depth_Value (S, Uint_1);
elsif not Is_Record_Type (Current_Scope) then
if Ekind (S) = E_Loop then
Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope));
else
Set_Scope_Depth_Value (S, Scope_Depth (Current_Scope) + 1);
end if;
end if;
end if;
Scope_Stack.Increment_Last;
declare
SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last);
begin
SST.Entity := S;
SST.Save_Scope_Suppress := Scope_Suppress;
SST.Save_Local_Entity_Suppress := Local_Entity_Suppress.Last;
if Scope_Stack.Last > Scope_Stack.First then
SST.Component_Alignment_Default := Scope_Stack.Table
(Scope_Stack.Last - 1).
Component_Alignment_Default;
end if;
SST.Last_Subprogram_Name := null;
SST.Is_Transient := False;
SST.Node_To_Be_Wrapped := Empty;
SST.Pending_Freeze_Actions := No_List;
SST.Actions_To_Be_Wrapped_Before := No_List;
SST.Actions_To_Be_Wrapped_After := No_List;
SST.First_Use_Clause := Empty;
SST.Is_Active_Stack_Base := False;
end;
if Debug_Flag_W then
Write_Str ("--> new scope: ");
Write_Name (Chars (Current_Scope));
Write_Str (", Id=");
Write_Int (Int (Current_Scope));
Write_Str (", Depth=");
Write_Int (Int (Scope_Stack.Last));
Write_Eol;
end if;
-- Copy from Scope (S) the categorization flags to S, this is not
-- done in case Scope (S) is Standard_Standard since propagation
-- is from library unit entity inwards.
if S /= Standard_Standard
and then Scope (S) /= Standard_Standard
and then not Is_Child_Unit (S)
then
E := Scope (S);
if Nkind (E) not in N_Entity then
return;
end if;
-- We only propagate inwards for library level entities,
-- inner level subprograms do not inherit the categorization.
if Is_Library_Level_Entity (S) then
Set_Is_Preelaborated (S, Is_Preelaborated (E));
Set_Is_Shared_Passive (S, Is_Shared_Passive (E));
Set_Categorization_From_Scope (E => S, Scop => E);
end if;
end if;
end New_Scope;
------------------------
-- Note_Redundant_Use --
------------------------
procedure Note_Redundant_Use (Clause : Node_Id) is
Pack_Name : constant Entity_Id := Entity (Clause);
Cur_Use : constant Node_Id := Current_Use_Clause (Pack_Name);
Decl : constant Node_Id := Parent (Clause);
Prev_Use : Node_Id := Empty;
Redundant : Node_Id := Empty;
-- The Use_Clause which is actually redundant. In the simplest case
-- it is Pack itself, but when we compile a body we install its
-- context before that of its spec, in which case it is the use_clause
-- in the spec that will appear to be redundant, and we want the
-- warning to be placed on the body. Similar complications appear when
-- the redundancy is between a child unit and one of its ancestors.
begin
Set_Redundant_Use (Clause, True);
if not Comes_From_Source (Clause)
or else In_Instance
or else not Warn_On_Redundant_Constructs
then
return;
end if;
if not Is_Compilation_Unit (Current_Scope) then
-- If the use_clause is in an inner scope, it is made redundant
-- by some clause in the current context, with one exception:
-- If we're compiling a nested package body, and the use_clause
-- comes from the corresponding spec, the clause is not necessarily
-- fully redundant, so we should not warn. If a warning was
-- warranted, it would have been given when the spec was processed.
if Nkind (Parent (Decl)) = N_Package_Specification then
declare
Package_Spec_Entity : constant Entity_Id :=
Defining_Unit_Name (Parent (Decl));
begin
if In_Package_Body (Package_Spec_Entity) then
return;
end if;
end;
end if;
Redundant := Clause;
Prev_Use := Cur_Use;
elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Body then
declare
Cur_Unit : constant Unit_Number_Type := Get_Source_Unit (Cur_Use);
New_Unit : constant Unit_Number_Type := Get_Source_Unit (Clause);
Scop : Entity_Id;
begin
if Cur_Unit = New_Unit then
-- Redundant clause in same body
Redundant := Clause;
Prev_Use := Cur_Use;
elsif Cur_Unit = Current_Sem_Unit then
-- If the new clause is not in the current unit it has been
-- analyzed first, and it makes the other one redundant.
-- However, if the new clause appears in a subunit, Cur_Unit
-- is still the parent, and in that case the redundant one
-- is the one appearing in the subunit.
if Nkind (Unit (Cunit (New_Unit))) = N_Subunit then
Redundant := Clause;
Prev_Use := Cur_Use;
-- Most common case: redundant clause in body,
-- original clause in spec. Current scope is spec entity.
elsif
Current_Scope =
Defining_Entity (
Unit (Library_Unit (Cunit (Current_Sem_Unit))))
then
Redundant := Cur_Use;
Prev_Use := Clause;
else
-- The new clause may appear in an unrelated unit, when
-- the parents of a generic are being installed prior to
-- instantiation. In this case there must be no warning.
-- We detect this case by checking whether the current top
-- of the stack is related to the current compilation.
Scop := Current_Scope;
while Present (Scop)
and then Scop /= Standard_Standard
loop
if Is_Compilation_Unit (Scop)
and then not Is_Child_Unit (Scop)
then
return;
elsif Scop = Cunit_Entity (Current_Sem_Unit) then
exit;
end if;
Scop := Scope (Scop);
end loop;
Redundant := Cur_Use;
Prev_Use := Clause;
end if;
elsif New_Unit = Current_Sem_Unit then
Redundant := Clause;
Prev_Use := Cur_Use;
else
-- Neither is the current unit, so they appear in parent or
-- sibling units. Warning will be emitted elsewhere.
return;
end if;
end;
elsif Nkind (Unit (Cunit (Current_Sem_Unit))) = N_Package_Declaration
and then Present (Parent_Spec (Unit (Cunit (Current_Sem_Unit))))
then
-- Use_clause is in child unit of current unit, and the child
-- unit appears in the context of the body of the parent, so it
-- has been installed first, even though it is the redundant one.
-- Depending on their placement in the context, the visible or the
-- private parts of the two units, either might appear as redundant,
-- but the message has to be on the current unit.
if Get_Source_Unit (Cur_Use) = Current_Sem_Unit then
Redundant := Cur_Use;
Prev_Use := Clause;
else
Redundant := Clause;
Prev_Use := Cur_Use;
end if;
-- If the new use clause appears in the private part of a parent unit
-- it may appear to be redudant w.r.t. a use clause in a child unit,
-- but the previous use clause was needed in the visible part of the
-- child, and no warning should be emitted.
if Nkind (Parent (Decl)) = N_Package_Specification
and then
List_Containing (Decl) = Private_Declarations (Parent (Decl))
then
declare
Par : constant Entity_Id := Defining_Entity (Parent (Decl));
Spec : constant Node_Id :=
Specification (Unit (Cunit (Current_Sem_Unit)));
begin
if Is_Compilation_Unit (Par)
and then Par /= Cunit_Entity (Current_Sem_Unit)
and then Parent (Cur_Use) = Spec
and then
List_Containing (Cur_Use) = Visible_Declarations (Spec)
then
return;
end if;
end;
end if;
else
null;
end if;
if Present (Redundant) then
Error_Msg_Sloc := Sloc (Prev_Use);
Error_Msg_NE (
"& is already use_visible through declaration #?",
Redundant, Pack_Name);
end if;
end Note_Redundant_Use;
---------------
-- Pop_Scope --
---------------
procedure Pop_Scope is
SST : Scope_Stack_Entry renames Scope_Stack.Table (Scope_Stack.Last);
begin
if Debug_Flag_E then
Write_Info;
end if;
Scope_Suppress := SST.Save_Scope_Suppress;
Local_Entity_Suppress.Set_Last (SST.Save_Local_Entity_Suppress);
if Debug_Flag_W then
Write_Str ("--> exiting scope: ");
Write_Name (Chars (Current_Scope));
Write_Str (", Depth=");
Write_Int (Int (Scope_Stack.Last));
Write_Eol;
end if;
End_Use_Clauses (SST.First_Use_Clause);
-- If the actions to be wrapped are still there they will get lost
-- causing incomplete code to be generated. It is better to abort in
-- this case (and we do the abort even with assertions off since the
-- penalty is incorrect code generation)
if SST.Actions_To_Be_Wrapped_Before /= No_List
or else
SST.Actions_To_Be_Wrapped_After /= No_List
then
return;
end if;
-- Free last subprogram name if allocated, and pop scope
Free (SST.Last_Subprogram_Name);
Scope_Stack.Decrement_Last;
end Pop_Scope;
---------------------
-- Premature_Usage --
---------------------
procedure Premature_Usage (N : Node_Id) is
Kind : constant Node_Kind := Nkind (Parent (Entity (N)));
E : Entity_Id := Entity (N);
begin
-- Within an instance, the analysis of the actual for a formal object
-- does not see the name of the object itself. This is significant
-- only if the object is an aggregate, where its analysis does not do
-- any name resolution on component associations. (see 4717-008). In
-- such a case, look for the visible homonym on the chain.
if In_Instance
and then Present (Homonym (E))
then
E := Homonym (E);
while Present (E)
and then not In_Open_Scopes (Scope (E))
loop
E := Homonym (E);
end loop;
if Present (E) then
Set_Entity (N, E);
Set_Etype (N, Etype (E));
return;
end if;
end if;
if Kind = N_Component_Declaration then
Error_Msg_N
("component&! cannot be used before end of record declaration", N);
elsif Kind = N_Parameter_Specification then
Error_Msg_N
("formal parameter&! cannot be used before end of specification",
N);
elsif Kind = N_Discriminant_Specification then
Error_Msg_N
("discriminant&! cannot be used before end of discriminant part",
N);
elsif Kind = N_Procedure_Specification
or else Kind = N_Function_Specification
then
Error_Msg_N
("subprogram&! cannot be used before end of its declaration",
N);
else
Error_Msg_N
("object& cannot be used before end of its declaration!", N);
end if;
end Premature_Usage;
------------------------
-- Present_System_Aux --
------------------------
function Present_System_Aux (N : Node_Id := Empty) return Boolean is
Loc : Source_Ptr;
Aux_Name : Name_Id;
Unum : Unit_Number_Type;
Withn : Node_Id;
With_Sys : Node_Id;
The_Unit : Node_Id;
function Find_System (C_Unit : Node_Id) return Entity_Id;
-- Scan context clause of compilation unit to find a with_clause
-- for System.
-----------------
-- Find_System --
-----------------
function Find_System (C_Unit : Node_Id) return Entity_Id is
With_Clause : Node_Id;
begin
With_Clause := First (Context_Items (C_Unit));
while Present (With_Clause) loop
if (Nkind (With_Clause) = N_With_Clause
and then Chars (Name (With_Clause)) = Name_System)
and then Comes_From_Source (With_Clause)
then
return With_Clause;
end if;
Next (With_Clause);
end loop;
return Empty;
end Find_System;
-- Start of processing for Present_System_Aux
begin
-- The child unit may have been loaded and analyzed already
if Present (System_Aux_Id) then
return True;
-- If no previous pragma for System.Aux, nothing to load
elsif No (System_Extend_Unit) then
return False;
-- Use the unit name given in the pragma to retrieve the unit.
-- Verify that System itself appears in the context clause of the
-- current compilation. If System is not present, an error will
-- have been reported already.
else
With_Sys := Find_System (Cunit (Current_Sem_Unit));
The_Unit := Unit (Cunit (Current_Sem_Unit));
if No (With_Sys)
and then (Nkind (The_Unit) = N_Package_Body
or else (Nkind (The_Unit) = N_Subprogram_Body
and then not Acts_As_Spec (Cunit (Current_Sem_Unit))))
then
With_Sys := Find_System (Library_Unit (Cunit (Current_Sem_Unit)));
end if;
if No (With_Sys)
and then Present (N)
then
-- If we are compiling a subunit, we need to examine its
-- context as well (Current_Sem_Unit is the parent unit);
The_Unit := Parent (N);
while Nkind (The_Unit) /= N_Compilation_Unit loop
The_Unit := Parent (The_Unit);
end loop;
if Nkind (Unit (The_Unit)) = N_Subunit then
With_Sys := Find_System (The_Unit);
end if;
end if;
if No (With_Sys) then
return False;
end if;
Loc := Sloc (With_Sys);
Get_Name_String (Chars (Expression (System_Extend_Unit)));
Name_Buffer (8 .. Name_Len + 7) := Name_Buffer (1 .. Name_Len);
Name_Buffer (1 .. 7) := "system.";
Name_Buffer (Name_Len + 8) := '%';
Name_Buffer (Name_Len + 9) := 's';
Name_Len := Name_Len + 9;
Aux_Name := Name_Find;
Unum :=
Load_Unit
(Load_Name => Aux_Name,
Required => False,
Subunit => False,
Error_Node => With_Sys);
if Unum /= No_Unit then
Semantics (Cunit (Unum));
System_Aux_Id :=
Defining_Entity (Specification (Unit (Cunit (Unum))));
Withn := Make_With_Clause (Loc,
Name =>
Make_Expanded_Name (Loc,
Chars => Chars (System_Aux_Id),
Prefix =>
New_Reference_To (Scope (System_Aux_Id), Loc),
Selector_Name =>
New_Reference_To (System_Aux_Id, Loc)));
Set_Entity (Name (Withn), System_Aux_Id);
Set_Library_Unit (Withn, Cunit (Unum));
Set_Corresponding_Spec (Withn, System_Aux_Id);
Set_First_Name (Withn, True);
Set_Implicit_With (Withn, True);
Insert_After (With_Sys, Withn);
Mark_Rewrite_Insertion (Withn);
Set_Context_Installed (Withn);
return True;
-- Here if unit load failed
else
Error_Msg_Name_1 := Name_System;
Error_Msg_Name_2 := Chars (Expression (System_Extend_Unit));
Error_Msg_N
("extension package `%.%` does not exist",
Opt.System_Extend_Unit);
return False;
end if;
end if;
end Present_System_Aux;
-------------------------
-- Restore_Scope_Stack --
-------------------------
procedure Restore_Scope_Stack (Handle_Use : Boolean := True) is
E : Entity_Id;
S : Entity_Id;
Comp_Unit : Node_Id;
In_Child : Boolean := False;
Full_Vis : Boolean := True;
SS_Last : constant Int := Scope_Stack.Last;
begin
-- Restore visibility of previous scope stack, if any
for J in reverse 0 .. Scope_Stack.Last loop
exit when Scope_Stack.Table (J).Entity = Standard_Standard
or else No (Scope_Stack.Table (J).Entity);
S := Scope_Stack.Table (J).Entity;
if not Is_Hidden_Open_Scope (S) then
-- If the parent scope is hidden, its entities are hidden as
-- well, unless the entity is the instantiation currently
-- being analyzed.
if not Is_Hidden_Open_Scope (Scope (S))
or else not Analyzed (Parent (S))
or else Scope (S) = Standard_Standard
then
Set_Is_Immediately_Visible (S, True);
end if;
E := First_Entity (S);
while Present (E) loop
if Is_Child_Unit (E) then
Set_Is_Immediately_Visible (E,
Is_Visible_Child_Unit (E) or else In_Open_Scopes (E));
else
Set_Is_Immediately_Visible (E, True);
end if;
Next_Entity (E);
if not Full_Vis then
exit when E = First_Private_Entity (S);
end if;
end loop;
-- The visibility of child units (siblings of current compilation)
-- must be restored in any case. Their declarations may appear
-- after the private part of the parent.
if not Full_Vis
and then Present (E)
then
while Present (E) loop
if Is_Child_Unit (E) then
Set_Is_Immediately_Visible (E,
Is_Visible_Child_Unit (E) or else In_Open_Scopes (E));
end if;
Next_Entity (E);
end loop;
end if;
end if;
if Is_Child_Unit (S)
and not In_Child -- check only for current unit.
then
In_Child := True;
-- restore visibility of parents according to whether the child
-- is private and whether we are in its visible part.
Comp_Unit := Parent (Unit_Declaration_Node (S));
if Nkind (Comp_Unit) = N_Compilation_Unit
and then Private_Present (Comp_Unit)
then
Full_Vis := True;
elsif (Ekind (S) = E_Package
or else Ekind (S) = E_Generic_Package)
and then (In_Private_Part (S)
or else In_Package_Body (S))
then
Full_Vis := True;
elsif (Ekind (S) = E_Procedure
or else Ekind (S) = E_Function)
and then Has_Completion (S)
then
Full_Vis := True;
else
Full_Vis := False;
end if;
else
Full_Vis := True;
end if;
end loop;
if SS_Last >= Scope_Stack.First
and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard
and then Handle_Use
then
Install_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause);
end if;
end Restore_Scope_Stack;
----------------------
-- Save_Scope_Stack --
----------------------
procedure Save_Scope_Stack (Handle_Use : Boolean := True) is
E : Entity_Id;
S : Entity_Id;
SS_Last : constant Int := Scope_Stack.Last;
begin
if SS_Last >= Scope_Stack.First
and then Scope_Stack.Table (SS_Last).Entity /= Standard_Standard
then
if Handle_Use then
End_Use_Clauses (Scope_Stack.Table (SS_Last).First_Use_Clause);
end if;
-- If the call is from within a compilation unit, as when
-- called from Rtsfind, make current entries in scope stack
-- invisible while we analyze the new unit.
for J in reverse 0 .. SS_Last loop
exit when Scope_Stack.Table (J).Entity = Standard_Standard
or else No (Scope_Stack.Table (J).Entity);
S := Scope_Stack.Table (J).Entity;
Set_Is_Immediately_Visible (S, False);
E := First_Entity (S);
while Present (E) loop
Set_Is_Immediately_Visible (E, False);
Next_Entity (E);
end loop;
end loop;
end if;
end Save_Scope_Stack;
-------------
-- Set_Use --
-------------
procedure Set_Use (L : List_Id) is
Decl : Node_Id;
Pack_Name : Node_Id;
Pack : Entity_Id;
Id : Entity_Id;
begin
if Present (L) then
Decl := First (L);
while Present (Decl) loop
if Nkind (Decl) = N_Use_Package_Clause then
Chain_Use_Clause (Decl);
Pack_Name := First (Names (Decl));
while Present (Pack_Name) loop
Pack := Entity (Pack_Name);
if Ekind (Pack) = E_Package
and then Applicable_Use (Pack_Name)
then
Use_One_Package (Pack, Decl);
end if;
Next (Pack_Name);
end loop;
elsif Nkind (Decl) = N_Use_Type_Clause then
Chain_Use_Clause (Decl);
Id := First (Subtype_Marks (Decl));
while Present (Id) loop
if Entity (Id) /= Any_Type then
Use_One_Type (Id);
end if;
Next (Id);
end loop;
end if;
Next (Decl);
end loop;
end if;
end Set_Use;
---------------------
-- Use_One_Package --
---------------------
procedure Use_One_Package (P : Entity_Id; N : Node_Id) is
Id : Entity_Id;
Prev : Entity_Id;
Current_Instance : Entity_Id := Empty;
Real_P : Entity_Id;
Private_With_OK : Boolean := False;
begin
if Ekind (P) /= E_Package then
return;
end if;
Set_In_Use (P);
Set_Current_Use_Clause (P, N);
-- Ada 2005 (AI-50217): Check restriction
if From_With_Type (P) then
Error_Msg_N ("limited withed package cannot appear in use clause", N);
end if;
-- Find enclosing instance, if any
if In_Instance then
Current_Instance := Current_Scope;
while not Is_Generic_Instance (Current_Instance) loop
Current_Instance := Scope (Current_Instance);
end loop;
if No (Hidden_By_Use_Clause (N)) then
Set_Hidden_By_Use_Clause (N, New_Elmt_List);
end if;
end if;
-- If unit is a package renaming, indicate that the renamed
-- package is also in use (the flags on both entities must
-- remain consistent, and a subsequent use of either of them
-- should be recognized as redundant).
if Present (Renamed_Object (P)) then
Set_In_Use (Renamed_Object (P));
Set_Current_Use_Clause (Renamed_Object (P), N);
Real_P := Renamed_Object (P);
else
Real_P := P;
end if;
-- Ada 2005 (AI-262): Check the use_clause of a private withed package
-- found in the private part of a package specification
if In_Private_Part (Current_Scope)
and then Has_Private_With (P)
and then Is_Child_Unit (Current_Scope)
and then Is_Child_Unit (P)
and then Is_Ancestor_Package (Scope (Current_Scope), P)
then
Private_With_OK := True;
end if;
-- Loop through entities in one package making them potentially
-- use-visible.
Id := First_Entity (P);
while Present (Id)
and then (Id /= First_Private_Entity (P)
or else Private_With_OK) -- Ada 2005 (AI-262)
loop
Prev := Current_Entity (Id);
while Present (Prev) loop
if Is_Immediately_Visible (Prev)
and then (not Is_Overloadable (Prev)
or else not Is_Overloadable (Id)
or else (Type_Conformant (Id, Prev)))
then
if No (Current_Instance) then
-- Potentially use-visible entity remains hidden
goto Next_Usable_Entity;
-- A use clause within an instance hides outer global
-- entities, which are not used to resolve local entities
-- in the instance. Note that the predefined entities in
-- Standard could not have been hidden in the generic by
-- a use clause, and therefore remain visible. Other
-- compilation units whose entities appear in Standard must
-- be hidden in an instance.
-- To determine whether an entity is external to the instance
-- we compare the scope depth of its scope with that of the
-- current instance. However, a generic actual of a subprogram
-- instance is declared in the wrapper package but will not be
-- hidden by a use-visible entity.
-- If Id is called Standard, the predefined package with the
-- same name is in the homonym chain. It has to be ignored
-- because it has no defined scope (being the only entity in
-- the system with this mandated behavior).
elsif not Is_Hidden (Id)
and then Present (Scope (Prev))
and then not Is_Wrapper_Package (Scope (Prev))
and then Scope_Depth (Scope (Prev)) <
Scope_Depth (Current_Instance)
and then (Scope (Prev) /= Standard_Standard
or else Sloc (Prev) > Standard_Location)
then
Set_Is_Potentially_Use_Visible (Id);
Set_Is_Immediately_Visible (Prev, False);
Append_Elmt (Prev, Hidden_By_Use_Clause (N));
end if;
-- A user-defined operator is not use-visible if the
-- predefined operator for the type is immediately visible,
-- which is the case if the type of the operand is in an open
-- scope. This does not apply to user-defined operators that
-- have operands of different types, because the predefined
-- mixed mode operations (multiplication and division) apply to
-- universal types and do not hide anything.
elsif Ekind (Prev) = E_Operator
and then Operator_Matches_Spec (Prev, Id)
and then In_Open_Scopes
(Scope (Base_Type (Etype (First_Formal (Id)))))
and then (No (Next_Formal (First_Formal (Id)))
or else Etype (First_Formal (Id))
= Etype (Next_Formal (First_Formal (Id)))
or else Chars (Prev) = Name_Op_Expon)
then
goto Next_Usable_Entity;
end if;
Prev := Homonym (Prev);
end loop;
-- On exit, we know entity is not hidden, unless it is private
if not Is_Hidden (Id)
and then ((not Is_Child_Unit (Id))
or else Is_Visible_Child_Unit (Id))
then
Set_Is_Potentially_Use_Visible (Id);
if Is_Private_Type (Id)
and then Present (Full_View (Id))
then
Set_Is_Potentially_Use_Visible (Full_View (Id));
end if;
end if;
<<Next_Usable_Entity>>
Next_Entity (Id);
end loop;
-- Child units are also made use-visible by a use clause, but they
-- may appear after all visible declarations in the parent entity list.
while Present (Id) loop
if Is_Child_Unit (Id)
and then Is_Visible_Child_Unit (Id)
then
Set_Is_Potentially_Use_Visible (Id);
end if;
Next_Entity (Id);
end loop;
if Chars (Real_P) = Name_System
and then Scope (Real_P) = Standard_Standard
and then Present_System_Aux (N)
then
Use_One_Package (System_Aux_Id, N);
end if;
end Use_One_Package;
------------------
-- Use_One_Type --
------------------
procedure Use_One_Type (Id : Node_Id) is
T : Entity_Id;
Op_List : Elist_Id;
Elmt : Elmt_Id;
begin
-- It is the type determined by the subtype mark (8.4(8)) whose
-- operations become potentially use-visible.
T := Base_Type (Entity (Id));
Set_Redundant_Use
(Id,
In_Use (T)
or else Is_Potentially_Use_Visible (T)
or else In_Use (Scope (T)));
if In_Open_Scopes (Scope (T)) then
null;
-- If the subtype mark designates a subtype in a different package,
-- we have to check that the parent type is visible, otherwise the
-- use type clause is a noop. Not clear how to do that???
elsif not Redundant_Use (Id) then
Set_In_Use (T);
Op_List := Collect_Primitive_Operations (T);
Elmt := First_Elmt (Op_List);
while Present (Elmt) loop
if (Nkind (Node (Elmt)) = N_Defining_Operator_Symbol
or else Chars (Node (Elmt)) in Any_Operator_Name)
and then not Is_Hidden (Node (Elmt))
then
Set_Is_Potentially_Use_Visible (Node (Elmt));
end if;
Next_Elmt (Elmt);
end loop;
end if;
end Use_One_Type;
----------------
-- Write_Info --
----------------
procedure Write_Info is
Id : Entity_Id := First_Entity (Current_Scope);
begin
-- No point in dumping standard entities
if Current_Scope = Standard_Standard then
return;
end if;
Write_Str ("========================================================");
Write_Eol;
Write_Str (" Defined Entities in ");
Write_Name (Chars (Current_Scope));
Write_Eol;
Write_Str ("========================================================");
Write_Eol;
if No (Id) then
Write_Str ("-- none --");
Write_Eol;
else
while Present (Id) loop
Write_Entity_Info (Id, " ");
Next_Entity (Id);
end loop;
end if;
if Scope (Current_Scope) = Standard_Standard then
-- Print information on the current unit itself
Write_Entity_Info (Current_Scope, " ");
end if;
Write_Eol;
end Write_Info;
-----------------
-- Write_Scopes --
-----------------
procedure Write_Scopes is
S : Entity_Id;
begin
for J in reverse 1 .. Scope_Stack.Last loop
S := Scope_Stack.Table (J).Entity;
Write_Int (Int (S));
Write_Str (" === ");
Write_Name (Chars (S));
Write_Eol;
end loop;
end Write_Scopes;
end Sem_Ch8;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Discrete_Random;
procedure Avglen is
package IIO is new Ada.Text_IO.Integer_IO (Positive); use IIO;
package LFIO is new Ada.Text_IO.Float_IO (Long_Float); use LFIO;
subtype FactN is Natural range 0..20;
TESTS : constant Natural := 1_000_000;
function Factorial (N : FactN) return Long_Float is
Result : Long_Float := 1.0;
begin
for I in 2..N loop Result := Result * Long_Float(I); end loop;
return Result;
end Factorial;
function Analytical (N : FactN) return Long_Float is
Sum : Long_Float := 0.0;
begin
for I in 1..N loop
Sum := Sum + Factorial(N) / Factorial(N - I) / Long_Float(N)**I;
end loop;
return Sum;
end Analytical;
function Experimental (N : FactN) return Long_Float is
subtype RandInt is Natural range 1..N;
package Random is new Ada.Numerics.Discrete_Random(RandInt);
seed : Random.Generator;
Num : RandInt;
count : Natural := 0;
bits : array(RandInt'Range) of Boolean;
begin
Random.Reset(seed);
for run in 1..TESTS loop
bits := (others => false);
for I in RandInt'Range loop
Num := Random.Random(seed); exit when bits(Num);
bits(Num) := True; count := count + 1;
end loop;
end loop;
return Long_Float(count)/Long_Float(TESTS);
end Experimental;
A, E, err : Long_Float;
begin
Put_Line(" N avg calc %diff");
for I in 1..20 loop
A := Analytical(I); E := Experimental(I); err := abs(E-A)/A*100.0;
Put(I, Width=>2); Put(E ,Aft=>4, exp=>0); Put(A, Aft=>4, exp=>0);
Put(err, Fore=>3, Aft=>3, exp=>0); New_line;
end loop;
end Avglen;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . F I L E _ C O N T R O L _ B L O C K --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the declaration of the basic file control block
-- shared between Text_IO, Sequential_IO, Direct_IO and Streams.Stream_IO.
-- The actual control blocks are derived from this block by extension. The
-- control block is itself derived from Ada.Streams.Root_Stream_Type which
-- facilitates implementation of Stream_IO.Stream and Text_Streams.Stream.
with Ada.Streams;
with Interfaces.C_Streams;
with System.CRTL;
package System.File_Control_Block is
pragma Preelaborate;
----------------------------
-- Ada File Control Block --
----------------------------
-- The Ada file control block is an abstract extension of the root
-- stream type. This allows a file to be treated directly as a stream
-- for the purposes of Stream_IO, or stream operations on a text file.
-- The individual I/O packages extend this type with package specific
-- fields to create the concrete types to which the routines in this
-- package can be applied.
-- The type File_Type in the individual packages is an access to the
-- extended file control block. The value is null if the file is not
-- open, and a pointer to the control block if the file is open.
type Pstring is access all String;
-- Used to hold name and form strings
type File_Mode is (In_File, Inout_File, Out_File, Append_File);
subtype Read_File_Mode is File_Mode range In_File .. Inout_File;
-- File mode (union of file modes permitted by individual packages,
-- the types File_Mode in the individual packages are declared to
-- allow easy conversion to and from this general type.
type Shared_Status_Type is (Yes, No, None);
-- This type is used to define the sharing status of a file. The default
-- setting of None is used if no "shared=xxx" appears in the form string
-- when a file is created or opened. For a file with Shared_Status set to
-- None, Use_Error will be raised if any other file is opened or created
-- with the same full name. Yes/No are set in response to the presence
-- of "shared=yes" or "shared=no" in the form string. In either case it
-- is permissible to have multiple files opened with the same full name.
-- All files opened simultaneously with "shared=yes" will share the same
-- stream with the semantics specified in the RM for file sharing. All
-- files opened with "shared=no" will have their own stream.
type AFCB is tagged;
type AFCB_Ptr is access all AFCB'Class;
type AFCB is abstract new Ada.Streams.Root_Stream_Type with record
Stream : Interfaces.C_Streams.FILEs;
-- The file descriptor
Name : Pstring;
-- A pointer to the file name. The file name is null for temporary
-- files, and also for standard files (stdin, stdout, stderr). The
-- name is always NUL-terminated if it is non-null.
Encoding : System.CRTL.Filename_Encoding;
-- Encoding used to specified the filename
Form : Pstring;
-- A pointer to the form string. This is the string used in the
-- fopen call, and must be supplied by the caller (there are no
-- defaults at this level). The string is always null-terminated.
Mode : File_Mode;
-- The file mode. No checks are made that the mode is consistent
-- with the form used to fopen the file.
Is_Regular_File : Boolean;
-- A flag indicating if the file is a regular file
Is_Temporary_File : Boolean;
-- A flag set only for temporary files (i.e. files created using the
-- Create function with a null name parameter).
Is_System_File : Boolean;
-- A flag set only for system files (stdin, stdout, stderr)
Text_Encoding : Interfaces.C_Streams.Content_Encoding;
-- A flag set to describe file content encoding
Shared_Status : Shared_Status_Type;
-- Indicates sharing status of file, see description of type above
Access_Method : Character;
-- Set to 'Q', 'S', 'T', 'D' for Sequential_IO, Stream_IO, Text_IO,
-- Direct_IO file (used to validate file sharing request).
Next : AFCB_Ptr;
Prev : AFCB_Ptr;
-- All open files are kept on a doubly linked chain, with these
-- pointers used to maintain the next and previous pointers.
end record;
----------------------------------
-- Primitive Operations of AFCB --
----------------------------------
-- Note that we inherit the abstract operations Read and Write from
-- the base type. These must be overridden by the individual file
-- access methods to provide Stream Read/Write access.
function AFCB_Allocate (Control_Block : AFCB) return AFCB_Ptr is abstract;
-- Given a control block, allocate space for a control block of the same
-- type on the heap, and return the pointer to this allocated block. Note
-- that the argument Control_Block is not used other than as the argument
-- that controls which version of AFCB_Allocate is called.
procedure AFCB_Close (File : not null access AFCB) is abstract;
-- Performs any specialized close actions on a file before the file is
-- actually closed at the system level. This is called by Close, and
-- the reason we need the primitive operation is for the automatic
-- close operations done as part of finalization.
procedure AFCB_Free (File : not null access AFCB) is abstract;
-- Frees the AFCB referenced by the given parameter. It is not necessary
-- to free the strings referenced by the Form and Name fields, but if the
-- extension has any other heap objects, they must be freed as well. This
-- procedure must be overridden by each individual file package.
end System.File_Control_Block;
|
with
short_Math,
float_Math.Geometry,
long_Math,
ada.text_IO;
procedure launch_basic_math_Demo
--
-- A simple demonstration of the Math packages.
--
is
package Math renames float_Math;
use Math, math.Geometry;
procedure log (Message : in String) renames ada.text_IO.put_Line;
begin
declare
Value : Real := 0.0;
begin
log (Image (Value, 5));
Value := Value + 1.0;
log (Image (Value, 5));
end;
declare
use Vectors;
Value : Vector_3 := math.Origin_3d;
begin
log (Image (Value));
Value := Value + (1.0, 1.0, 1.0);
log (Image (Value));
end;
end launch_basic_math_Demo;
|
pragma License (Unrestricted);
with Ada.Numerics.Generic_Complex_Arrays;
with Ada.Numerics.Long_Long_Complex_Types;
with Ada.Numerics.Long_Long_Real_Arrays;
package Ada.Numerics.Long_Long_Complex_Arrays is
new Generic_Complex_Arrays (Long_Long_Real_Arrays, Long_Long_Complex_Types);
pragma Pure (Ada.Numerics.Long_Long_Complex_Arrays);
|
package body WeatherCommon is
procedure show_temp(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; temp : BBS.units.temp_c) is
servo_value : float := float((temp - temp_min)/(temp_max - temp_min));
error : integer;
begin
if (servo_value < 0.0)
then
servo_value := 0.0;
servo.set_full_on(temp_range_chan, error);
elsif (servo_value > 1.0) then
servo_value := 1.0;
servo.set_full_on(temp_range_chan, error);
else
servo.set_full_off(temp_range_chan, error);
end if;
servo_value := servo_value*2.0 - 1.0;
servo.set_servo(temp_chan, BBS.BBB.i2c.PCA9685.servo_range(servo_value), error);
end;
--
procedure show_press(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; press : BBS.units.press_p) is
servo_value : float := float((press - press_min)/(press_max - press_min));
error : integer;
begin
if (servo_value < 0.0)
then
servo_value := 0.0;
servo.set_full_on(press_range_chan, error);
elsif (servo_value > 1.0) then
servo_value := 1.0;
servo.set_full_on(press_range_chan, error);
else
servo.set_full_off(press_range_chan, error);
end if;
servo_value := servo_value*2.0 - 1.0;
servo.set_servo(press_chan, BBS.BBB.i2c.PCA9685.servo_range(servo_value), error);
end;
--
procedure show_hum(servo: BBS.BBB.i2c.PCA9685.PS9685_ptr; hum : float) is
servo_value : float := float((hum - hum_min)/(hum_max - hum_min));
error : integer;
begin
if (servo_value < 0.0)
then
servo_value := 0.0;
servo.set_full_on(hum_range_chan, error);
elsif (servo_value > 1.0) then
servo_value := 1.0;
servo.set_full_on(hum_range_chan, error);
else
servo.set_full_off(hum_range_chan, error);
end if;
servo_value := servo_value*2.0 - 1.0;
servo.set_servo(hum_chan, BBS.BBB.i2c.PCA9685.servo_range(servo_value), error);
end;
--
end;
|
with Goertzel;
with Ada.Text_Io;
procedure Main is
Flt : Goertzel.Filter;
Samples : Goertzel.Samples := ( 0.0, 1.0, 0.0, Goertzel.Value(-1.0) );
Y : Goertzel.Value;
begin
Flt := Goertzel.Make(2000.0, 8000.0);
Goertzel.Process(Flt, Samples, y);
Y := Goertzel.DBm(Y);
Ada.Text_IO.Put_Line(Y'Image);
end Main;
|
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Pointers;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with System;
with JNI_MD; -- use JNI_MD;
package JNI is
JNI_OK : constant := 0; -- Success.
JNI_ERR : constant := -1; -- Unknown error.
JNI_EDETACHED : constant := -2; -- Thread detached from the VM.
JNI_EVERSION : constant := -3; -- JNI version error.
JNI_ENOMEM : constant := -4; -- Not enough memory.
JNI_EEXIST : constant := -5; -- VM already created.
JNI_EINVAL : constant := -6; -- Invalid arguments.
JNI_COMMIT : constant := 1;
JNI_ABORT : constant := 2;
-- Basic Java types.
subtype jchar is char16_t;
subtype jbyte is JNI_MD.jbyte;
subtype jint is JNI_MD.jint;
subtype jshort is short;
subtype jlong is JNI_MD.jlong;
subtype jfloat is C_float;
subtype jdouble is double;
subtype jsize is jint;
type jboolean is (False, True) with
Convention => C;
type jboolean_Ptr_Arrays is array (jsize range <>) of aliased jboolean with
Convention => C;
package jboolean_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jboolean,
Element_Array => jboolean_Ptr_Arrays,
Default_Terminator => False);
use type jboolean_Array_Ptr.Pointer;
-- Array and pointer types for the primitive types.
-- jchar types.
type jchar_Ptr_Arrays is array (jsize range <>) of aliased jchar with
Convention => C;
package jchar_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jchar,
Element_Array => jchar_Ptr_Arrays,
Default_Terminator => jchar'Val (0));
use type jchar_Array_Ptr.Pointer;
-- jbyte types.
type jbyte_Ptr_Arrays is array (jsize range <>) of aliased jbyte with
Convention => C;
package jbyte_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jbyte,
Element_Array => jbyte_Ptr_Arrays,
Default_Terminator => 0);
use type jbyte_Array_Ptr.Pointer;
-- jshort types.
type jshort_Ptr_Arrays is array (jsize range <>) of aliased jshort with
Convention => C;
package jshort_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jshort,
Element_Array => jshort_Ptr_Arrays,
Default_Terminator => 0);
use type jshort_Array_Ptr.Pointer;
-- jint types.
type jint_Ptr_Arrays is array (jsize range <>) of aliased jint with
Convention => C;
package jint_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jint,
Element_Array => jint_Ptr_Arrays,
Default_Terminator => 0);
use type jint_Array_Ptr.Pointer;
-- jlong types.
type jlong_Ptr_Arrays is array (jsize range <>) of aliased jlong with
Convention => C;
package jlong_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jlong,
Element_Array => jlong_Ptr_Arrays,
Default_Terminator => 0);
use type jlong_Array_Ptr.Pointer;
-- jfloat types.
type jfloat_Ptr_Arrays is array (jsize range <>) of aliased jfloat with
Convention => C;
package jfloat_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jfloat,
Element_Array => jfloat_Ptr_Arrays,
Default_Terminator => 0.0);
use type jfloat_Array_Ptr.Pointer;
-- jdouble types.
type jdouble_Ptr_Arrays is array (jsize range <>) of aliased jdouble with
Convention => C;
package jdouble_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jdouble,
Element_Array => jdouble_Ptr_Arrays,
Default_Terminator => 0.0);
use type jdouble_Array_Ptr.Pointer;
-- jsize types.
type jsize_Ptr_Arrays is array (jsize range <>) of aliased jsize with
Convention => C;
package jsize_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jsize,
Element_Array => jsize_Ptr_Arrays,
Default_Terminator => -1);
use type jsize_Array_Ptr.Pointer;
-- Object types.
type jobject_Type is null record;
type jobject is access all jobject_Type with
Convention => C;
type jobject_Arrays is array (jsize range <>) of aliased jobject with
Convention => C;
package jobject_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jobject,
Element_Array => jobject_Arrays,
Default_Terminator => null);
use type jobject_Array_Ptr.Pointer;
-- Composite types derive from jobject.
subtype jclass is jobject;
subtype jthrowable is jobject;
subtype jstring is jobject;
-- jclass types.
type jclass_Arrays is array (jsize range <>) of aliased jclass with
Convention => C;
package jclass_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jclass,
Element_Array => jclass_Arrays,
Default_Terminator => null);
use type jclass_Array_Ptr.Pointer;
-- jthrowable types.
type jthrowable_Arrays is array (jsize range <>) of aliased jthrowable with
Convention => C;
package jthrowable_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jthrowable,
Element_Array => jthrowable_Arrays,
Default_Terminator => null);
use type jthrowable_Array_Ptr.Pointer;
-- jstring types.
type jstring_Arrays is array (jsize range <>) of aliased jstring with
Convention => C;
package jstring_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => jstring,
Element_Array => jstring_Arrays,
Default_Terminator => null);
use type jstring_Array_Ptr.Pointer;
subtype jarray is jobject;
subtype jbooleanArray is jarray;
subtype jbyteArray is jarray;
subtype jcharArray is jarray;
subtype jshortArray is jarray;
subtype jintArray is jarray;
subtype jlongArray is jarray;
subtype jfloatArray is jarray;
subtype jdoubleArray is jarray;
subtype jobjectArray is jarray;
subtype jweak is jobject;
type jvalue (discr : unsigned := 0) is record
case discr is
when 0 =>
z : aliased jboolean;
when 1 =>
b : aliased jbyte;
when 2 =>
c : aliased jchar;
when 3 =>
s : aliased jshort;
when 4 =>
i : aliased jint;
when 5 =>
j : aliased jlong;
when 6 =>
f : aliased jfloat;
when 7 =>
d : aliased jdouble;
when others =>
l : jobject;
end case;
end record with
Convention => C_Pass_By_Copy,
Unchecked_Union => True;
type Versions is new jint;
JNI_VERSION_1_1 : constant Versions := 16#0001_0001#;
JNI_VERSION_1_2 : constant Versions := 16#0001_0002#;
JNI_VERSION_1_4 : constant Versions := 16#0001_0004#;
JNI_VERSION_1_6 : constant Versions := 16#0001_0006#;
JNI_VERSION_1_8 : constant Versions := 16#0001_0008#;
JNI_VERSION_9 : constant Versions := 16#0009_0000#;
JNI_VERSION_10 : constant Versions := 16#000a_0000#;
-- Null_jvalue : constant jvalue := (discr => unsigned'Last, l => null);
-- type jvalue_Arrays is array (jsize range <>) of aliased jvalue with
-- Convention => C;
-- package jvalue_Array_Ptr is new Interfaces.C.Pointers
-- (Index => jsize,
-- Element => jvalue,
-- Element_Array => jvalue_Arrays,
-- Default_Terminator => Null_jvalue);
-- use type jvalue_Array_Ptr.Pointer;
type jfieldID_Type is null record;
type jfieldID is access all jfieldID_Type with
Convention => C;
type jmethodID_Type is null record;
type jmethodID is access all jmethodID_Type with
Convention => C;
type jobject_Ref_Type is
(Invalid_Ref_Type,
Local_Ref_Type,
Global_Ref_Type,
Weak_Global_Ref_Type) with
Convention => C;
type Native_Method is record
Name : chars_ptr;
Signature : chars_ptr;
Function_Ptr : System.Address;
end record with
Convention => C_Pass_By_Copy;
type Native_Method_Arrays is array (jint range <>) of aliased Native_Method with
Convention => C;
package Native_Method_Ptr is new Interfaces.C.Pointers
(Index => jint,
Element => Native_Method,
Element_Array => Native_Method_Arrays,
Default_Terminator => Native_Method'(Name | Signature => null, Function_Ptr => System.Null_Address));
use type Native_Method_Ptr.Pointer;
-- This this is all to cover C's pointer to point mess!
-- JavaVM = JNIInvokeInterface_!!
type Java_VMs;
type Java_VM_Ptr is access all Java_VMs with
Convention => C;
type Java_VM_Ptr_Ptr is access all Java_VM_Ptr with
Convention => C;
-- JNIEnv.
-- type Environment is null record with
-- Convention => C;
type Environment;
type Env_Ptr is access all Environment with
Convention => C;
type Env_Ptr_Ptr is access all Env_Ptr with
Convention => C;
type Environment is record
reserved_0 : System.Address;
reserved_1 : System.Address;
reserved_2 : System.Address;
reserved_3 : System.Address;
Get_Version : access function (Environment : in not null Env_Ptr_Ptr) return Versions;
Define_Class : access function
(Environment : in not null Env_Ptr_Ptr;
Name : in chars_ptr;
Loader : in jobject;
Bufffer : access jbyte;
Length : in jsize) return jclass;
Find_Class : access function
(Environment : in not null Env_Ptr_Ptr;
Name : in chars_ptr) return jclass;
From_Reflected_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Method : in not null jobject) return jmethodID;
From_Reflected_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Field : in not null jobject) return jfieldID;
To_Reflected_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : in not null jmethodID;
Is_Static : in jboolean) return jobject;
Get_Superclass : access function
(Environment : in not null Env_Ptr_Ptr;
Sub_Class : in not null jclass) return jclass;
Is_Assignable_From : access function
(Environment : in not null Env_Ptr_Ptr;
Class_1 : in not null jclass;
Class_2 : in not null jclass) return jboolean;
To_Reflected_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : in not null jfieldID;
Is_Static : in jboolean) return jobject;
Throw : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jthrowable) return jint;
Throw_New : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Message : in chars_ptr) return jint;
Exception_Occurred : access function (Environment : in not null Env_Ptr_Ptr) return jthrowable;
Exception_Describe : access procedure (Environment : in not null Env_Ptr_Ptr);
Exception_Clear : access procedure (Environment : in not null Env_Ptr_Ptr);
Fatal_Error : access procedure
(Environment : in not null Env_Ptr_Ptr;
Message : in chars_ptr);
Push_Local_Frame : access function
(Environment : in not null Env_Ptr_Ptr;
Capacity : in jint) return jint;
Pop_Local_Frame : access function
(Environment : in not null Env_Ptr_Ptr;
Result : in out jobject) return jobject;
New_Global_Ref : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in jobject) return jobject;
Delete_Global_Ref : access procedure
(Environment : in not null Env_Ptr_Ptr;
Global_Ref : in jobject);
Delete_Local_Ref : access procedure
(Environment : in not null Env_Ptr_Ptr;
Local_Ref : in jobject);
Is_Same_Object : access function
(Environment : in not null Env_Ptr_Ptr;
Ref_1 : in jobject;
Ref_2 : in jobject) return jboolean;
New_Local_Ref : access function
(Environment : in not null Env_Ptr_Ptr;
Ref : in jobject) return jobject;
Ensure_Local_Capacity : access function
(Environment : in not null Env_Ptr_Ptr;
Capacity : in jint) return jint; -- TODO: Change type?
Alloc_Object : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass) return jobject;
New_Object : access function
(Environment : in not null Env_Ptr_Ptr;
arg2 : jclass;
arg3 : jmethodID
) return jobject; -- TODO: DO NOT USE, IS varargs, will need a generic for this.
New_Object_V : access function
(Environment : in not null Env_Ptr_Ptr;
arg2 : jclass;
arg3 : jmethodID;
arg4 : access System.Address) return jobject; -- TODO: DO NOT USE, arg4 = va_list type.
New_Object_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
method_ID : in not null jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer) return jobject;
Get_Object_Class : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject) return jclass;
Is_Instance_Of : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in jobject;
Class : in not null jclass) return jboolean;
Get_Method_ID : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Name : in chars_ptr;
Signature : in chars_ptr) return jmethodID;
Call_Object_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jobject; -- TODO: varargs
Call_Object_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jobject; -- TODO: va_list.
Call_Object_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer) return jobject;
Call_Boolean_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jboolean; -- TODO: varargs
Call_Boolean_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jboolean; -- TODO: va_list.
Call_Boolean_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jboolean_Array_Ptr.Pointer) return jboolean;
Call_Byte_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jbyte; -- TODO: varargs
Call_Byte_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jbyte; -- TODO: va_list.
Call_Byte_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jbyte_Array_Ptr.Pointer) return jbyte;
Call_Char_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jchar; -- TODO: varargs
Call_Char_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jchar; -- TODO: va_list.
Call_Char_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jchar_Array_Ptr.Pointer) return jchar;
Call_Short_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jshort; -- TODO: varargs
Call_Short_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jshort; -- TODO: va_list.
Call_Short_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jshort_Array_Ptr.Pointer) return jshort;
Call_Int_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jint; -- TODO: varargs
Call_Int_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jint; -- TODO: va_list.
Call_Int_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jint_Array_Ptr.Pointer) return jint;
Call_Long_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jlong; -- TODO: varargs
Call_Long_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jlong; -- TODO: va_list.
Call_Long_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jlong_Array_Ptr.Pointer) return jlong;
Call_Float_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jfloat; -- TODO: varargs
Call_Float_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jfloat; -- TODO: va_list.
Call_Float_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jfloat_Array_Ptr.Pointer) return jfloat;
Call_Double_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
) return jdouble; -- TODO: varargs
Call_Double_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address) return jdouble; -- TODO: va_list.
Call_Double_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jdouble_Array_Ptr.Pointer) return jdouble;
Call_Void_Method : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID
); -- TODO: varargs
Call_Void_Method_V : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Args : access System.Address); -- TODO: va_list.
Call_Void_Method_A : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer);
Call_Non_Virtual_Object_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Method_ID : jmethodID;
arg4 : jmethodID
) return jobject; -- TODO: varargs
Call_Non_Virtual_Object_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jobject; -- TODO: va_list.
Call_Non_Virtual_Object_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer) return jobject;
Call_Non_Virtual_Boolean_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jboolean; -- TODO: varargs
Call_Non_Virtual_Boolean_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jboolean; -- TODO: va_list.
Call_Non_Virtual_Boolean_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jboolean_Array_Ptr.Pointer) return jboolean;
Call_Non_Virtual_Byte_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jbyte; -- TODO: varargs
Call_Non_Virtual_Byte_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jbyte; -- TODO: va_list.
Call_Non_Virtual_Byte_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jbyte_Array_Ptr.Pointer) return jbyte;
Call_Non_Virtual_Char_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jchar; -- TODO: varargs
Call_Non_Virtual_Char_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jchar; -- TODO: va_list.
Call_Non_Virtual_Char_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jchar_Array_Ptr.Pointer) return jchar;
Call_Non_Virtual_Short_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jshort; -- TODO: varargs
Call_Non_Virtual_Short_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jshort; -- TODO: va_list.
Call_Non_Virtual_Short_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jshort_Array_Ptr.Pointer) return jshort;
Call_Non_Virtual_Int_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jint; -- TODO: varargs
Call_Non_Virtual_Int_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jint; -- TODO: va_list.
Call_Non_Virtual_Int_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jint_Array_Ptr.Pointer) return jint;
Call_Non_Virtual_Long_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jlong; -- TODO: varargs
Call_Non_Virtual_Long_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jlong; -- TODO: va_list.
Call_Non_Virtual_Long_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jlong_Array_Ptr.Pointer) return jlong;
Call_Non_Virtual_Float_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jfloat; -- TODO: varargs
Call_Non_Virtual_Float_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jfloat; -- TODO: va_list.
Call_Non_Virtual_Float_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jfloat_Array_Ptr.Pointer) return jfloat;
Call_Non_Virtual_Double_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
) return jdouble; -- TODO: varargs
Call_Non_Virtual_Double_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address) return jdouble; -- TODO: va_list.
Call_Non_Virtual_Double_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jdouble_Array_Ptr.Pointer) return jdouble;
Call_Non_Virtual_Void_Method : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID
); -- TODO: varargs
Call_Non_Virtual_Void_Method_V : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
arg5 : access System.Address); -- TODO: va_list.
Call_Non_Virtual_Void_Method_A : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer);
Get_Field_ID : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Name : in chars_ptr;
Signature : in chars_ptr) return jfieldID;
Get_Object_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jobject;
Get_Boolean_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jboolean;
Get_Byte_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jbyte;
Get_Char_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jchar;
Get_Short_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jshort;
Get_Int_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jint;
Get_Long_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jlong;
Get_Float_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jfloat;
Get_Double_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID) return jdouble;
Set_Object_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jobject);
Set_Boolean_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jboolean);
Set_Byte_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jbyte);
Set_Char_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jchar);
Set_Short_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jshort);
Set_Int_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jint);
Set_Long_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jlong);
Set_Float_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jfloat);
Set_Double_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject;
Field_ID : jfieldID;
Value : jdouble);
Get_Static_Method_ID : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Name : in chars_ptr;
Signature : in chars_ptr) return jmethodID;
Call_Static_Object_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jobject;
Call_Static_Object_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jobject; -- TODO: va_list.
Call_Static_Object_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer) return jobject;
Call_Static_Boolean_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jboolean; -- TODO: varargs
Call_Static_Boolean_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jboolean; -- TODO: va_list.
Call_Static_Boolean_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jboolean_Array_Ptr.Pointer) return jboolean;
Call_Static_Byte_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jbyte; -- TODO: varargs
Call_Static_Byte_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jbyte; -- TODO: va_list.
Call_Static_Byte_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jbyte_Array_Ptr.Pointer) return jbyte;
Call_Static_Char_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jchar; -- TODO: varargs
CallStaticCharMethodV : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jchar;
Call_Static_Char_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jchar_Array_Ptr.Pointer) return jchar;
Call_Static_Short_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jshort; -- TODO: varargs
Call_Static_Short_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jshort; -- TODO: va_list.
Call_Static_Short_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jshort_Array_Ptr.Pointer) return jshort;
Call_Static_Int_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jint; -- TODO: varargs
Call_Static_Int_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jint; -- TODO: va_list.
Call_Static_Int_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jint_Array_Ptr.Pointer) return jint;
Call_Static_Long_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jlong; -- TODO: varargs
Call_Static_Long_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jlong; -- TODO: va_list.
Call_Static_Long_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jlong_Array_Ptr.Pointer) return jlong;
Call_Static_Float_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jfloat; -- TODO: varargs
Call_Static_Float_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jfloat; -- TODO: va_list.
Call_Static_Float_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jfloat_Array_Ptr.Pointer) return jfloat;
Call_Static_Double_Method : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
) return jdouble; -- TODO: varargs
Call_Static_Double_Method_V : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address) return jdouble; -- TODO: va_list.
Call_Static_Double_Method_A : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jdouble_Array_Ptr.Pointer) return jdouble;
Call_Static_Void_Method : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID
); -- TODO: varargs
Call_Static_Void_Method_V : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
arg4 : access System.Address); -- TODO: va_list.
Call_Static_Void_Method_A : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Method_ID : jmethodID;
Arg_Array : jobject_Array_Ptr.Pointer);
Get_Static_Field_ID : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Name : in chars_ptr;
Signature : in chars_ptr) return jfieldID;
Get_Static_Object_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jobject;
Get_Static_Boolean_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jboolean;
Get_Static_Byte_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jbyte;
Get_Static_Char_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jchar;
Get_Static_Short_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jshort;
Get_Static_Int_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jint;
Get_Static_Long_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jlong;
Get_Static_Float_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jfloat;
Get_Static_Double_Field : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID) return jdouble;
Set_Static_Object_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jobject);
Set_Static_Boolean_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jboolean);
Set_Static_Byte_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jbyte);
Set_Static_Char_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jchar);
Set_Static_Short_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jshort);
Set_Static_Int_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jint);
Set_Static_Long_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jlong);
Set_Static_Float_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jfloat);
Set_Static_Double_Field : access procedure
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass;
Field_ID : jfieldID;
Value : jdouble);
New_String : access function
(Environment : in not null Env_Ptr_Ptr;
Unicode_Characters : jchar_Array_Ptr.Pointer;
Length : jsize) return jstring; -- TODO: See below
-- Static_Predicate => Unicode_Characters = null and Length = 0;
Get_String_Length : access function
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring) return jsize;
Get_String_Chars : access function
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Is_Copy : access jboolean) return access jchar;
Release_String_Chars : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Chars : access jchar);
New_String_UTF : access function
(Environment : in not null Env_Ptr_Ptr;
Bytes : in chars_ptr) return jstring;
Get_String_UTF_Length : access function
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring) return jsize;
Get_String_UTF_Chars : access function
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Is_Copy : access jboolean) return chars_ptr;
Release_String_UTF_Chars : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
UTF : in chars_ptr);
Get_Array_Length : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jarray) return jsize;
New_Object_Array : access function
(Environment : in not null Env_Ptr;
Length : in jsize;
Element_Class : in not null jclass;
Initial_Element : in jobject) return jobjectArray; -- with
-- Pre => Length >= 0;
Get_Object_Array_Element : access function
(Environment : in not null Env_Ptr;
Object_Array : in not null jobjectArray;
Index : jsize) return jobject; -- with
-- Static_Predicate => Index >= 0;
Set_Object_Array_Element : access procedure
(Environment : in not null Env_Ptr;
Object_Array : in not null jobjectArray;
Index : jsize;
Value : in jobject); -- with
-- Static_Predicate => Index >= 0;
New_Boolean_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jbooleanArray; -- with
-- Static_Predicate => Length >= 0;
New_Byte_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jbyteArray; -- with
-- Static_Predicate => Length >= 0;
New_Char_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jcharArray; -- with
-- Static_Predicate => Length >= 0;
New_Short_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jshortArray; -- with
-- Static_Predicate => Length >= 0;
New_Int_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jintArray; -- with
-- Static_Predicate => Length >= 0;
New_Long_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jlongArray; -- with
-- Static_Predicate => Length >= 0;
New_Float_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jfloatArray; -- with
-- Static_Predicate => Length >= 0;
New_Double_Array : access function
(Environment : in not null Env_Ptr_Ptr;
Length : in jsize) return jdoubleArray; -- with
-- Static_Predicate => Length >= 0;
Get_Boolean_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbooleanArray;
Is_Copy : access jboolean) return access jboolean;
Get_Byte_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbyteArray;
Is_Copy : access jboolean) return access jbyte;
Get_Char_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jcharArray;
Is_Copy : access jboolean) return access jchar;
Get_Short_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jshortArray;
Is_Copy : access jboolean) return access jshort;
Get_Int_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jintArray;
Is_Copy : access jboolean) return access jint;
Get_Long_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jlongArray;
Is_Copy : access jboolean) return access jlong;
Get_Float_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jfloatArray;
Is_Copy : access jboolean) return access jfloat;
Get_Double_Array_Elements : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jdoubleArray;
Is_Copy : access jboolean) return access jdouble;
Release_Boolean_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbooleanArray;
Elements : access jboolean; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Byte_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbyteArray;
Elements : access jbyte; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Char_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jcharArray;
Elements : access jchar; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Short_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jshortArray;
Elements : access jshort; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Int_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jintArray;
Elements : access jint; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Long_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jlongArray;
Elements : access jlong; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Float_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jfloatArray;
Elements : access jfloat; -- TODO: Change to C.Pointer
Mode : in jint);
Release_Double_Array_Elements : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jdoubleArray;
Elements : access jdouble; -- TODO: Change to C.Pointer
Mode : in jint);
Get_Boolean_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbooleanArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jboolean);
Get_Byte_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbyteArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jbyte);
Get_Char_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jcharArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jchar);
Get_Short_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jshortArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jshort);
Get_Int_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jintArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jint);
Get_Long_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jlongArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jlong);
Get_Float_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jfloatArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jfloat);
Get_Double_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jdoubleArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jdouble);
Set_Boolean_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbooleanArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jboolean);
Set_Byte_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jbyteArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jbyte);
Set_Char_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jcharArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jchar);
Set_Short_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jshortArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jshort);
Set_Int_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jintArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jint);
Set_Long_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jlongArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jlong);
Set_Float_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jfloatArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jfloat);
Set_Double_Array_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jdoubleArray;
Start : in jsize;
Length : in jsize;
Buffer : not null access jdouble);
Register_Natives : access function
(Environment : in not null Env_Ptr;
Class : in not null jclass;
Methods : not null access Native_Method_Ptr.Pointer;
Total_Methods : jint) return jint;
Unregister_Natives : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass) return jint;
Monitor_Enter : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject) return jint;
Monitor_Exit : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in not null jobject) return jint;
-- Note that the VM parameter is "JavaVM **vm" in C.
Get_Java_VM : access function
(Environment : in not null Env_Ptr_Ptr;
VM : out Java_VM_Ptr) return jint;
Get_String_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Start : in jsize;
Length : in jsize;
Buffer : access jchar);
Get_String_UTF_Region : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Start : in jsize;
Length : in jsize;
Buffer : in chars_ptr);
Get_Primitive_Array_Critical : access function
(Environment : in not null Env_Ptr_Ptr;
Java_Array : in not null jarray;
Is_Copy : access jboolean) return System.Address; -- TODO: C.Pointers
Release_Primitive_Array_Critical : access procedure
(Environment : in not null Env_Ptr;
Java_Array : in not null jarray;
Critical_Array : in System.Address;
Mode : in jint);
Get_String_Critical : access function
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Is_Copy : access jboolean) return access jchar;
Release_String_Critical : access procedure
(Environment : in not null Env_Ptr_Ptr;
Java_String : in not null jstring;
Is_Copy : access jchar);
New_Weak_Global_Ref : access function
(Environment : in not null Env_Ptr_Ptr;
Object : in jobject) return jweak;
Delete_Weak_Global_Ref : access procedure
(Environment : in not null Env_Ptr_Ptr;
Object : in jweak);
Exception_Check : access function (Environment : in not null Env_Ptr_Ptr) return jboolean;
New_Direct_Byte_Buffer : access function
(Environment : in not null Env_Ptr_Ptr;
Address : in System.Address;
Capacity : in jlong) return jobject;
Get_Direct_Buffer_Address : access function
(Environment : in not null Env_Ptr_Ptr;
Buffer : in not null jobject) return System.Address;
Get_Direct_Buffer_Capacity : access function
(Environment : in not null Env_Ptr_Ptr;
Buffer : in not null jobject) return jlong;
Get_Object_Ref_Type : access function
(Environment : in not null Env_Ptr_Ptr;
Object : jobject) return jobject_Ref_Type;
Get_Module : access function
(Environment : in not null Env_Ptr_Ptr;
Class : in not null jclass) return jobject;
end record with
Convention => C_Pass_By_Copy;
type VM_Options is record
Option_String : chars_ptr;
Extra_Info : System.Address;
end record with
Convention => C_Pass_By_Copy;
type VM_Option_Arrays is array (jsize range <>) of aliased VM_Options with
Convention => C;
package VM_Option_Array_Ptr is new Interfaces.C.Pointers
(Index => jsize,
Element => VM_Options,
Element_Array => VM_Option_Arrays,
Default_Terminator => VM_Options'(null, System.Null_Address));
use type VM_Option_Array_Ptr.Pointer;
type VM_Init_Args is record
Version : Versions;
Total_Options : jint;
Options : VM_Option_Array_Ptr.Pointer;
Ignore_Unrecognised : jboolean;
end record with
Convention => C_Pass_By_Copy;
type VM_Init_Args_Ptr is access all VM_Init_Args with
Convention => C;
type VM_Attach_Args is record
Version : jint;
Name : chars_ptr;
Group : jobject;
end record with
Convention => C_Pass_By_Copy;
-- Invoke_Interface = Java_VMs.
type Java_VMs is record
reserved_0 : System.Address;
reserved_1 : System.Address;
reserved_2 : System.Address;
Destroy_Java_VM : access function (VM : in Java_VM_Ptr_Ptr) return jint;
Attach_Current_Thread : access function
(VM : in Java_VM_Ptr;
Env : System.Address;
Args : System.Address) return jint;
Detach_Current_Thread : access function (VM : in Java_VM_Ptr) return jint;
Get_Env : access function
(VM : in Java_VM_Ptr_Ptr;
Env : System.Address;
Version : in jint) return jint;
Attach_Current_Thread_As_Daemon : access function
(VM : in Java_VM_Ptr_Ptr;
Env : System.Address;
Args : System.Address) return jint;
end record with
Convention => C_Pass_By_Copy;
function Get_Default_Java_VM_Init_Args (Args : System.Address) return jint with
Convention => C,
Import => True,
External_Name => "JNI_GetDefaultJavaVMInitArgs";
function Create_Java_VM
(VM : out Java_VM_Ptr_Ptr;
Env : out Env_Ptr_Ptr;
Args : in VM_Init_Args_Ptr) return jint with
Convention => C,
Import => True,
External_Name => "JNI_CreateJavaVM";
-- function JNI_GetCreatedJavaVMs
-- (VM : access Native_Interface;
-- Size : jsize;
-- Size_2 : jsize) return jint with
-- Convention => C,
-- Import => True,
-- External_Name => "JNI_GetCreatedJavaVMs";
function On_Load
(VM : in Java_VM_Ptr;
Reserved : System.Address) return jint with
Convention => C,
Import => True,
External_Name => "JNI_OnLoad";
function On_Unload
(VM : in Java_VM_Ptr;
Reserved : System.Address) return jint with
Convention => C,
Import => True,
External_Name => "JNI_OnUnload";
procedure Test;
end JNI;
|
--
-- This package provides resources to handle dynamic "plugins"
--
-- A plugin is an "object" that can be called dynamically at run-time to
-- handle, for example, files with different format. A plugin will
-- typically be a descendant of an abstract type that specifies the
-- minimal interface the plugin must export. For example, a program
-- that needs to load images that can be in many different formats,
-- it can define an "abstract image reader" with something like
--
-- type Abstract_Image_Reader is interface;
--
-- function Read_Image (Filename : String) return Image
-- is abstract;
--
-- Successively, one can define plugins to read JPEG, GIF, PNG, ...
-- as descendants of Abstract_Image_Reader.
--
-- Every plugin is identified by a Plugin_ID. The actual form of
-- the Plugin_ID depends on the implementation, therefore its definition
-- is used as a parameter of this package. In the case of the image readers,
-- the ID could be a string with the format name.
--
-- Note that while an ID uniquely identifies a plugin, a plugin can
-- be identified by more than an ID. For example, the plugin to read
-- JPEG images could be identified by both IDs "jpg" and "jpeg" (supposing
-- the IDs case insensitive)
with Ada.Tags;
generic
type Root_Plugin_Type (<>) is abstract tagged private;
-- The ancestor of all plugins, the one who specify the minimum
-- plugin interface.
type Plugin_Parameters (<>) is limited private;
-- A type used to pass parameters to the plugin that is going to
-- be built. In the "parent" of this package there are few types
-- that cover the most common cases.
type Plugin_ID (<>) is private;
-- The ID used to identify plugins.
with function "<" (L, R : Plugin_ID) return Boolean is <>;
-- An ID ordering function
with function Constructor (Params : not null access Plugin_Parameters)
return Root_Plugin_Type is abstract;
-- A "builder" for the abstract plugin. The programmer who writes
-- a new plugin must define this function for the new plugin.
package Plugins.Tables is
procedure Register (ID : Plugin_ID;
Tag : Ada.Tags.Tag)
with Pre =>
Ada.Tags.Is_Descendant_At_Same_Level (Descendant => Tag,
Ancestor => Root_Plugin_Type'Tag);
-- Register a new plugin in the table by giving its ID and the Tag of the
-- corresponding type. By calling this procedure more than once, one
-- can register many IDs for the same plugin.
function Exists (ID : Plugin_ID;
Search_If_Missing : Boolean := False)
return Boolean;
-- Return true if a plugin with the specified ID exists. If
-- Search_If_Missing is True, try to search for the plugin with the finder
-- before returning false.
function Get (ID : Plugin_ID;
Params : not null access Plugin_Parameters;
Search_If_Missing : Boolean := False)
return Root_Plugin_Type'Class;
-- Get a plugin with the specified ID. Raise Unknown_Plugin_ID if the
-- ID does not exist. If Search_If_Missing is True, try to search
-- for the plugin with the finder before raising the exception
Unknown_Plugin_ID : exception;
procedure For_All_Plugins
(Callback : not null access procedure (ID : Plugin_ID));
-- Call the Callback with every known plugin ID. Note that in this
-- case the plugin finder is not used.
type Abstract_Finder is interface;
-- A "finder" is an object used to search for plugins (e.g., on disk,
-- in Internet, ...). The user can register new finders with the
-- table.
procedure Search_Plugin
(Finder : in out Abstract_Finder;
ID : in Plugin_ID;
Success : out Boolean)
is abstract;
-- Search for a plugin with the given ID and set Success = True
-- if found
type Finder_Access is access all Abstract_Finder'Class;
type Finder_ID is private;
-- Every time a new finder is registered, the package assigns to
-- it an ID that can be used to remove the finder
No_Finder : constant Finder_ID;
function Add_Finder (Finder : Finder_Access) return Finder_ID;
-- Add a new finder to the table and return an ID that can be
-- used to remove it
procedure Remove_Finder (ID : Finder_ID);
-- Remove the specified finder
private
type Finder_ID is new Natural;
No_Finder : constant Finder_ID := Finder_ID'First;
end Plugins.Tables;
|
package SPARKNaCl.Tests
is
-- Additional stress test cases for NaCl operations.
-- This is a child package of SPARKNaCl so these bodies
-- can see the private part and operations of SPARKNaCl.
procedure GF_Stress;
procedure Car_Stress;
procedure Diff_Car_Stress;
procedure Pack_Stress;
end SPARKNaCl.Tests;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Opt;
with Osint; use Osint;
with Output; use Output;
with Prj.Attr;
with Prj.Com;
with Prj.Err; use Prj.Err;
with Snames; use Snames;
with Uintp; use Uintp;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Containers.Ordered_Sets;
with Ada.Unchecked_Deallocation;
with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.HTable;
package body Prj is
type Restricted_Lang;
type Restricted_Lang_Access is access Restricted_Lang;
type Restricted_Lang is record
Name : Name_Id;
Next : Restricted_Lang_Access;
end record;
Restricted_Languages : Restricted_Lang_Access := null;
-- When null, all languages are allowed, otherwise only the languages in
-- the list are allowed.
Object_Suffix : constant String := Get_Target_Object_Suffix.all;
-- File suffix for object files
Initial_Buffer_Size : constant := 100;
-- Initial size for extensible buffer used in Add_To_Buffer
The_Empty_String : Name_Id := No_Name;
The_Dot_String : Name_Id := No_Name;
Debug_Level : Integer := 0;
-- Current indentation level for debug traces
type Cst_String_Access is access constant String;
All_Lower_Case_Image : aliased constant String := "lowercase";
All_Upper_Case_Image : aliased constant String := "UPPERCASE";
Mixed_Case_Image : aliased constant String := "MixedCase";
The_Casing_Images : constant array (Known_Casing) of Cst_String_Access :=
(All_Lower_Case => All_Lower_Case_Image'Access,
All_Upper_Case => All_Upper_Case_Image'Access,
Mixed_Case => Mixed_Case_Image'Access);
package Name_Id_Set is
new Ada.Containers.Ordered_Sets (Element_Type => Name_Id);
procedure Free (Project : in out Project_Id);
-- Free memory allocated for Project
procedure Free_List (Languages : in out Language_Ptr);
procedure Free_List (Source : in out Source_Id);
procedure Free_List (Languages : in out Language_List);
-- Free memory allocated for the list of languages or sources
procedure Reset_Units_In_Table (Table : in out Units_Htable.Instance);
-- Resets all Units to No_Unit_Index Unit.File_Names (Spec).Unit &
-- Unit.File_Names (Impl).Unit in the given table.
procedure Free_Units (Table : in out Units_Htable.Instance);
-- Free memory allocated for unit information in the project
procedure Language_Changed (Iter : in out Source_Iterator);
procedure Project_Changed (Iter : in out Source_Iterator);
-- Called when a new project or language was selected for this iterator
function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean;
-- Return True if there is at least one ALI file in the directory Dir
-----------------------------
-- Add_Restricted_Language --
-----------------------------
procedure Add_Restricted_Language (Name : String) is
N : String (1 .. Name'Length) := Name;
begin
To_Lower (N);
Name_Len := 0;
Add_Str_To_Name_Buffer (N);
Restricted_Languages :=
new Restricted_Lang'(Name => Name_Find, Next => Restricted_Languages);
end Add_Restricted_Language;
-------------------------------------
-- Remove_All_Restricted_Languages --
-------------------------------------
procedure Remove_All_Restricted_Languages is
begin
Restricted_Languages := null;
end Remove_All_Restricted_Languages;
-------------------
-- Add_To_Buffer --
-------------------
procedure Add_To_Buffer
(S : String;
To : in out String_Access;
Last : in out Natural)
is
begin
if To = null then
To := new String (1 .. Initial_Buffer_Size);
Last := 0;
end if;
-- If Buffer is too small, double its size
while Last + S'Length > To'Last loop
declare
New_Buffer : constant String_Access :=
new String (1 .. 2 * To'Length);
begin
New_Buffer (1 .. Last) := To (1 .. Last);
Free (To);
To := New_Buffer;
end;
end loop;
To (Last + 1 .. Last + S'Length) := S;
Last := Last + S'Length;
end Add_To_Buffer;
---------------------------------
-- Current_Object_Path_File_Of --
---------------------------------
function Current_Object_Path_File_Of
(Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type
is
begin
return Shared.Private_Part.Current_Object_Path_File;
end Current_Object_Path_File_Of;
---------------------------------
-- Current_Source_Path_File_Of --
---------------------------------
function Current_Source_Path_File_Of
(Shared : Shared_Project_Tree_Data_Access)
return Path_Name_Type is
begin
return Shared.Private_Part.Current_Source_Path_File;
end Current_Source_Path_File_Of;
---------------------------
-- Delete_Temporary_File --
---------------------------
procedure Delete_Temporary_File
(Shared : Shared_Project_Tree_Data_Access := null;
Path : Path_Name_Type)
is
Dont_Care : Boolean;
pragma Warnings (Off, Dont_Care);
begin
if not Opt.Keep_Temporary_Files then
if Current_Verbosity = High then
Write_Line ("Removing temp file: " & Get_Name_String (Path));
end if;
Delete_File (Get_Name_String (Path), Dont_Care);
if Shared /= null then
for Index in
1 .. Temp_Files_Table.Last (Shared.Private_Part.Temp_Files)
loop
if Shared.Private_Part.Temp_Files.Table (Index) = Path then
Shared.Private_Part.Temp_Files.Table (Index) := No_Path;
end if;
end loop;
end if;
end if;
end Delete_Temporary_File;
------------------------------
-- Delete_Temp_Config_Files --
------------------------------
procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref) is
Success : Boolean;
pragma Warnings (Off, Success);
Proj : Project_List;
begin
if not Opt.Keep_Temporary_Files then
if Project_Tree /= null then
Proj := Project_Tree.Projects;
while Proj /= null loop
if Proj.Project.Config_File_Temp then
Delete_Temporary_File
(Project_Tree.Shared, Proj.Project.Config_File_Name);
-- Make sure that we don't have a config file for this
-- project, in case there are several mains. In this case,
-- we will recreate another config file: we cannot reuse the
-- one that we just deleted.
Proj.Project.Config_Checked := False;
Proj.Project.Config_File_Name := No_Path;
Proj.Project.Config_File_Temp := False;
end if;
Proj := Proj.Next;
end loop;
end if;
end if;
end Delete_Temp_Config_Files;
---------------------------
-- Delete_All_Temp_Files --
---------------------------
procedure Delete_All_Temp_Files
(Shared : Shared_Project_Tree_Data_Access)
is
Dont_Care : Boolean;
pragma Warnings (Off, Dont_Care);
Path : Path_Name_Type;
begin
if not Opt.Keep_Temporary_Files then
for Index in
1 .. Temp_Files_Table.Last (Shared.Private_Part.Temp_Files)
loop
Path := Shared.Private_Part.Temp_Files.Table (Index);
if Path /= No_Path then
if Current_Verbosity = High then
Write_Line ("Removing temp file: "
& Get_Name_String (Path));
end if;
Delete_File (Get_Name_String (Path), Dont_Care);
end if;
end loop;
Temp_Files_Table.Free (Shared.Private_Part.Temp_Files);
Temp_Files_Table.Init (Shared.Private_Part.Temp_Files);
end if;
-- If any of the environment variables ADA_PRJ_INCLUDE_FILE or
-- ADA_PRJ_OBJECTS_FILE has been set, then reset their value to
-- the empty string.
if Shared.Private_Part.Current_Source_Path_File /= No_Path then
Setenv (Project_Include_Path_File, "");
end if;
if Shared.Private_Part.Current_Object_Path_File /= No_Path then
Setenv (Project_Objects_Path_File, "");
end if;
end Delete_All_Temp_Files;
---------------------
-- Dependency_Name --
---------------------
function Dependency_Name
(Source_File_Name : File_Name_Type;
Dependency : Dependency_File_Kind) return File_Name_Type
is
begin
case Dependency is
when None =>
return No_File;
when Makefile =>
return Extend_Name (Source_File_Name, Makefile_Dependency_Suffix);
when ALI_Closure
| ALI_File
=>
return Extend_Name (Source_File_Name, ALI_Dependency_Suffix);
end case;
end Dependency_Name;
----------------
-- Dot_String --
----------------
function Dot_String return Name_Id is
begin
return The_Dot_String;
end Dot_String;
----------------
-- Empty_File --
----------------
function Empty_File return File_Name_Type is
begin
return File_Name_Type (The_Empty_String);
end Empty_File;
-------------------
-- Empty_Project --
-------------------
function Empty_Project
(Qualifier : Project_Qualifier) return Project_Data
is
begin
Prj.Initialize (Tree => No_Project_Tree);
declare
Data : Project_Data (Qualifier => Qualifier);
begin
-- Only the fields for which no default value could be provided in
-- prj.ads are initialized below.
Data.Config := Default_Project_Config;
return Data;
end;
end Empty_Project;
------------------
-- Empty_String --
------------------
function Empty_String return Name_Id is
begin
return The_Empty_String;
end Empty_String;
------------
-- Expect --
------------
procedure Expect (The_Token : Token_Type; Token_Image : String) is
begin
if Token /= The_Token then
-- ??? Should pass user flags here instead
Error_Msg (Gnatmake_Flags, Token_Image & " expected", Token_Ptr);
end if;
end Expect;
-----------------
-- Extend_Name --
-----------------
function Extend_Name
(File : File_Name_Type;
With_Suffix : String) return File_Name_Type
is
Last : Positive;
begin
Get_Name_String (File);
Last := Name_Len + 1;
while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop
Name_Len := Name_Len - 1;
end loop;
if Name_Len <= 1 then
Name_Len := Last;
end if;
for J in With_Suffix'Range loop
Name_Buffer (Name_Len) := With_Suffix (J);
Name_Len := Name_Len + 1;
end loop;
Name_Len := Name_Len - 1;
return Name_Find;
end Extend_Name;
-------------------------
-- Is_Allowed_Language --
-------------------------
function Is_Allowed_Language (Name : Name_Id) return Boolean is
R : Restricted_Lang_Access := Restricted_Languages;
Lang : constant String := Get_Name_String (Name);
begin
if R = null then
return True;
else
while R /= null loop
if Get_Name_String (R.Name) = Lang then
return True;
end if;
R := R.Next;
end loop;
return False;
end if;
end Is_Allowed_Language;
---------------------
-- Project_Changed --
---------------------
procedure Project_Changed (Iter : in out Source_Iterator) is
begin
if Iter.Project /= null then
Iter.Language := Iter.Project.Project.Languages;
Language_Changed (Iter);
end if;
end Project_Changed;
----------------------
-- Language_Changed --
----------------------
procedure Language_Changed (Iter : in out Source_Iterator) is
begin
Iter.Current := No_Source;
if Iter.Language_Name /= No_Name then
while Iter.Language /= null
and then Iter.Language.Name /= Iter.Language_Name
loop
Iter.Language := Iter.Language.Next;
end loop;
end if;
-- If there is no matching language in this project, move to next
if Iter.Language = No_Language_Index then
if Iter.All_Projects then
loop
Iter.Project := Iter.Project.Next;
exit when Iter.Project = null
or else Iter.Encapsulated_Libs
or else not Iter.Project.From_Encapsulated_Lib;
end loop;
Project_Changed (Iter);
else
Iter.Project := null;
end if;
else
Iter.Current := Iter.Language.First_Source;
if Iter.Current = No_Source then
Iter.Language := Iter.Language.Next;
Language_Changed (Iter);
elsif not Iter.Locally_Removed
and then Iter.Current.Locally_Removed
then
Next (Iter);
end if;
end if;
end Language_Changed;
---------------------
-- For_Each_Source --
---------------------
function For_Each_Source
(In_Tree : Project_Tree_Ref;
Project : Project_Id := No_Project;
Language : Name_Id := No_Name;
Encapsulated_Libs : Boolean := True;
Locally_Removed : Boolean := True) return Source_Iterator
is
Iter : Source_Iterator;
begin
Iter := Source_Iterator'
(In_Tree => In_Tree,
Project => In_Tree.Projects,
All_Projects => Project = No_Project,
Language_Name => Language,
Language => No_Language_Index,
Current => No_Source,
Encapsulated_Libs => Encapsulated_Libs,
Locally_Removed => Locally_Removed);
if Project /= null then
while Iter.Project /= null
and then Iter.Project.Project /= Project
loop
Iter.Project := Iter.Project.Next;
end loop;
else
while not Iter.Encapsulated_Libs
and then Iter.Project.From_Encapsulated_Lib
loop
Iter.Project := Iter.Project.Next;
end loop;
end if;
Project_Changed (Iter);
return Iter;
end For_Each_Source;
-------------
-- Element --
-------------
function Element (Iter : Source_Iterator) return Source_Id is
begin
return Iter.Current;
end Element;
----------
-- Next --
----------
procedure Next (Iter : in out Source_Iterator) is
begin
loop
Iter.Current := Iter.Current.Next_In_Lang;
exit when Iter.Locally_Removed
or else Iter.Current = No_Source
or else not Iter.Current.Locally_Removed;
end loop;
if Iter.Current = No_Source then
Iter.Language := Iter.Language.Next;
Language_Changed (Iter);
end if;
end Next;
--------------------------------
-- For_Every_Project_Imported --
--------------------------------
procedure For_Every_Project_Imported_Context
(By : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out State;
Include_Aggregated : Boolean := True;
Imported_First : Boolean := False)
is
use Project_Boolean_Htable;
procedure Recursive_Check_Context
(Project : Project_Id;
Tree : Project_Tree_Ref;
In_Aggregate_Lib : Boolean;
From_Encapsulated_Lib : Boolean);
-- Recursively handle the project tree creating a new context for
-- keeping track about already handled projects.
-----------------------------
-- Recursive_Check_Context --
-----------------------------
procedure Recursive_Check_Context
(Project : Project_Id;
Tree : Project_Tree_Ref;
In_Aggregate_Lib : Boolean;
From_Encapsulated_Lib : Boolean)
is
package Name_Id_Set is
new Ada.Containers.Ordered_Sets (Element_Type => Path_Name_Type);
Seen_Name : Name_Id_Set.Set;
-- This set is needed to ensure that we do not handle the same
-- project twice in the context of aggregate libraries.
-- Since duplicate project names are possible in the context of
-- aggregated projects, we need to check the full paths.
procedure Recursive_Check
(Project : Project_Id;
Tree : Project_Tree_Ref;
In_Aggregate_Lib : Boolean;
From_Encapsulated_Lib : Boolean);
-- Check if project has already been seen. If not, mark it as Seen,
-- Call Action, and check all its imported and aggregated projects.
---------------------
-- Recursive_Check --
---------------------
procedure Recursive_Check
(Project : Project_Id;
Tree : Project_Tree_Ref;
In_Aggregate_Lib : Boolean;
From_Encapsulated_Lib : Boolean)
is
function Has_Sources (P : Project_Id) return Boolean;
-- Returns True if P has sources
function Get_From_Tree (P : Project_Id) return Project_Id;
-- Get project P from Tree. If P has no sources get another
-- instance of this project with sources. If P has sources,
-- returns it.
-----------------
-- Has_Sources --
-----------------
function Has_Sources (P : Project_Id) return Boolean is
Lang : Language_Ptr;
begin
Lang := P.Languages;
while Lang /= No_Language_Index loop
if Lang.First_Source /= No_Source then
return True;
end if;
Lang := Lang.Next;
end loop;
return False;
end Has_Sources;
-------------------
-- Get_From_Tree --
-------------------
function Get_From_Tree (P : Project_Id) return Project_Id is
List : Project_List := Tree.Projects;
begin
if not Has_Sources (P) then
while List /= null loop
if List.Project.Name = P.Name
and then Has_Sources (List.Project)
then
return List.Project;
end if;
List := List.Next;
end loop;
end if;
return P;
end Get_From_Tree;
-- Local variables
List : Project_List;
-- Start of processing for Recursive_Check
begin
if not Seen_Name.Contains (Project.Path.Name) then
-- Even if a project is aggregated multiple times in an
-- aggregated library, we will only return it once.
Seen_Name.Include (Project.Path.Name);
if not Imported_First then
Action
(Get_From_Tree (Project),
Tree,
Project_Context'(In_Aggregate_Lib, From_Encapsulated_Lib),
With_State);
end if;
-- Visit all extended projects
if Project.Extends /= No_Project then
Recursive_Check
(Project.Extends, Tree,
In_Aggregate_Lib, From_Encapsulated_Lib);
end if;
-- Visit all imported projects
List := Project.Imported_Projects;
while List /= null loop
Recursive_Check
(List.Project, Tree,
In_Aggregate_Lib,
From_Encapsulated_Lib
or else Project.Standalone_Library = Encapsulated);
List := List.Next;
end loop;
-- Visit all aggregated projects
if Include_Aggregated
and then Project.Qualifier in Aggregate_Project
then
declare
Agg : Aggregated_Project_List;
begin
Agg := Project.Aggregated_Projects;
while Agg /= null loop
pragma Assert (Agg.Project /= No_Project);
-- For aggregated libraries, the tree must be the one
-- of the aggregate library.
if Project.Qualifier = Aggregate_Library then
Recursive_Check
(Agg.Project, Tree,
True,
From_Encapsulated_Lib
or else
Project.Standalone_Library = Encapsulated);
else
-- Use a new context as we want to returns the same
-- project in different project tree for aggregated
-- projects.
Recursive_Check_Context
(Agg.Project, Agg.Tree, False, False);
end if;
Agg := Agg.Next;
end loop;
end;
end if;
if Imported_First then
Action
(Get_From_Tree (Project),
Tree,
Project_Context'(In_Aggregate_Lib, From_Encapsulated_Lib),
With_State);
end if;
end if;
end Recursive_Check;
-- Start of processing for Recursive_Check_Context
begin
Recursive_Check
(Project, Tree, In_Aggregate_Lib, From_Encapsulated_Lib);
end Recursive_Check_Context;
-- Start of processing for For_Every_Project_Imported
begin
Recursive_Check_Context
(Project => By,
Tree => Tree,
In_Aggregate_Lib => False,
From_Encapsulated_Lib => False);
end For_Every_Project_Imported_Context;
procedure For_Every_Project_Imported
(By : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out State;
Include_Aggregated : Boolean := True;
Imported_First : Boolean := False)
is
procedure Internal
(Project : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context;
With_State : in out State);
-- Action wrapper for handling the context
--------------
-- Internal --
--------------
procedure Internal
(Project : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context;
With_State : in out State)
is
pragma Unreferenced (Context);
begin
Action (Project, Tree, With_State);
end Internal;
procedure For_Projects is
new For_Every_Project_Imported_Context (State, Internal);
begin
For_Projects (By, Tree, With_State, Include_Aggregated, Imported_First);
end For_Every_Project_Imported;
-----------------
-- Find_Source --
-----------------
function Find_Source
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
In_Imported_Only : Boolean := False;
In_Extended_Only : Boolean := False;
Base_Name : File_Name_Type;
Index : Int := 0) return Source_Id
is
Result : Source_Id := No_Source;
procedure Look_For_Sources
(Proj : Project_Id;
Tree : Project_Tree_Ref;
Src : in out Source_Id);
-- Look for Base_Name in the sources of Proj
----------------------
-- Look_For_Sources --
----------------------
procedure Look_For_Sources
(Proj : Project_Id;
Tree : Project_Tree_Ref;
Src : in out Source_Id)
is
Iterator : Source_Iterator;
begin
Iterator := For_Each_Source (In_Tree => Tree, Project => Proj);
while Element (Iterator) /= No_Source loop
if Element (Iterator).File = Base_Name
and then (Index = 0 or else Element (Iterator).Index = Index)
then
Src := Element (Iterator);
-- If the source has been excluded, continue looking. We will
-- get the excluded source only if there is no other source
-- with the same base name that is not locally removed.
if not Element (Iterator).Locally_Removed then
return;
end if;
end if;
Next (Iterator);
end loop;
end Look_For_Sources;
procedure For_Imported_Projects is new For_Every_Project_Imported
(State => Source_Id, Action => Look_For_Sources);
Proj : Project_Id;
-- Start of processing for Find_Source
begin
if In_Extended_Only then
Proj := Project;
while Proj /= No_Project loop
Look_For_Sources (Proj, In_Tree, Result);
exit when Result /= No_Source;
Proj := Proj.Extends;
end loop;
elsif In_Imported_Only then
Look_For_Sources (Project, In_Tree, Result);
if Result = No_Source then
For_Imported_Projects
(By => Project,
Tree => In_Tree,
Include_Aggregated => False,
With_State => Result);
end if;
else
Look_For_Sources (No_Project, In_Tree, Result);
end if;
return Result;
end Find_Source;
----------------------
-- Find_All_Sources --
----------------------
function Find_All_Sources
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
In_Imported_Only : Boolean := False;
In_Extended_Only : Boolean := False;
Base_Name : File_Name_Type;
Index : Int := 0) return Source_Ids
is
Result : Source_Ids (1 .. 1_000);
Last : Natural := 0;
type Empty_State is null record;
No_State : Empty_State;
-- This is needed for the State parameter of procedure Look_For_Sources
-- below, because of the instantiation For_Imported_Projects of generic
-- procedure For_Every_Project_Imported. As procedure Look_For_Sources
-- does not modify parameter State, there is no need to give its type
-- more than one value.
procedure Look_For_Sources
(Proj : Project_Id;
Tree : Project_Tree_Ref;
State : in out Empty_State);
-- Look for Base_Name in the sources of Proj
----------------------
-- Look_For_Sources --
----------------------
procedure Look_For_Sources
(Proj : Project_Id;
Tree : Project_Tree_Ref;
State : in out Empty_State)
is
Iterator : Source_Iterator;
Src : Source_Id;
begin
State := No_State;
Iterator := For_Each_Source (In_Tree => Tree, Project => Proj);
while Element (Iterator) /= No_Source loop
if Element (Iterator).File = Base_Name
and then (Index = 0
or else
(Element (Iterator).Unit /= No_Unit_Index
and then
Element (Iterator).Index = Index))
then
Src := Element (Iterator);
-- If the source has been excluded, continue looking. We will
-- get the excluded source only if there is no other source
-- with the same base name that is not locally removed.
if not Element (Iterator).Locally_Removed then
Last := Last + 1;
Result (Last) := Src;
end if;
end if;
Next (Iterator);
end loop;
end Look_For_Sources;
procedure For_Imported_Projects is new For_Every_Project_Imported
(State => Empty_State, Action => Look_For_Sources);
Proj : Project_Id;
-- Start of processing for Find_All_Sources
begin
if In_Extended_Only then
Proj := Project;
while Proj /= No_Project loop
Look_For_Sources (Proj, In_Tree, No_State);
exit when Last > 0;
Proj := Proj.Extends;
end loop;
elsif In_Imported_Only then
Look_For_Sources (Project, In_Tree, No_State);
if Last = 0 then
For_Imported_Projects
(By => Project,
Tree => In_Tree,
Include_Aggregated => False,
With_State => No_State);
end if;
else
Look_For_Sources (No_Project, In_Tree, No_State);
end if;
return Result (1 .. Last);
end Find_All_Sources;
----------
-- Hash --
----------
function Hash is new GNAT.HTable.Hash (Header_Num => Header_Num);
-- Used in implementation of other functions Hash below
----------
-- Hash --
----------
function Hash (Name : File_Name_Type) return Header_Num is
begin
return Hash (Get_Name_String (Name));
end Hash;
function Hash (Name : Name_Id) return Header_Num is
begin
return Hash (Get_Name_String (Name));
end Hash;
function Hash (Name : Path_Name_Type) return Header_Num is
begin
return Hash (Get_Name_String (Name));
end Hash;
function Hash (Project : Project_Id) return Header_Num is
begin
if Project = No_Project then
return Header_Num'First;
else
return Hash (Get_Name_String (Project.Name));
end if;
end Hash;
-----------
-- Image --
-----------
function Image (The_Casing : Casing_Type) return String is
begin
return The_Casing_Images (The_Casing).all;
end Image;
-----------------------------
-- Is_Standard_GNAT_Naming --
-----------------------------
function Is_Standard_GNAT_Naming
(Naming : Lang_Naming_Data) return Boolean
is
begin
return Get_Name_String (Naming.Spec_Suffix) = ".ads"
and then Get_Name_String (Naming.Body_Suffix) = ".adb"
and then Get_Name_String (Naming.Dot_Replacement) = "-";
end Is_Standard_GNAT_Naming;
----------------
-- Initialize --
----------------
procedure Initialize (Tree : Project_Tree_Ref) is
begin
if The_Empty_String = No_Name then
Uintp.Initialize;
Name_Len := 0;
The_Empty_String := Name_Find;
Name_Len := 1;
Name_Buffer (1) := '.';
The_Dot_String := Name_Find;
Prj.Attr.Initialize;
-- Make sure that new reserved words after Ada 95 may be used as
-- identifiers.
Opt.Ada_Version := Opt.Ada_95;
Opt.Ada_Version_Pragma := Empty;
Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project));
Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends));
Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External));
Set_Name_Table_Byte
(Name_External_As_List, Token_Type'Pos (Tok_External_As_List));
end if;
if Tree /= No_Project_Tree then
Reset (Tree);
end if;
end Initialize;
------------------
-- Is_Extending --
------------------
function Is_Extending
(Extending : Project_Id;
Extended : Project_Id) return Boolean
is
Proj : Project_Id;
begin
Proj := Extending;
while Proj /= No_Project loop
if Proj = Extended then
return True;
end if;
Proj := Proj.Extends;
end loop;
return False;
end Is_Extending;
-----------------
-- Object_Name --
-----------------
function Object_Name
(Source_File_Name : File_Name_Type;
Object_File_Suffix : Name_Id := No_Name) return File_Name_Type
is
begin
if Object_File_Suffix = No_Name then
return Extend_Name
(Source_File_Name, Object_Suffix);
else
return Extend_Name
(Source_File_Name, Get_Name_String (Object_File_Suffix));
end if;
end Object_Name;
function Object_Name
(Source_File_Name : File_Name_Type;
Source_Index : Int;
Index_Separator : Character;
Object_File_Suffix : Name_Id := No_Name) return File_Name_Type
is
Index_Img : constant String := Source_Index'Img;
Last : Natural;
begin
Get_Name_String (Source_File_Name);
Last := Name_Len;
while Last > 1 and then Name_Buffer (Last) /= '.' loop
Last := Last - 1;
end loop;
if Last > 1 then
Name_Len := Last - 1;
end if;
Add_Char_To_Name_Buffer (Index_Separator);
Add_Str_To_Name_Buffer (Index_Img (2 .. Index_Img'Last));
if Object_File_Suffix = No_Name then
Add_Str_To_Name_Buffer (Object_Suffix);
else
Add_Str_To_Name_Buffer (Get_Name_String (Object_File_Suffix));
end if;
return Name_Find;
end Object_Name;
----------------------
-- Record_Temp_File --
----------------------
procedure Record_Temp_File
(Shared : Shared_Project_Tree_Data_Access;
Path : Path_Name_Type)
is
begin
Temp_Files_Table.Append (Shared.Private_Part.Temp_Files, Path);
end Record_Temp_File;
----------
-- Free --
----------
procedure Free (List : in out Aggregated_Project_List) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Aggregated_Project, Aggregated_Project_List);
Tmp : Aggregated_Project_List;
begin
while List /= null loop
Tmp := List.Next;
Free (List.Tree);
Unchecked_Free (List);
List := Tmp;
end loop;
end Free;
----------------------------
-- Add_Aggregated_Project --
----------------------------
procedure Add_Aggregated_Project
(Project : Project_Id;
Path : Path_Name_Type)
is
Aggregated : Aggregated_Project_List;
begin
-- Check if the project is already in the aggregated project list. If it
-- is, do not add it again.
Aggregated := Project.Aggregated_Projects;
while Aggregated /= null loop
if Path = Aggregated.Path then
return;
else
Aggregated := Aggregated.Next;
end if;
end loop;
Project.Aggregated_Projects := new Aggregated_Project'
(Path => Path,
Project => No_Project,
Tree => null,
Next => Project.Aggregated_Projects);
end Add_Aggregated_Project;
----------
-- Free --
----------
procedure Free (Project : in out Project_Id) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_Data, Project_Id);
begin
if Project /= null then
Free (Project.Ada_Include_Path);
Free (Project.Objects_Path);
Free (Project.Ada_Objects_Path);
Free (Project.Ada_Objects_Path_No_Libs);
Free_List (Project.Imported_Projects, Free_Project => False);
Free_List (Project.All_Imported_Projects, Free_Project => False);
Free_List (Project.Languages);
case Project.Qualifier is
when Aggregate
| Aggregate_Library
=>
Free (Project.Aggregated_Projects);
when others =>
null;
end case;
Unchecked_Free (Project);
end if;
end Free;
---------------
-- Free_List --
---------------
procedure Free_List (Languages : in out Language_List) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Language_List_Element, Language_List);
Tmp : Language_List;
begin
while Languages /= null loop
Tmp := Languages.Next;
Unchecked_Free (Languages);
Languages := Tmp;
end loop;
end Free_List;
---------------
-- Free_List --
---------------
procedure Free_List (Source : in out Source_Id) is
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation (Source_Data, Source_Id);
Tmp : Source_Id;
begin
while Source /= No_Source loop
Tmp := Source.Next_In_Lang;
Free_List (Source.Alternate_Languages);
if Source.Unit /= null
and then Source.Kind in Spec_Or_Body
then
Source.Unit.File_Names (Source.Kind) := null;
end if;
Unchecked_Free (Source);
Source := Tmp;
end loop;
end Free_List;
---------------
-- Free_List --
---------------
procedure Free_List
(List : in out Project_List;
Free_Project : Boolean)
is
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation (Project_List_Element, Project_List);
Tmp : Project_List;
begin
while List /= null loop
Tmp := List.Next;
if Free_Project then
Free (List.Project);
end if;
Unchecked_Free (List);
List := Tmp;
end loop;
end Free_List;
---------------
-- Free_List --
---------------
procedure Free_List (Languages : in out Language_Ptr) is
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation (Language_Data, Language_Ptr);
Tmp : Language_Ptr;
begin
while Languages /= null loop
Tmp := Languages.Next;
Free_List (Languages.First_Source);
Unchecked_Free (Languages);
Languages := Tmp;
end loop;
end Free_List;
--------------------------
-- Reset_Units_In_Table --
--------------------------
procedure Reset_Units_In_Table (Table : in out Units_Htable.Instance) is
Unit : Unit_Index;
begin
Unit := Units_Htable.Get_First (Table);
while Unit /= No_Unit_Index loop
if Unit.File_Names (Spec) /= null then
Unit.File_Names (Spec).Unit := No_Unit_Index;
end if;
if Unit.File_Names (Impl) /= null then
Unit.File_Names (Impl).Unit := No_Unit_Index;
end if;
Unit := Units_Htable.Get_Next (Table);
end loop;
end Reset_Units_In_Table;
----------------
-- Free_Units --
----------------
procedure Free_Units (Table : in out Units_Htable.Instance) is
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation (Unit_Data, Unit_Index);
Unit : Unit_Index;
begin
Unit := Units_Htable.Get_First (Table);
while Unit /= No_Unit_Index loop
-- We cannot reset Unit.File_Names (Impl or Spec).Unit here as
-- Source_Data buffer is freed by the following instruction
-- Free_List (Tree.Projects, Free_Project => True);
Unchecked_Free (Unit);
Unit := Units_Htable.Get_Next (Table);
end loop;
Units_Htable.Reset (Table);
end Free_Units;
----------
-- Free --
----------
procedure Free (Tree : in out Project_Tree_Ref) is
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation
(Project_Tree_Data, Project_Tree_Ref);
procedure Unchecked_Free is new
Ada.Unchecked_Deallocation
(Project_Tree_Appdata'Class, Project_Tree_Appdata_Access);
begin
if Tree /= null then
if Tree.Is_Root_Tree then
Name_List_Table.Free (Tree.Shared.Name_Lists);
Number_List_Table.Free (Tree.Shared.Number_Lists);
String_Element_Table.Free (Tree.Shared.String_Elements);
Variable_Element_Table.Free (Tree.Shared.Variable_Elements);
Array_Element_Table.Free (Tree.Shared.Array_Elements);
Array_Table.Free (Tree.Shared.Arrays);
Package_Table.Free (Tree.Shared.Packages);
Temp_Files_Table.Free (Tree.Shared.Private_Part.Temp_Files);
end if;
if Tree.Appdata /= null then
Free (Tree.Appdata.all);
Unchecked_Free (Tree.Appdata);
end if;
Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
Source_Files_Htable.Reset (Tree.Source_Files_HT);
Reset_Units_In_Table (Tree.Units_HT);
Free_List (Tree.Projects, Free_Project => True);
Free_Units (Tree.Units_HT);
Unchecked_Free (Tree);
end if;
end Free;
-----------
-- Reset --
-----------
procedure Reset (Tree : Project_Tree_Ref) is
begin
-- Visible tables
if Tree.Is_Root_Tree then
-- We cannot use 'Access here:
-- "illegal attribute for discriminant-dependent component"
-- However, we know this is valid since Shared and Shared_Data have
-- the same lifetime and will always exist concurrently.
Tree.Shared := Tree.Shared_Data'Unrestricted_Access;
Name_List_Table.Init (Tree.Shared.Name_Lists);
Number_List_Table.Init (Tree.Shared.Number_Lists);
String_Element_Table.Init (Tree.Shared.String_Elements);
Variable_Element_Table.Init (Tree.Shared.Variable_Elements);
Array_Element_Table.Init (Tree.Shared.Array_Elements);
Array_Table.Init (Tree.Shared.Arrays);
Package_Table.Init (Tree.Shared.Packages);
-- Create Dot_String_List
String_Element_Table.Append
(Tree.Shared.String_Elements,
String_Element'
(Value => The_Dot_String,
Index => 0,
Display_Value => The_Dot_String,
Location => No_Location,
Flag => False,
Next => Nil_String));
Tree.Shared.Dot_String_List :=
String_Element_Table.Last (Tree.Shared.String_Elements);
-- Private part table
Temp_Files_Table.Init (Tree.Shared.Private_Part.Temp_Files);
Tree.Shared.Private_Part.Current_Source_Path_File := No_Path;
Tree.Shared.Private_Part.Current_Object_Path_File := No_Path;
end if;
Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
Source_Files_Htable.Reset (Tree.Source_Files_HT);
Replaced_Source_HTable.Reset (Tree.Replaced_Sources);
Tree.Replaced_Source_Number := 0;
Reset_Units_In_Table (Tree.Units_HT);
Free_List (Tree.Projects, Free_Project => True);
Free_Units (Tree.Units_HT);
end Reset;
-------------------------------------
-- Set_Current_Object_Path_File_Of --
-------------------------------------
procedure Set_Current_Object_Path_File_Of
(Shared : Shared_Project_Tree_Data_Access;
To : Path_Name_Type)
is
begin
Shared.Private_Part.Current_Object_Path_File := To;
end Set_Current_Object_Path_File_Of;
-------------------------------------
-- Set_Current_Source_Path_File_Of --
-------------------------------------
procedure Set_Current_Source_Path_File_Of
(Shared : Shared_Project_Tree_Data_Access;
To : Path_Name_Type)
is
begin
Shared.Private_Part.Current_Source_Path_File := To;
end Set_Current_Source_Path_File_Of;
-----------------------
-- Set_Path_File_Var --
-----------------------
procedure Set_Path_File_Var (Name : String; Value : String) is
Host_Spec : String_Access := To_Host_File_Spec (Value);
begin
if Host_Spec = null then
Prj.Com.Fail
("could not convert file name """ & Value & """ to host spec");
else
Setenv (Name, Host_Spec.all);
Free (Host_Spec);
end if;
end Set_Path_File_Var;
-------------------
-- Switches_Name --
-------------------
function Switches_Name
(Source_File_Name : File_Name_Type) return File_Name_Type
is
begin
return Extend_Name (Source_File_Name, Switches_Dependency_Suffix);
end Switches_Name;
-----------
-- Value --
-----------
function Value (Image : String) return Casing_Type is
begin
for Casing in The_Casing_Images'Range loop
if To_Lower (Image) = To_Lower (The_Casing_Images (Casing).all) then
return Casing;
end if;
end loop;
raise Constraint_Error;
end Value;
---------------------
-- Has_Ada_Sources --
---------------------
function Has_Ada_Sources (Data : Project_Id) return Boolean is
Lang : Language_Ptr;
begin
Lang := Data.Languages;
while Lang /= No_Language_Index loop
if Lang.Name = Name_Ada then
return Lang.First_Source /= No_Source;
end if;
Lang := Lang.Next;
end loop;
return False;
end Has_Ada_Sources;
------------------------
-- Contains_ALI_Files --
------------------------
function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is
Dir_Name : constant String := Get_Name_String (Dir);
Direct : Dir_Type;
Name : String (1 .. 1_000);
Last : Natural;
Result : Boolean := False;
begin
Open (Direct, Dir_Name);
-- For each file in the directory, check if it is an ALI file
loop
Read (Direct, Name, Last);
exit when Last = 0;
Canonical_Case_File_Name (Name (1 .. Last));
Result := Last >= 5 and then Name (Last - 3 .. Last) = ".ali";
exit when Result;
end loop;
Close (Direct);
return Result;
exception
-- If there is any problem, close the directory if open and return True.
-- The library directory will be added to the path.
when others =>
if Is_Open (Direct) then
Close (Direct);
end if;
return True;
end Contains_ALI_Files;
--------------------------
-- Get_Object_Directory --
--------------------------
function Get_Object_Directory
(Project : Project_Id;
Including_Libraries : Boolean;
Only_If_Ada : Boolean := False) return Path_Name_Type
is
begin
if (Project.Library and then Including_Libraries)
or else
(Project.Object_Directory /= No_Path_Information
and then (not Including_Libraries or else not Project.Library))
then
-- For a library project, add the library ALI directory if there is
-- no object directory or if the library ALI directory contains ALI
-- files; otherwise add the object directory.
if Project.Library then
if Project.Object_Directory = No_Path_Information
or else
(Including_Libraries
and then
Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name))
then
return Project.Library_ALI_Dir.Display_Name;
else
return Project.Object_Directory.Display_Name;
end if;
-- For a non-library project, add object directory if it is not a
-- virtual project, and if there are Ada sources in the project or
-- one of the projects it extends. If there are no Ada sources,
-- adding the object directory could disrupt the order of the
-- object dirs in the path.
elsif not Project.Virtual then
declare
Add_Object_Dir : Boolean;
Prj : Project_Id;
begin
Add_Object_Dir := not Only_If_Ada;
Prj := Project;
while not Add_Object_Dir and then Prj /= No_Project loop
if Has_Ada_Sources (Prj) then
Add_Object_Dir := True;
else
Prj := Prj.Extends;
end if;
end loop;
if Add_Object_Dir then
return Project.Object_Directory.Display_Name;
end if;
end;
end if;
end if;
return No_Path;
end Get_Object_Directory;
-----------------------------------
-- Ultimate_Extending_Project_Of --
-----------------------------------
function Ultimate_Extending_Project_Of
(Proj : Project_Id) return Project_Id
is
Prj : Project_Id;
begin
Prj := Proj;
while Prj /= null and then Prj.Extended_By /= No_Project loop
Prj := Prj.Extended_By;
end loop;
return Prj;
end Ultimate_Extending_Project_Of;
-----------------------------------
-- Compute_All_Imported_Projects --
-----------------------------------
procedure Compute_All_Imported_Projects
(Root_Project : Project_Id;
Tree : Project_Tree_Ref)
is
procedure Analyze_Tree
(Local_Root : Project_Id;
Local_Tree : Project_Tree_Ref;
Context : Project_Context);
-- Process Project and all its aggregated project to analyze their own
-- imported projects.
------------------
-- Analyze_Tree --
------------------
procedure Analyze_Tree
(Local_Root : Project_Id;
Local_Tree : Project_Tree_Ref;
Context : Project_Context)
is
pragma Unreferenced (Local_Root);
Project : Project_Id;
procedure Recursive_Add
(Prj : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context;
Dummy : in out Boolean);
-- Recursively add the projects imported by project Project, but not
-- those that are extended.
-------------------
-- Recursive_Add --
-------------------
procedure Recursive_Add
(Prj : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context;
Dummy : in out Boolean)
is
pragma Unreferenced (Tree);
List : Project_List;
Prj2 : Project_Id;
begin
-- A project is not importing itself
Prj2 := Ultimate_Extending_Project_Of (Prj);
if Project /= Prj2 then
-- Check that the project is not already in the list. We know
-- the one passed to Recursive_Add have never been visited
-- before, but the one passed it are the extended projects.
List := Project.All_Imported_Projects;
while List /= null loop
if List.Project = Prj2 then
return;
end if;
List := List.Next;
end loop;
-- Add it to the list
Project.All_Imported_Projects :=
new Project_List_Element'
(Project => Prj2,
From_Encapsulated_Lib =>
Context.From_Encapsulated_Lib
or else Analyze_Tree.Context.From_Encapsulated_Lib,
Next => Project.All_Imported_Projects);
end if;
end Recursive_Add;
procedure For_All_Projects is
new For_Every_Project_Imported_Context (Boolean, Recursive_Add);
Dummy : Boolean := False;
List : Project_List;
begin
List := Local_Tree.Projects;
while List /= null loop
Project := List.Project;
Free_List
(Project.All_Imported_Projects, Free_Project => False);
For_All_Projects
(Project, Local_Tree, Dummy, Include_Aggregated => False);
List := List.Next;
end loop;
end Analyze_Tree;
procedure For_Aggregates is
new For_Project_And_Aggregated_Context (Analyze_Tree);
-- Start of processing for Compute_All_Imported_Projects
begin
For_Aggregates (Root_Project, Tree);
end Compute_All_Imported_Projects;
-------------------
-- Is_Compilable --
-------------------
function Is_Compilable (Source : Source_Id) return Boolean is
begin
case Source.Compilable is
when Unknown =>
if Source.Language.Config.Compiler_Driver /= No_File
and then
Length_Of_Name (Source.Language.Config.Compiler_Driver) /= 0
and then not Source.Locally_Removed
and then (Source.Language.Config.Kind /= File_Based
or else Source.Kind /= Spec)
then
-- Do not modify Source.Compilable before the source record
-- has been initialized.
if Source.Source_TS /= Empty_Time_Stamp then
Source.Compilable := Yes;
end if;
return True;
else
if Source.Source_TS /= Empty_Time_Stamp then
Source.Compilable := No;
end if;
return False;
end if;
when Yes =>
return True;
when No =>
return False;
end case;
end Is_Compilable;
------------------------------
-- Object_To_Global_Archive --
------------------------------
function Object_To_Global_Archive (Source : Source_Id) return Boolean is
begin
return Source.Language.Config.Kind = File_Based
and then Source.Kind = Impl
and then Source.Language.Config.Objects_Linked
and then Is_Compilable (Source)
and then Source.Language.Config.Object_Generated;
end Object_To_Global_Archive;
----------------------------
-- Get_Language_From_Name --
----------------------------
function Get_Language_From_Name
(Project : Project_Id;
Name : String) return Language_Ptr
is
N : Name_Id;
Result : Language_Ptr;
begin
Name_Len := Name'Length;
Name_Buffer (1 .. Name_Len) := Name;
To_Lower (Name_Buffer (1 .. Name_Len));
N := Name_Find;
Result := Project.Languages;
while Result /= No_Language_Index loop
if Result.Name = N then
return Result;
end if;
Result := Result.Next;
end loop;
return No_Language_Index;
end Get_Language_From_Name;
----------------
-- Other_Part --
----------------
function Other_Part (Source : Source_Id) return Source_Id is
begin
if Source.Unit /= No_Unit_Index then
case Source.Kind is
when Impl => return Source.Unit.File_Names (Spec);
when Spec => return Source.Unit.File_Names (Impl);
when Sep => return No_Source;
end case;
else
return No_Source;
end if;
end Other_Part;
------------------
-- Create_Flags --
------------------
function Create_Flags
(Report_Error : Error_Handler;
When_No_Sources : Error_Warning;
Require_Sources_Other_Lang : Boolean := True;
Allow_Duplicate_Basenames : Boolean := True;
Compiler_Driver_Mandatory : Boolean := False;
Error_On_Unknown_Language : Boolean := True;
Require_Obj_Dirs : Error_Warning := Error;
Allow_Invalid_External : Error_Warning := Error;
Missing_Source_Files : Error_Warning := Error;
Ignore_Missing_With : Boolean := False)
return Processing_Flags
is
begin
return Processing_Flags'
(Report_Error => Report_Error,
When_No_Sources => When_No_Sources,
Require_Sources_Other_Lang => Require_Sources_Other_Lang,
Allow_Duplicate_Basenames => Allow_Duplicate_Basenames,
Error_On_Unknown_Language => Error_On_Unknown_Language,
Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
Require_Obj_Dirs => Require_Obj_Dirs,
Allow_Invalid_External => Allow_Invalid_External,
Missing_Source_Files => Missing_Source_Files,
Ignore_Missing_With => Ignore_Missing_With,
Incomplete_Withs => False);
end Create_Flags;
------------
-- Length --
------------
function Length
(Table : Name_List_Table.Instance;
List : Name_List_Index) return Natural
is
Count : Natural := 0;
Tmp : Name_List_Index;
begin
Tmp := List;
while Tmp /= No_Name_List loop
Count := Count + 1;
Tmp := Table.Table (Tmp).Next;
end loop;
return Count;
end Length;
------------------
-- Debug_Output --
------------------
procedure Debug_Output (Str : String) is
begin
if Current_Verbosity > Default then
Set_Standard_Error;
Write_Line ((1 .. Debug_Level * 2 => ' ') & Str);
Set_Standard_Output;
end if;
end Debug_Output;
------------------
-- Debug_Indent --
------------------
procedure Debug_Indent is
begin
if Current_Verbosity = High then
Set_Standard_Error;
Write_Str ((1 .. Debug_Level * 2 => ' '));
Set_Standard_Output;
end if;
end Debug_Indent;
------------------
-- Debug_Output --
------------------
procedure Debug_Output (Str : String; Str2 : Name_Id) is
begin
if Current_Verbosity > Default then
Debug_Indent;
Set_Standard_Error;
Write_Str (Str);
if Str2 = No_Name then
Write_Line (" <no_name>");
else
Write_Line (" """ & Get_Name_String (Str2) & '"');
end if;
Set_Standard_Output;
end if;
end Debug_Output;
---------------------------
-- Debug_Increase_Indent --
---------------------------
procedure Debug_Increase_Indent
(Str : String := ""; Str2 : Name_Id := No_Name)
is
begin
if Str2 /= No_Name then
Debug_Output (Str, Str2);
else
Debug_Output (Str);
end if;
Debug_Level := Debug_Level + 1;
end Debug_Increase_Indent;
---------------------------
-- Debug_Decrease_Indent --
---------------------------
procedure Debug_Decrease_Indent (Str : String := "") is
begin
if Debug_Level > 0 then
Debug_Level := Debug_Level - 1;
end if;
if Str /= "" then
Debug_Output (Str);
end if;
end Debug_Decrease_Indent;
----------------
-- Debug_Name --
----------------
function Debug_Name (Tree : Project_Tree_Ref) return Name_Id is
P : Project_List;
begin
Name_Len := 0;
Add_Str_To_Name_Buffer ("Tree [");
P := Tree.Projects;
while P /= null loop
if P /= Tree.Projects then
Add_Char_To_Name_Buffer (',');
end if;
Add_Str_To_Name_Buffer (Get_Name_String (P.Project.Name));
P := P.Next;
end loop;
Add_Char_To_Name_Buffer (']');
return Name_Find;
end Debug_Name;
----------
-- Free --
----------
procedure Free (Tree : in out Project_Tree_Appdata) is
pragma Unreferenced (Tree);
begin
null;
end Free;
--------------------------------
-- For_Project_And_Aggregated --
--------------------------------
procedure For_Project_And_Aggregated
(Root_Project : Project_Id;
Root_Tree : Project_Tree_Ref)
is
Agg : Aggregated_Project_List;
begin
Action (Root_Project, Root_Tree);
if Root_Project.Qualifier in Aggregate_Project then
Agg := Root_Project.Aggregated_Projects;
while Agg /= null loop
For_Project_And_Aggregated (Agg.Project, Agg.Tree);
Agg := Agg.Next;
end loop;
end if;
end For_Project_And_Aggregated;
----------------------------------------
-- For_Project_And_Aggregated_Context --
----------------------------------------
procedure For_Project_And_Aggregated_Context
(Root_Project : Project_Id;
Root_Tree : Project_Tree_Ref)
is
procedure Recursive_Process
(Project : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context);
-- Process Project and all aggregated projects recursively
-----------------------
-- Recursive_Process --
-----------------------
procedure Recursive_Process
(Project : Project_Id;
Tree : Project_Tree_Ref;
Context : Project_Context)
is
Agg : Aggregated_Project_List;
Ctx : Project_Context;
begin
Action (Project, Tree, Context);
if Project.Qualifier in Aggregate_Project then
Ctx :=
(In_Aggregate_Lib => Project.Qualifier = Aggregate_Library,
From_Encapsulated_Lib =>
Context.From_Encapsulated_Lib
or else Project.Standalone_Library = Encapsulated);
Agg := Project.Aggregated_Projects;
while Agg /= null loop
Recursive_Process (Agg.Project, Agg.Tree, Ctx);
Agg := Agg.Next;
end loop;
end if;
end Recursive_Process;
-- Start of processing for For_Project_And_Aggregated_Context
begin
Recursive_Process
(Root_Project, Root_Tree, Project_Context'(False, False));
end For_Project_And_Aggregated_Context;
-----------------------------
-- Set_Ignore_Missing_With --
-----------------------------
procedure Set_Ignore_Missing_With
(Flags : in out Processing_Flags;
Value : Boolean)
is
begin
Flags.Ignore_Missing_With := Value;
end Set_Ignore_Missing_With;
-- Package initialization for Prj
begin
-- Make sure that the standard config and user project file extensions are
-- compatible with canonical case file naming.
Canonical_Case_File_Name (Config_Project_File_Extension);
Canonical_Case_File_Name (Project_File_Extension);
end Prj;
|
with C.winbase;
with C.winnt;
package body System.Native_Time is
-- implementation
function To_Duration (D : C.windef.FILETIME) return Duration is
U : constant C.winnt.ULARGE_INTEGER := (
Unchecked_Tag => 0,
LowPart => D.dwLowDateTime,
HighPart => D.dwHighDateTime);
begin
return Duration'Fixed_Value ((Nanosecond_Number (U.QuadPart)) * 100);
end To_Duration;
procedure Simple_Delay_For (D : Duration) is
begin
C.winbase.Sleep (C.windef.DWORD (D * 1_000.0));
end Simple_Delay_For;
procedure Delay_For (D : Duration) is
begin
if D >= 0.0 then
Delay_For_Hook.all (D);
end if;
end Delay_For;
end System.Native_Time;
|
with Ada.Text_IO;
procedure Euler8 is
Product_Size : constant Positive := 13;
type Product is range 0 .. 9 ** Product_Size;
package Product_IO is new Ada.Text_IO.Integer_IO(Product);
function String_Product(S: String) return Product is
Prod: Product := 1;
begin
for C of S loop
Prod := Prod * (Character'Pos(C) - Character'Pos('0'));
end loop;
return Prod;
end String_Product;
Line_Length: constant Positive := 50;
Number: String(1 .. 1000);
Append: Positive := Number'First;
Curr, Max: Product := 0;
begin
while not Ada.Text_IO.End_Of_File loop
Number(Append .. Append + Line_Length - 1) := Ada.Text_IO.Get_Line;
Append := Append + Line_Length;
end loop;
for I in Number'Range loop
exit when I + Product_Size - 1 > Number'Last;
Curr := String_Product(Number(I .. I + Product_Size - 1));
if Curr > Max then Max := Curr; end if;
end loop;
Product_IO.Put(Max);
end Euler8;
|
separate (Numerics.Sparse_Matrices)
function Kronecker (A, B : in Sparse_Matrix) return Sparse_Matrix is
Result : Sparse_Matrix;
N_Col : constant Pos := B.N_Col;
N_Row : constant Pos := B.N_Row;
Bl : Int_Array (1 .. N_Col);
Al : Integer;
Tmp : Nat := 1;
use Ada.Containers;
begin
Result.Format := CSC;
Result.N_Row := A.N_Row * B.N_Row;
Result.N_Col := A.N_Col * B.N_Col;
Result.I.Reserve_Capacity (A.I.Length * B.I.Length);
Result.X.Reserve_Capacity (A.X.Length * B.X.Length);
Result.P.Reserve_Capacity (Count_Type (Result.N_Col + 1));
-- Set P
for I in Bl'Range loop
Bl (I) := B.P (I + 1) - B.P (I); -- #Elements in col(I) of right
end loop;
Result.P.Append (Tmp); -- Tmp = 1
for I in 1 .. A.N_Col loop
Al := A.P (I + 1) - A.P (I); -- #Elements in col(I) of left
for J in Bl'Range loop -- Assign Result.P
Tmp := Tmp + Pos (Al * Bl (J));
Result.P.Append (Tmp);
end loop;
end loop;
-- Set I
for PI in 1 .. A.N_Col loop
for PJ in 1 .. B.N_Col loop
for I in A.P (PI) .. A.P (PI + 1) - 1 loop
for J in B.P (PJ) .. B.P (PJ + 1) - 1 loop
Result.I.Append ((A.I (I) - 1) * N_Row + B.I (J));
Result.X.Append (A.X (I) * B.X (J));
end loop;
end loop;
end loop;
end loop;
return Result;
end Kronecker;
|
-- { dg-do run }
with Ada.Tags; use Ada.Tags;
with Ada.Text_IO; use Ada.Text_IO;
procedure aggr3 is
package Pkg is
type Element is interface;
type Event is tagged record
V1 : Natural;
V2 : Natural;
end record;
function Create return Event;
type D_Event is new Event and Element with null record;
function Create return D_Event;
end;
package body Pkg is
function Create return Event is
Obj : Event;
begin
Obj.V1 := 0;
return Obj;
end;
function Create return D_Event is
begin
return (Event'(Create) with null record);
end;
end;
use Pkg;
procedure CW_Test (Obj : Element'Class) is
S : Constant String := Expanded_Name (Obj'Tag);
begin
null;
end;
begin
CW_Test (Create);
end;
|
with
Interfaces.C.Strings,
Ada.Unchecked_Deallocation,
System;
use type
System.Address,
Interfaces.C.int,
Interfaces.C.unsigned_long,
Interfaces.C.Strings.chars_ptr;
package body FLTK.Widgets.Menus is
procedure menu_set_draw_hook
(W, D : in System.Address);
pragma Import (C, menu_set_draw_hook, "menu_set_draw_hook");
pragma Inline (menu_set_draw_hook);
procedure menu_set_handle_hook
(W, H : in System.Address);
pragma Import (C, menu_set_handle_hook, "menu_set_handle_hook");
pragma Inline (menu_set_handle_hook);
function new_fl_menu
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_menu, "new_fl_menu");
pragma Inline (new_fl_menu);
procedure free_fl_menu
(F : in System.Address);
pragma Import (C, free_fl_menu, "free_fl_menu");
pragma Inline (free_fl_menu);
function fl_menu_add
(M : in System.Address;
T : in Interfaces.C.char_array;
S : in Interfaces.C.unsigned_long;
C, U : in System.Address;
F : in Interfaces.C.unsigned_long)
return Interfaces.C.int;
pragma Import (C, fl_menu_add, "fl_menu_add");
pragma Inline (fl_menu_add);
function fl_menu_insert
(M : in System.Address;
P : in Interfaces.C.int;
T : in Interfaces.C.char_array;
S : in Interfaces.C.unsigned_long;
C, U : in System.Address;
F : in Interfaces.C.unsigned_long)
return Interfaces.C.int;
pragma Import (C, fl_menu_insert, "fl_menu_insert");
pragma Inline (fl_menu_insert);
procedure fl_menu_remove
(M : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_menu_remove, "fl_menu_remove");
pragma Inline (fl_menu_remove);
procedure fl_menu_clear
(M : in System.Address);
pragma Import (C, fl_menu_clear, "fl_menu_clear");
pragma Inline (fl_menu_clear);
function fl_menu_get_item
(M : in System.Address;
I : in Interfaces.C.int)
return System.Address;
pragma Import (C, fl_menu_get_item, "fl_menu_get_item");
pragma Inline (fl_menu_get_item);
function fl_menu_find_item
(M : in System.Address;
T : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, fl_menu_find_item, "fl_menu_find_item");
pragma Inline (fl_menu_find_item);
function fl_menu_find_item2
(M, C : in System.Address)
return System.Address;
pragma Import (C, fl_menu_find_item2, "fl_menu_find_item2");
pragma Inline (fl_menu_find_item2);
function fl_menu_find_index
(M : in System.Address;
T : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_menu_find_index, "fl_menu_find_index");
pragma Inline (fl_menu_find_index);
function fl_menu_find_index2
(M, I : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_find_index2, "fl_menu_find_index2");
pragma Inline (fl_menu_find_index2);
function fl_menu_find_index3
(M, C : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_find_index3, "fl_menu_find_index3");
pragma Inline (fl_menu_find_index3);
function fl_menu_size
(M : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_size, "fl_menu_size");
pragma Inline (fl_menu_size);
function fl_menu_mvalue
(M : in System.Address)
return System.Address;
pragma Import (C, fl_menu_mvalue, "fl_menu_mvalue");
pragma Inline (fl_menu_mvalue);
function fl_menu_text
(M : in System.Address)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, fl_menu_text, "fl_menu_text");
pragma Inline (fl_menu_text);
function fl_menu_value
(M : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_value, "fl_menu_value");
pragma Inline (fl_menu_value);
function fl_menu_set_value
(M : in System.Address;
I : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_menu_set_value, "fl_menu_set_value");
pragma Inline (fl_menu_set_value);
function fl_menu_set_value2
(M, I : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_set_value2, "fl_menu_set_value2");
pragma Inline (fl_menu_set_value2);
function fl_menu_get_textcolor
(M : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_menu_get_textcolor, "fl_menu_get_textcolor");
pragma Inline (fl_menu_get_textcolor);
procedure fl_menu_set_textcolor
(M : in System.Address;
C : in Interfaces.C.unsigned);
pragma Import (C, fl_menu_set_textcolor, "fl_menu_set_textcolor");
pragma Inline (fl_menu_set_textcolor);
function fl_menu_get_textfont
(M : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_get_textfont, "fl_menu_get_textfont");
pragma Inline (fl_menu_get_textfont);
procedure fl_menu_set_textfont
(M : in System.Address;
F : in Interfaces.C.int);
pragma Import (C, fl_menu_set_textfont, "fl_menu_set_textfont");
pragma Inline (fl_menu_set_textfont);
function fl_menu_get_textsize
(M : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_get_textsize, "fl_menu_get_textsize");
pragma Inline (fl_menu_get_textsize);
procedure fl_menu_set_textsize
(M : in System.Address;
S : in Interfaces.C.int);
pragma Import (C, fl_menu_set_textsize, "fl_menu_set_textsize");
pragma Inline (fl_menu_set_textsize);
function fl_menu_get_down_box
(M : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_menu_get_down_box, "fl_menu_get_down_box");
pragma Inline (fl_menu_get_down_box);
procedure fl_menu_set_down_box
(M : in System.Address;
T : in Interfaces.C.int);
pragma Import (C, fl_menu_set_down_box, "fl_menu_set_down_box");
pragma Inline (fl_menu_set_down_box);
procedure fl_menu_global
(M : in System.Address);
pragma Import (C, fl_menu_global, "fl_menu_global");
pragma Inline (fl_menu_global);
function fl_menu_measure
(M : in System.Address;
I : in Interfaces.C.int;
H : out Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_menu_measure, "fl_menu_measure");
pragma Inline (fl_menu_measure);
function fl_menu_popup
(M : in System.Address;
X, Y : in Interfaces.C.int;
T : in Interfaces.C.char_array;
N : in Interfaces.C.int)
return System.Address;
pragma Import (C, fl_menu_popup, "fl_menu_popup");
pragma Inline (fl_menu_popup);
function fl_menu_pulldown
(M : in System.Address;
X, Y, W, H : in Interfaces.C.int;
N : in Interfaces.C.int)
return System.Address;
pragma Import (C, fl_menu_pulldown, "fl_menu_pulldown");
pragma Inline (fl_menu_pulldown);
procedure fl_menu_draw_item
(M : in System.Address;
I : in Interfaces.C.int;
X, Y, W, H : in Interfaces.C.int;
S : in Interfaces.C.int);
pragma Import (C, fl_menu_draw_item, "fl_menu_draw_item");
pragma Inline (fl_menu_draw_item);
procedure Item_Hook
(M, U : in System.Address)
is
Ada_Widget : access Widget'Class :=
Widget_Convert.To_Pointer (fl_widget_get_user_data (M));
Action : Widget_Callback := Callback_Convert.To_Pointer (U);
begin
Action.all (Ada_Widget.all);
end Item_Hook;
procedure Free_Item is new Ada.Unchecked_Deallocation
(Object => FLTK.Menu_Items.Menu_Item, Name => Item_Access);
procedure Finalize
(This : in out Menu) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Menu'Class
then
for Item of This.My_Items loop
Free_Item (Item);
end loop;
free_fl_menu (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Widget (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Menu is
begin
return This : Menu do
This.Void_Ptr := new_fl_menu
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
menu_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
menu_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
This.My_Items := Item_Vectors.Empty_Vector;
end return;
end Create;
end Forge;
procedure Add
(This : in out Menu;
Text : in String;
Action : in Widget_Callback := null;
Shortcut : in Key_Combo := No_Key;
Flags : in Menu_Flag := Flag_Normal)
is
Place : Interfaces.C.int;
Callback, User_Data : System.Address := System.Null_Address;
New_Item : Item_Access;
begin
if Action /= null then
Callback := Item_Hook'Address;
User_Data := Callback_Convert.To_Address (Action);
end if;
Place := fl_menu_add
(This.Void_Ptr,
Interfaces.C.To_C (Text),
To_C (Shortcut),
Callback,
User_Data,
Interfaces.C.unsigned_long (Flags));
New_Item := new FLTK.Menu_Items.Menu_Item;
Wrapper (New_Item.all).Void_Ptr := fl_menu_get_item (This.Void_Ptr, Place);
Wrapper (New_Item.all).Needs_Dealloc := False;
This.My_Items.Append (New_Item);
end Add;
procedure Insert
(This : in out Menu;
Place : in Index;
Text : in String;
Action : in Widget_Callback := null;
Shortcut : in Key_Combo := No_Key;
Flags : in Menu_Flag := Flag_Normal)
is
Ret_Place : Interfaces.C.int;
Callback, User_Data : System.Address := System.Null_Address;
New_Item : Item_Access;
begin
if Action /= null then
Callback := Item_Hook'Address;
User_Data := Callback_Convert.To_Address (Action);
end if;
Ret_Place := fl_menu_insert
(This.Void_Ptr,
Interfaces.C.int (Place) - 1,
Interfaces.C.To_C (Text),
To_C (Shortcut),
Callback,
User_Data,
Interfaces.C.unsigned_long (Flags));
New_Item := new FLTK.Menu_Items.Menu_Item;
Wrapper (New_Item.all).Void_Ptr := fl_menu_get_item (This.Void_Ptr, Ret_Place);
Wrapper (New_Item.all).Needs_Dealloc := False;
This.My_Items.Insert (Positive (Ret_Place + 1), New_Item);
end Insert;
procedure Remove
(This : in out Menu;
Place : in Index) is
begin
Free_Item (This.My_Items.Reference (Place));
This.My_Items.Delete (Place);
fl_menu_remove (This.Void_Ptr, Interfaces.C.int (Place) - 1);
end Remove;
procedure Clear
(This : in out Menu) is
begin
for Item of This.My_Items loop
Free_Item (Item);
end loop;
This.My_Items := Item_Vectors.Empty_Vector;
fl_menu_clear (This.Void_Ptr);
end Clear;
function Has_Item
(This : in Menu;
Place : in Index)
return Boolean is
begin
return Place in 1 .. This.Number_Of_Items;
end Has_Item;
function Has_Item
(Place : in Cursor)
return Boolean is
begin
return Place.My_Container.Has_Item (Place.My_Index);
end Has_Item;
function Item
(This : in Menu;
Place : in Index)
return FLTK.Menu_Items.Menu_Item_Reference is
begin
return (Data => This.My_Items.Element (Place));
end Item;
function Item
(This : in Menu;
Place : in Cursor)
return FLTK.Menu_Items.Menu_Item_Reference is
begin
return This.Item (Place.My_Index);
end Item;
function Find_Item
(This : in Menu;
Name : in String)
return FLTK.Menu_Items.Menu_Item_Reference is
begin
return (Data => This.My_Items.Element (This.Find_Index (Name)));
end Find_Item;
function Find_Item
(This : in Menu;
Action : in Widget_Callback)
return FLTK.Menu_Items.Menu_Item_Reference is
begin
return (Data => This.My_Items.Element (This.Find_Index (Action)));
end Find_Item;
function Find_Index
(This : in Menu;
Name : in String)
return Extended_Index
is
Ret : Interfaces.C.int;
begin
Ret := fl_menu_find_index (This.Void_Ptr, Interfaces.C.To_C (Name));
return Extended_Index (Ret + 1);
end Find_Index;
function Find_Index
(This : in Menu;
Item : in FLTK.Menu_Items.Menu_Item)
return Extended_Index
is
Ret : Interfaces.C.int;
begin
Ret := fl_menu_find_index2 (This.Void_Ptr, Wrapper (Item).Void_Ptr);
return Extended_Index (Ret + 1);
end Find_Index;
function Find_Index
(This : in Menu;
Action : in Widget_Callback)
return Extended_Index
is
Ret : Interfaces.C.int;
begin
Ret := fl_menu_find_index3
(This.Void_Ptr,
Callback_Convert.To_Address (Action));
return Extended_Index (Ret + 1);
end Find_Index;
function Number_Of_Items
(This : in Menu)
return Natural is
begin
return Natural (fl_menu_size (This.Void_Ptr));
end Number_Of_Items;
function Iterate
(This : in Menu)
return Menu_Iterators.Reversible_Iterator'Class is
begin
return It : Iterator := (My_Container => This'Unrestricted_Access);
end Iterate;
function First
(Object : in Iterator)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Object.My_Container,
My_Index => 1);
end First;
function Next
(Object : in Iterator;
Place : in Cursor)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Place.My_Container,
My_Index => Place.My_Index + 1);
end Next;
function Last
(Object : in Iterator)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Object.My_Container,
My_Index => Object.My_Container.Number_Of_Items);
end Last;
function Previous
(Object : in Iterator;
Place : in Cursor)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Place.My_Container,
My_Index => Place.My_Index - 1);
end Previous;
function Chosen
(This : in Menu)
return FLTK.Menu_Items.Menu_Item_Reference is
begin
return (Data => This.My_Items.Element (This.Chosen_Index));
end Chosen;
function Chosen_Label
(This : in Menu)
return String
is
Ptr : Interfaces.C.Strings.chars_ptr := fl_menu_text (This.Void_Ptr);
begin
if Ptr = Interfaces.C.Strings.Null_Ptr then
return "";
else
-- no dealloc required?
return Interfaces.C.Strings.Value (Ptr);
end if;
end Chosen_Label;
function Chosen_Index
(This : in Menu)
return Extended_Index is
begin
return Extended_Index (fl_menu_value (This.Void_Ptr) + 1);
end Chosen_Index;
procedure Set_Chosen
(This : in out Menu;
Place : in Index)
is
Ignore_Ret : Interfaces.C.int;
begin
Ignore_Ret := fl_menu_set_value (This.Void_Ptr, Interfaces.C.int (Place) - 1);
end Set_Chosen;
procedure Set_Chosen
(This : in out Menu;
Item : in FLTK.Menu_Items.Menu_Item)
is
Ignore_Ret : Interfaces.C.int;
begin
Ignore_Ret := fl_menu_set_value2 (This.Void_Ptr, Wrapper (Item).Void_Ptr);
end Set_Chosen;
function Get_Text_Color
(This : in Menu)
return Color is
begin
return Color (fl_menu_get_textcolor (This.Void_Ptr));
end Get_Text_Color;
procedure Set_Text_Color
(This : in out Menu;
To : in Color) is
begin
fl_menu_set_textcolor (This.Void_Ptr, Interfaces.C.unsigned (To));
end Set_Text_Color;
function Get_Text_Font
(This : in Menu)
return Font_Kind is
begin
return Font_Kind'Val (fl_menu_get_textfont (This.Void_Ptr));
end Get_Text_Font;
procedure Set_Text_Font
(This : in out Menu;
To : in Font_Kind) is
begin
fl_menu_set_textfont (This.Void_Ptr, Font_Kind'Pos (To));
end Set_Text_Font;
function Get_Text_Size
(This : in Menu)
return Font_Size is
begin
return Font_Size (fl_menu_get_textsize (This.Void_Ptr));
end Get_Text_Size;
procedure Set_Text_Size
(This : in out Menu;
To : in Font_Size) is
begin
fl_menu_set_textsize (This.Void_Ptr, Interfaces.C.int (To));
end Set_Text_Size;
function Get_Down_Box
(This : in Menu)
return Box_Kind is
begin
return Box_Kind'Val (fl_menu_get_down_box (This.Void_Ptr));
end Get_Down_Box;
procedure Set_Down_Box
(This : in out Menu;
To : in Box_Kind) is
begin
fl_menu_set_down_box (This.Void_Ptr, Box_Kind'Pos (To));
end Set_Down_Box;
procedure Make_Global
(This : in out Menu) is
begin
fl_menu_global (This.Void_Ptr);
end Make_Global;
procedure Measure_Item
(This : in Menu;
Item : in Index;
W, H : out Integer) is
begin
W := Integer (fl_menu_measure
(This.Void_Ptr,
Interfaces.C.int (Item) - 1,
Interfaces.C.int (H)));
end Measure_Item;
function Popup
(This : in Menu;
X, Y : in Integer;
Title : in String := "";
Initial : in Extended_Index := No_Index)
return FLTK.Menu_Items.Menu_Item_Reference
is
Ptr : System.Address := fl_menu_popup
(This.Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.To_C (Title),
Interfaces.C.int (Initial) - 1);
Place : Index := Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
begin
return (Data => This.My_Items.Element (Place));
end Popup;
function Pulldown
(This : in Menu;
X, Y, W, H : in Integer;
Initial : in Extended_Index := No_Index)
return FLTK.Menu_Items.Menu_Item_Reference
is
Ptr : System.Address := fl_menu_pulldown
(This.Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Initial) - 1);
Place : Index := Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
begin
return (Data => This.My_Items.Element (Place));
end Pulldown;
procedure Draw_Item
(This : in out Menu;
Item : in Index;
X, Y, W, H : in Integer;
Selected : in Boolean := False) is
begin
fl_menu_draw_item
(This.Void_Ptr,
Interfaces.C.int (Item) - 1,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Boolean'Pos (Selected));
end Draw_Item;
function Handle
(This : in out Menu;
Event : in Event_Kind)
return Event_Outcome is
begin
return Not_Handled;
end Handle;
end FLTK.Widgets.Menus;
|
package body kv.avm.Actor_References is
use Interfaces;
Local_Domain : Interfaces.Unsigned_32 := 0;
----------------------------------------------------------------------------
procedure Set_Local_Domain(Domain : Interfaces.Unsigned_32) is
begin
Local_Domain := Domain;
end Set_Local_Domain;
----------------------------------------------------------------------------
function Get_Local_Domain return Interfaces.Unsigned_32 is
begin
return Local_Domain;
end Get_Local_Domain;
----------------------------------------------------------------------------
procedure Initialize
(Self : in out Actor_Reference_Type;
Key : in Interfaces.Unsigned_32;
Domain : in Interfaces.Unsigned_32 := Get_Local_Domain) is
begin
Self.Key := Key;
Self.Domain := Domain;
end Initialize;
----------------------------------------------------------------------------
function Get_Key(Self : Actor_Reference_Type) return Interfaces.Unsigned_32 is
begin
return Self.Key;
end Get_Key;
----------------------------------------------------------------------------
function Get_Domain(Self : Actor_Reference_Type) return Interfaces.Unsigned_32 is
begin
return Self.Domain;
end Get_Domain;
----------------------------------------------------------------------------
function Is_Local(Self : Actor_Reference_Type) return Boolean is
begin
return Self.Domain = Local_Domain;
end Is_Local;
----------------------------------------------------------------------------
function Image(Self : Actor_Reference_Type) return String is
Domain : constant String := Interfaces.Unsigned_32'IMAGE(Self.Domain);
use Interfaces;
begin
if Self.Key = Null_Reference.Key and Self.Domain = Null_Reference.Domain then
return " NULL_REFERENCE";
else
return Interfaces.Unsigned_32'IMAGE(Self.Key) & "@" & Domain(2..Domain'LAST);
end if;
end Image;
----------------------------------------------------------------------------
function "="(L, R : Actor_Reference_Type) return Boolean is
begin
return L.Domain = R.Domain and then L.Key = R.Key;
end "=";
----------------------------------------------------------------------------
function "<"(L, R : Actor_Reference_Type) return Boolean is
begin
return L.Domain < R. Domain or else (L.Domain = R.Domain and L.Key < R.Key);
end "<";
end kv.avm.Actor_References;
|
with Ada.Containers.Formal_Vectors;
-- with Ada.Containers.Formal_Hashed_Sets;
with Ada.Containers.Formal_Ordered_Sets;
with AVTAS.LMCP.Types; use AVTAS.LMCP.Types;
package Common_Formal_Containers with SPARK_Mode is
package Int64_Vects is new Ada.Containers.Formal_Vectors
(Index_Type => Natural,
Element_Type => Int64);
Int64_Vects_Common_Max_Capacity : constant := 200; -- arbitrary
subtype Int64_Vect is Int64_Vects.Vector (Int64_Vects_Common_Max_Capacity);
function Int64_Hash (X : Int64) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type'Mod (X));
-- pragma Assertion_Policy (Post => Ignore);
-- package Int64_Sets is new Ada.Containers.Formal_Hashed_Sets
-- (Element_Type => Int64,
-- Hash => Int64_Hash);
package Int64_Sets is new Ada.Containers.Formal_Ordered_Sets
(Element_Type => Int64);
-- pragma Assertion_Policy (Post => Suppressible);
Int64_Sets_Common_Max_Capacity : constant := 200; -- arbitrary, and shared among all instances but not necessarily
-- subtype Int64_Set is Int64_Sets.Set
-- (Int64_Sets_Common_Max_Capacity, Int64_Sets.Default_Modulus (Int64_Sets_Common_Max_Capacity));
subtype Int64_Set is Int64_Sets.Set
(Int64_Sets_Common_Max_Capacity);
end Common_Formal_Containers;
|
with System;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32.RNG is
-- Enable the TRNG
-- This requires some care:
-- 1) HSI48 must be on see: setup_pll.adb
-- 2) The CONDRST must be set with the CONFIGx params
-- 3) Then the CONDRST is SW set to low but will only become 0
-- after HW clears it.
-- 4) Finally, we enable the RNGEN in the block.
-- Failure to follow the procedure will yield no RND numbers
procedure Enable_Rng
is
-- Here we do some work to overlay the CR reg record
-- on a UInt32. Reason is, the datasheet makes it clear
-- that if you are to set the CONDRST then
-- simultaneously you need to write the CONFIGx vals also.
-- Thus we map it and make one write to Y which has the address
-- of the CR reg.
X : UInt32;
Cr : RNG_CR_Register;
for X'Address use Cr'Address;
CrAddr : System.Address := SEC_RNG_Periph.RNG_CR'Address;
Y : UInt32;
for Y'Address use CrAddr;
-- vvv some magic here.
-- We want a UInt32 to live on top of the DR
-- This was more an experiment than a requirement.
Z : System.Address := SEC_RNG_Periph.RNG_DR'Address;
Rval : UInt32;
for Rval'Address use Z;
RCC : aliased RCC_Peripheral
with Import, Address => S_NS_Periph (RCC_Base);
begin
RCC.AHB2ENR.RNGEN := True;
-- Per selection A
-- NISTC bit = 0
-- CONFIG1 = 8
-- CLKDIV = 0
-- CONFIG2 = 0
-- CONFIG3 = D
-- CED = 0
Cr.RNG_CONFIG1 := 8;
Cr.RNG_CONFIG3 := 16#D#;
Cr.CONDRST := True;
Y := X;
RNG.RNG_CR.CONDRST := False;
loop
exit when not SEC_RNG_Periph.RNG_CR.CONDRST;
end loop;
RNG.RNG_CR.RNGEN := True;
end Enable_Rng;
function Random return UInt32
is
begin
loop
exit when RNG.RNG_SR.DRDY;
end loop;
return RNG.RNG_DR;
end Random;
end STM32.RNG;
|
with Ada.Text_IO; use Ada.Text_IO;
with AWS.Client;
with AWS.Response;
procedure HTTP_Request is
begin
Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org")));
end HTTP_Request;
|
with Ada.Command_Line;
package body Command_Line with SPARK_Mode => Off is
function Argument (Number : Positive) return String
is
begin
return Ada.Command_Line.Argument (Number);
end Argument;
function Argument_Count return Natural
is
begin
return Ada.Command_Line.Argument_Count;
end Argument_Count;
procedure Set_Exit_Status (Code : Exit_Status)
is
begin
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Exit_Status (Code));
end Set_Exit_Status;
end Command_Line;
|
with Ada.Text_IO;
with Ada.Strings.Fixed;
with System.Storage_Elements; use System.Storage_Elements;
package body Offmt_Lib.Fmt_Data.Unsigned_Generic is
Size_In_Bytes : constant Natural := T'Size / 8;
package T_IO is new Ada.Text_IO.Modular_IO (T);
function Image (Val : T; Kind : Format_Kind) return String;
-----------
-- Image --
-----------
function Image (Val : T; Kind : Format_Kind) return String is
Result : String (1 .. (case Kind is
when Decimal => Size_In_Bytes * 2 + 4,
when Hexadecimal => Size_In_Bytes * 2 + 4,
when Binary => T'Size + 4));
begin
T_IO.Put (To => Result,
Item => Val,
Base => (case Kind is
when Decimal => 10,
when Hexadecimal => 16,
when Binary => 2));
case Kind is
when Decimal =>
return Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left);
when Hexadecimal =>
declare
Trim : constant String
:= Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left);
begin
-- Remove the '16#' and '#' from the hexadecimal image
return Trim (Trim'First + 3 .. Trim'Last - 1);
end;
when Binary =>
declare
Trim : constant String
:= Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left);
begin
-- Remove the '2#' and '#' from the binary image
return Trim (Trim'First + 2 .. Trim'Last - 1);
end;
end case;
end Image;
----------------
-- From_Frame --
----------------
overriding
procedure From_Frame (This : in out Instance;
Frame : in out Data_Frame)
is
function Shift_Left
(Value : T;
Amount : Natural) return T
with Import, Convention => Intrinsic;
Elt : Storage_Element;
begin
if Remaining (Frame) < Size_In_Bytes then
raise Frame_Error with "Frame too short for U" & T'Size'Img;
else
This.Val := 0;
for Cnt in 0 .. Size_In_Bytes - 1 loop
Elt := Pop (Frame);
This.Val := This.Val or Shift_Left (T (Elt), 8 * Cnt);
end loop;
end if;
end From_Frame;
------------
-- Format --
------------
overriding
function Format (This : Instance;
Kind : Format_Kind)
return String
is
begin
return Image (This.Val, Kind);
end Format;
---------
-- Put --
---------
overriding
procedure Put (This : Instance; Kind : Format_Kind) is
begin
Ada.Text_IO.Put (This.Format (Kind));
end Put;
-----------
-- Value --
-----------
function Value (This : Instance) return T is
begin
return This.Val;
end Value;
end Offmt_Lib.Fmt_Data.Unsigned_Generic;
|
-- { dg-do compile }
with System;
package SSO1 is
type R is record -- { dg-error "inconsistent with bit order" }
B : Boolean;
end record;
for R'Bit_Order use System.Low_Order_First;
for R'Scalar_Storage_Order use System.High_Order_First; -- { dg-warning "no component clause" }
type RW is record
B : Boolean;
end record;
for RW'Bit_Order use System.Low_Order_First;
for RW'Scalar_Storage_Order use System.Low_Order_First; -- { dg-warning "no component clause" }
end SSO1;
|
with Ada.Integer_Text_IO;
package body Afficher_Un_Entier is
procedure Afficher (N: in Integer) is
begin
Ada.Integer_Text_IO.Put (N, 1);
end;
end Afficher_Un_Entier;
|
package body Lto7_Pkg is
procedure op1 (this : Root) is begin null; end;
procedure op2 (this : DT) is begin null; end;
end Lto7_Pkg;
|
-- { dg-do compile }
with discr1; use discr1;
package body discr2 is
procedure Copy (Dataset : in out C_Type) is
Last_Char : Positive := 300;
begin
while (Last_Char > 40) loop
Last_Char := Last_Char - 1;
end loop;
Assign (Dataset.Designator (1 .. Last_Char));
end;
procedure Dummy is
begin
null;
end Dummy;
end discr2;
|
pragma License (Unrestricted);
with Ada.Exceptions;
package GNAT.Traceback.Symbolic is
pragma Preelaborate;
function Symbolic_Traceback (E : Ada.Exceptions.Exception_Occurrence)
return String
renames Ada.Exceptions.Exception_Information;
end GNAT.Traceback.Symbolic;
|
with Memory.Split; use Memory.Split;
with Memory.Join; use Memory.Join;
package body Test.Split is
procedure Run_Tests is
ram : constant Monitor_Pointer := Create_Monitor(0);
mon1 : constant Monitor_Pointer := Create_Monitor(0, False);
mon2 : constant Monitor_Pointer := Create_Monitor(0, False);
split : Split_Pointer := Create_Split;
join1 : constant Join_Pointer := Create_Join(split, 0);
join2 : constant Join_Pointer := Create_Join(split, 1);
begin
Set_Offset(split.all, 256);
Set_Memory(split.all, ram);
Set_Bank(split.all, 0, mon1);
Set_Bank(split.all, 1, mon2);
Set_Memory(mon1.all, join1);
Set_Memory(mon2.all, join2);
Check(ram.reads = 0);
Check(ram.writes = 0);
Check(Get_Cost(split.all) = Get_Cost(mon1.all) + Get_Cost(mon2.all));
Read(split.all, 0, 8);
Check(mon1.reads = 1);
Check(mon1.last_addr = 0);
Check(mon1.last_size = 8);
Check(mon2.reads = 0);
Check(ram.reads = 1);
Check(ram.last_addr = 0);
Check(ram.last_size = 8);
Read(split.all, 256, 8);
Check(mon1.reads = 1);
Check(mon1.last_addr = 0);
Check(mon1.last_size = 8);
Check(mon2.reads = 1);
Check(mon2.last_addr = 0);
Check(mon2.last_size = 8);
Check(ram.reads = 2);
Check(ram.last_addr = 256);
Check(ram.last_size = 8);
Write(split.all, 256, 8);
Check(mon1.writes = 0);
Check(mon2.writes = 1);
Check(ram.writes = 1);
Write(split.all, 0, 8);
Check(mon1.writes = 1);
Check(mon2.writes = 1);
Check(ram.writes = 2);
Idle(split.all, 10);
Check(mon1.cycles = 10);
Check(mon2.cycles = 10);
Check(ram.cycles = 10);
Read(split.all, 252, 8);
Check(mon1.reads = 2);
Check(mon2.reads = 2);
Check(ram.reads = 4);
Read(split.all, Address_Type(2) ** 32 - 4, 8);
Check(mon1.reads = 3);
Check(mon2.reads = 3);
Check(ram.reads = 6);
Read(split.all, Address_Type(2) ** 32 - 1, 1);
Check(mon1.reads = 3);
Check(mon2.reads = 4);
Check(ram.reads = 7);
Read(split.all, 255, 1);
Check(mon1.reads = 4);
Check(mon2.reads = 4);
Check(ram.reads = 8);
Read(split.all, 255, 2);
Check(mon1.reads = 5);
Check(mon2.reads = 5);
Check(ram.reads = 10);
Read(split.all, Address_Type(2) ** 32 - 1, 2);
Check(mon1.reads = 6);
Check(mon2.reads = 6);
Check(ram.reads = 12);
Check(Get_Time(ram.all) = Get_Time(split.all));
Destroy(Memory_Pointer(split));
end Run_Tests;
end Test.Split;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
private package CUPS.cups_array_h is
-- * "$Id: array.h 10996 2013-05-29 11:51:34Z msweet $"
-- *
-- * Sorted array definitions for CUPS.
-- *
-- * Copyright 2007-2010 by Apple Inc.
-- * Copyright 1997-2007 by Easy Software Products.
-- *
-- * These coded instructions, statements, and computer programs are the
-- * property of Apple Inc. and are protected by Federal copyright
-- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
-- * which should have been included with this file. If this file is
-- * file is missing or damaged, see the license at "http://www.cups.org/".
-- *
-- * This file is subject to the Apple OS-Developed Software exception.
--
-- * Include necessary headers...
--
-- * C++ magic...
--
-- * Types and structures...
--
-- skipped empty struct u_cups_array_s
-- skipped empty struct cups_array_t
--*** CUPS array type ***
type cups_array_func_t is access function
(arg1 : System.Address;
arg2 : System.Address;
arg3 : System.Address) return int;
pragma Convention (C, cups_array_func_t); -- cups/array.h:44
--*** Array comparison function ***
type cups_ahash_func_t is access function (arg1 : System.Address; arg2 : System.Address) return int;
pragma Convention (C, cups_ahash_func_t); -- cups/array.h:46
--*** Array hash function ***
type cups_acopy_func_t is access function (arg1 : System.Address; arg2 : System.Address) return System.Address;
pragma Convention (C, cups_acopy_func_t); -- cups/array.h:48
--*** Array element copy function ***
type cups_afree_func_t is access procedure (arg1 : System.Address; arg2 : System.Address);
pragma Convention (C, cups_afree_func_t); -- cups/array.h:50
--*** Array element free function ***
-- * Functions...
--
-- * "$Id: array.h 10996 2013-05-29 11:51:34Z msweet $"
-- *
-- * Sorted array definitions for CUPS.
-- *
-- * Copyright 2007-2010 by Apple Inc.
-- * Copyright 1997-2007 by Easy Software Products.
-- *
-- * These coded instructions, statements, and computer programs are the
-- * property of Apple Inc. and are protected by Federal copyright
-- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
-- * which should have been included with this file. If this file is
-- * file is missing or damaged, see the license at "http://www.cups.org/".
-- *
-- * This file is subject to the Apple OS-Developed Software exception.
--
function cupsArrayAdd (a : System.Address; e : System.Address) return int; -- cups/array.h:58
pragma Import (C, cupsArrayAdd, "cupsArrayAdd");
procedure cupsArrayClear (a : System.Address); -- cups/array.h:59
pragma Import (C, cupsArrayClear, "cupsArrayClear");
function cupsArrayCount (a : System.Address) return int; -- cups/array.h:60
pragma Import (C, cupsArrayCount, "cupsArrayCount");
function cupsArrayCurrent (a : System.Address) return System.Address; -- cups/array.h:61
pragma Import (C, cupsArrayCurrent, "cupsArrayCurrent");
procedure cupsArrayDelete (a : System.Address); -- cups/array.h:62
pragma Import (C, cupsArrayDelete, "cupsArrayDelete");
function cupsArrayDup (a : System.Address) return System.Address; -- cups/array.h:63
pragma Import (C, cupsArrayDup, "cupsArrayDup");
function cupsArrayFind (a : System.Address; e : System.Address) return System.Address; -- cups/array.h:64
pragma Import (C, cupsArrayFind, "cupsArrayFind");
function cupsArrayFirst (a : System.Address) return System.Address; -- cups/array.h:65
pragma Import (C, cupsArrayFirst, "cupsArrayFirst");
function cupsArrayGetIndex (a : System.Address) return int; -- cups/array.h:66
pragma Import (C, cupsArrayGetIndex, "cupsArrayGetIndex");
function cupsArrayGetInsert (a : System.Address) return int; -- cups/array.h:67
pragma Import (C, cupsArrayGetInsert, "cupsArrayGetInsert");
function cupsArrayIndex (a : System.Address; n : int) return System.Address; -- cups/array.h:68
pragma Import (C, cupsArrayIndex, "cupsArrayIndex");
function cupsArrayInsert (a : System.Address; e : System.Address) return int; -- cups/array.h:69
pragma Import (C, cupsArrayInsert, "cupsArrayInsert");
function cupsArrayLast (a : System.Address) return System.Address; -- cups/array.h:70
pragma Import (C, cupsArrayLast, "cupsArrayLast");
function cupsArrayNew (f : cups_array_func_t; d : System.Address) return System.Address; -- cups/array.h:71
pragma Import (C, cupsArrayNew, "cupsArrayNew");
function cupsArrayNew2
(f : cups_array_func_t;
d : System.Address;
h : cups_ahash_func_t;
hsize : int) return System.Address; -- cups/array.h:72
pragma Import (C, cupsArrayNew2, "cupsArrayNew2");
function cupsArrayNew3
(f : cups_array_func_t;
d : System.Address;
h : cups_ahash_func_t;
hsize : int;
cf : cups_acopy_func_t;
ff : cups_afree_func_t) return System.Address; -- cups/array.h:74
pragma Import (C, cupsArrayNew3, "cupsArrayNew3");
function cupsArrayNext (a : System.Address) return System.Address; -- cups/array.h:78
pragma Import (C, cupsArrayNext, "cupsArrayNext");
function cupsArrayPrev (a : System.Address) return System.Address; -- cups/array.h:79
pragma Import (C, cupsArrayPrev, "cupsArrayPrev");
function cupsArrayRemove (a : System.Address; e : System.Address) return int; -- cups/array.h:80
pragma Import (C, cupsArrayRemove, "cupsArrayRemove");
function cupsArrayRestore (a : System.Address) return System.Address; -- cups/array.h:81
pragma Import (C, cupsArrayRestore, "cupsArrayRestore");
function cupsArraySave (a : System.Address) return int; -- cups/array.h:82
pragma Import (C, cupsArraySave, "cupsArraySave");
function cupsArrayUserData (a : System.Address) return System.Address; -- cups/array.h:83
pragma Import (C, cupsArrayUserData, "cupsArrayUserData");
-- * End of "$Id: array.h 10996 2013-05-29 11:51:34Z msweet $".
--
end CUPS.cups_array_h;
|
package Hide.File_Coder is
procedure Encode (Source_File_Name : Posix.C_String;
Output_File_Name : Posix.C_String;
Offset : Natural;
Text : String);
function Decode (File_Name : Posix.C_String) return String;
end Hide.File_Coder;
|
-----------------------------------------------------------------------
-- util-serialize-io-xml -- XML Serialization Driver
-- Copyright (C) 2011, 2012, 2016, 2017, 2020, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Sax.Exceptions;
with Sax.Locators;
with Sax.Readers;
with Sax.Attributes;
with Unicode.CES;
with Input_Sources;
with Ada.Streams;
with Ada.Strings.Unbounded;
with Util.Streams.Buffered;
with Util.Streams.Texts;
package Util.Serialize.IO.XML is
Parse_Error : exception;
type Parser is new Serialize.IO.Parser with private;
-- Parse the stream using the JSON parser.
procedure Parse (Handler : in out Parser;
Stream : in out Util.Streams.Buffered.Input_Buffer_Stream'Class;
Sink : in out Reader'Class);
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
procedure Set_Ignore_White_Spaces (Reader : in out Parser;
Value : in Boolean);
-- Set the XHTML reader to ignore empty lines.
procedure Set_Ignore_Empty_Lines (Reader : in out Parser;
Value : in Boolean);
-- Get the current location (file and line) to report an error message.
function Get_Location (Handler : in Parser) return String;
type Xhtml_Reader is new Sax.Readers.Reader with private;
-- ------------------------------
-- XML Output Stream
-- ------------------------------
-- The <b>Output_Stream</b> provides methods for creating an XML output stream.
-- The stream object takes care of the XML escape rules.
type Output_Stream is limited new Util.Serialize.IO.Output_Stream with private;
-- Set the target output stream.
procedure Initialize (Stream : in out Output_Stream;
Output : in Util.Streams.Texts.Print_Stream_Access);
-- Flush the buffer (if any) to the sink.
overriding
procedure Flush (Stream : in out Output_Stream);
-- Close the sink.
overriding
procedure Close (Stream : in out Output_Stream);
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Write a character on the response stream and escape that character as necessary.
procedure Write_Escape (Stream : in out Output_Stream'Class;
Char : in Wide_Wide_Character);
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
procedure Write_String (Stream : in out Output_Stream;
Value : in String);
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
procedure Write_Wide_String (Stream : in out Output_Stream;
Value : in Wide_Wide_String);
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
procedure Write_String (Stream : in out Output_Stream;
Value : in Util.Beans.Objects.Object);
-- Start a new XML object.
procedure Start_Entity (Stream : in out Output_Stream;
Name : in String);
-- Terminates the current XML object.
procedure End_Entity (Stream : in out Output_Stream;
Name : in String);
-- Write the attribute name/value pair.
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String);
overriding
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String);
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer);
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean);
-- Write a XML name/value attribute.
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Write the attribute with a null value.
overriding
procedure Write_Null_Attribute (Stream : in out Output_Stream;
Name : in String);
-- Write the entity value.
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String);
overriding
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time);
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer);
overriding
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String);
-- Write a XML name/value entity (see Write_Attribute).
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Write an entity with a null value.
overriding
procedure Write_Null_Entity (Stream : in out Output_Stream;
Name : in String);
-- Starts a XML array.
overriding
procedure Start_Array (Stream : in out Output_Stream;
Name : in String);
-- Terminates a XML array.
overriding
procedure End_Array (Stream : in out Output_Stream;
Name : in String);
-- Set the indentation level when writing XML entities.
procedure Set_Indentation (Stream : in out Output_Stream;
Count : in Natural);
-- Return the location where the exception was raised.
function Get_Location (Except : Sax.Exceptions.Sax_Parse_Exception'Class)
return String;
private
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class);
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class);
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class);
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator);
overriding
procedure Start_Document (Handler : in out Xhtml_Reader);
overriding
procedure End_Document (Handler : in out Xhtml_Reader);
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence);
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence);
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class);
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "");
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence);
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence);
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence);
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence);
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader);
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader);
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "");
procedure Collect_Text (Handler : in out Xhtml_Reader;
Content : Unicode.CES.Byte_Sequence);
type Xhtml_Reader is new Sax.Readers.Reader with record
Stack_Pos : Natural := 0;
Handler : access Parser'Class;
Text : Ada.Strings.Unbounded.Unbounded_String;
-- Whether white spaces can be ignored.
Ignore_White_Spaces : Boolean := True;
-- Whether empty lines should be ignored (when white spaces are kept).
Ignore_Empty_Lines : Boolean := True;
Sink : access Reader'Class;
end record;
type Parser is new Util.Serialize.IO.Parser with record
-- The SAX locator to find the current file and line number.
Locator : Sax.Locators.Locator;
Has_Pending_Char : Boolean := False;
Pending_Char : Character;
-- Whether white spaces can be ignored.
Ignore_White_Spaces : Boolean := True;
-- Whether empty lines should be ignored (when white spaces are kept).
Ignore_Empty_Lines : Boolean := True;
end record;
type Output_Stream is limited new Util.Serialize.IO.Output_Stream with record
Close_Start : Boolean := False;
Is_Closed : Boolean := False;
Level : Natural := 0;
Indent : Natural := 0;
Stream : Util.Streams.Texts.Print_Stream_Access;
end record;
end Util.Serialize.IO.XML;
|
package Aggr19_Pkg is
type Rec1 (D : Boolean := False) is record
case D is
when False => null;
when True => Pos : Integer;
end case;
end record;
type Rec2 is record
L : Rec1;
end record;
type Rec3 is tagged null record;
type Enum is (One, Two, Three);
type Rec4 (Kind : Enum := One) is record
Node : Rec2;
case Kind is
when One => R : Rec3;
when Others => I : Integer;
end case;
end record;
type Rec5 is record
Ent : Rec4;
end record;
procedure Proc (Pool : in out Rec5);
end Aggr19_Pkg;
|
-- Copyright 2018-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Vectors; use Ada.Containers;
with Ada.Strings.Unbounded.Hash;
with Ada.Containers.Hashed_Maps;
with DOM.Readers; use DOM.Readers;
with Game; use Game;
-- ****h* Stories/Stories
-- FUNCTION
-- Provide code for manipulate the game stories
-- SOURCE
package Stories is
-- ****
-- ****t* Stories/Stories.StartConditionType
-- FUNCTION
-- Types of conditions to start stories
-- SOURCE
type StartConditionType is (DROPITEM) with
Default_Value => DROPITEM;
-- ****
-- ****t* Stories/Stories.StepConditionType
-- FUNCTION
-- Types of conditions to finish story step
-- SOURCE
type StepConditionType is (ASKINBASE, DESTROYSHIP, EXPLORE, ANY, LOOT) with
Default_Value => ANY;
-- ****
-- ****s* Stories/Stories.StepText_Data
-- FUNCTION
-- Data structure for stories steps texts
-- PARAMETERS
-- Condition - Finish condition of previous step
-- Text - Text which will be show to player when step starts.
-- SOURCE
type StepText_Data is record
Condition: StepConditionType;
Text: Unbounded_String;
end record;
-- ****
-- ****t* Stories/Stories.StepTexts_Container
-- FUNCTION
-- Used to store stories steps text data
-- SOURCE
package StepTexts_Container is new Vectors(Positive, StepText_Data);
-- ****
-- ****s* Stories/Stories.StepFinish_Data
-- FUNCTION
-- Structure for finish condition data
-- PARAMETERS
-- Name - Name of data
-- Value - Value of data
-- SOURCE
type StepFinish_Data is record
Name: Unbounded_String;
Value: Unbounded_String;
end record;
-- ****
-- ****t* Stories/Stories.StepData_Container
-- FUNCTION
-- Used to store stories steps data
-- SOURCE
package StepData_Container is new Vectors(Positive, StepFinish_Data);
-- ****
-- ****s* Stories/Stories.Step_Data
-- FUNCTION
-- Data structure for stories steps
-- PARAMETERS
-- Index - Index of step
-- FinishCondition - Condition which must be met to finish selected step
-- and process to next
-- FinishData - Data for finish condition
-- Texts - Texts which will be show to player when step starts,
-- depends on finish condition of previous step.
-- FailText - Text which will be show to player when step fails to
-- progress.
-- SOURCE
type Step_Data is record
Index: Unbounded_String;
FinishCondition: StepConditionType;
FinishData: StepData_Container.Vector;
Texts: StepTexts_Container.Vector;
FailText: Unbounded_String;
end record;
-- ****
-- ****t* Stories/Stories.Steps_Container
-- FUNCTION
-- Used to store stories steps
-- SOURCE
package Steps_Container is new Vectors(Positive, Step_Data);
-- ****
-- ****s* Stories/Stories.Story_Data
-- FUNCTION
-- Data structure for stories
-- PARAMETERS
-- StartCondition - Condition which must be met to start story
-- StartData - Data for starting condition
-- MinSteps - Minimal amount of steps in story
-- MaxSteps - Maxium amount of steps in story
-- StartingStep - Starting step of story
-- Steps - Contains all steps in story
-- FinalStep - Final step of story
-- EndText - Text which will be show to player when story ends.
-- Name - Name of story, show in game
-- ForbiddenFactions - If player is in one of this factions, he/she can't
-- start this story.
-- SOURCE
type Story_Data is record
StartCondition: StartConditionType;
StartData: UnboundedString_Container.Vector;
MinSteps: Positive := 1;
MaxSteps: Positive := 1;
StartingStep: Step_Data;
Steps: Steps_Container.Vector;
FinalStep: Step_Data;
EndText: Unbounded_String;
Name: Unbounded_String;
ForbiddenFactions: UnboundedString_Container.Vector;
end record;
-- ****
-- ****t* Stories/Stories.Stories_Container
-- FUNCTION
-- Used to store stories
-- SOURCE
package Stories_Container is new Hashed_Maps
(Unbounded_String, Story_Data, Ada.Strings.Unbounded.Hash, "=");
-- ****
-- ****s* Stories/Stories.CurrentStory_Data
-- FUNCTION
-- Data structure for current active story
-- PARAMETERS
-- Index - Index of story or empty string if no story currently
-- active
-- Step - Number of current step in story
-- CurrentStep - Index of current step, 0 for starting step, -1 for finish
-- step
-- MaxSteps - Number of maxium amounts of steps in story
-- ShowText - If true, show text of current step to player
-- Data - Various data for current step, depends on step
-- FinishedStep - Finish condition for previous step
-- SOURCE
type CurrentStory_Data is record
Index: Unbounded_String;
Step: Positive := 1;
CurrentStep: Integer range -3 .. Integer'Last;
MaxSteps: Positive := 1;
ShowText: Boolean;
Data: Unbounded_String;
FinishedStep: StepConditionType;
end record;
-- ****
-- ****s* Stories/Stories.FinishedStory_Data
-- FUNCTION
-- Data structure for finished story/steps
-- PARAMETERS
-- Index - Index of story
-- StepsAmount - Amount of steps in this story
-- StepsTexts - Texts of steps done in this story. If less than
-- StepsAmount then it is current story.
-- SOURCE
type FinishedStory_Data is record
Index: Unbounded_String;
StepsAmount: Positive := 1;
StepsTexts: UnboundedString_Container.Vector;
end record;
-- ****
-- ****t* Stories/Stories.FinishedStories_Container
-- FUNCTIONS
-- Used to store finished stories
-- SOURCE
package FinishedStories_Container is new Vectors
(Positive, FinishedStory_Data);
-- ****
-- ****v* Stories/Stories.CurrentStory
-- FUNCTION
-- Contains data about current story on which player is
-- SOURCE
CurrentStory: CurrentStory_Data;
-- ****
-- ****v* Stories/Stories.Stories_List
-- FUNCTION
-- List of available stories in game
-- SOURCE
Stories_List: Stories_Container.Map;
-- ****
-- ****v* Stories/Stories.FinishedStories
-- FUNCTION
-- List of finished stories (or past data of current story)
-- SOURCE
FinishedStories: FinishedStories_Container.Vector;
-- ****
-- ****f* Stories/Stories.LoadStories
-- FUNCTION
-- Load stories data from files
-- PARAMETERS
-- Reader - XML Reader from which data will be read
-- SOURCE
procedure LoadStories(Reader: Tree_Reader);
-- ****
-- ****f* Stories/Stories.StartStory
-- FUNCTION
-- Check if any story can starts
-- PARAMETERS
-- FactionName - Name of faction to which players belongs
-- Condition - Starting condition which was triggered
-- SOURCE
procedure StartStory
(FactionName: Unbounded_String; Condition: StartConditionType) with
Pre => FactionName /= Null_Unbounded_String,
Test_Case => (Name => "Test_StartStory", Mode => Nominal);
-- ****
-- ****f* Stories/Stories.ClearCurrentStory
-- FUNCTION
-- Resets current story
-- SOURCE
procedure ClearCurrentStory with
Post => CurrentStory.Index = Null_Unbounded_String,
Test_Case => (Name => "Test_ClearCurrentStory", Mode => Nominal);
-- ****
-- ****f* Stories/Stories.ProgressStory
-- FUNCTION
-- Progress current story one step
-- PARAMETERS
-- NextStep - Used with DESTROYSHIP condition. If false, progress to the
-- next step in story. Default is false.
-- RESULT
-- True if story goes to next step, otherwise false
-- SOURCE
function ProgressStory(NextStep: Boolean := False) return Boolean with
Test_Case => (Name => "Test_ProgressStory", Mode => Robustness);
-- ****
-- ****f* Stories/Stories.GetCurrentStoryText
-- FUNCTION
-- Get text of current step in story
-- RESULT
-- Text of current step in current story
-- SOURCE
function GetCurrentStoryText return Unbounded_String with
Test_Case => (Name => "Tets_GetCurrentStoryText", Mode => Robustness);
-- ****
-- ****f* Stories/Stories.GetStepData
-- FUNCTION
-- Get step finish data with selected name
-- PARAMETERS
-- FinishData - List of step data
-- Name - Name of data to get
-- RESULT
-- Selected data from FinishData parameter
-- SOURCE
function GetStepData
(FinishData: StepData_Container.Vector; Name: String)
return Unbounded_String with
Pre => Name'Length > 0,
Test_Case => (Name => "Test_GetStepData", Mode => Nominal);
-- ****
-- ****f* Stories/Stories.GetStoryLocation
-- FUNCTION
-- Get target location of current story
-- PARAMETERS
-- StoryX - X coordination of current story target
-- StoryY - Y coordination of current story target
-- RESULT
-- Parameters X and Y
-- SOURCE
procedure GetStoryLocation
(StoryX: out Map_X_Range; StoryY: out Map_Y_Range) with
Test_Case => (Name => "Test_GetStoryLocation", Mode => Robustness);
-- ****
end Stories;
|
-- { dg-do compile }
-- { dg-options "-O2 -fno-inline -fdump-tree-optimized" }
procedure Opt39 (I : Integer) is
type Rec is record
I1 : Integer;
I2 : Integer;
I3 : Integer;
I4 : Integer;
I5 : Integer;
end record;
procedure Set (A : access Rec; I : Integer) is
Tmp : Rec := A.all;
begin
Tmp.I1 := I;
A.all := Tmp;
end;
R : aliased Rec;
begin
Set (R'Access, I);
if R.I1 /= I then
raise Program_Error;
end if;
end;
-- { dg-final { scan-tree-dump-times "MEM" 1 "optimized" } }
|
-- The Village of Vampire by YT, このソースコードはNYSLです
package body Tabula.Casts is
use type Ada.Strings.Unbounded.Unbounded_String;
function Find (Container : Groups.Vector; Group : Integer)
return Groups.Cursor is
begin
for I in Container.First_Index .. Container.Last_Index loop
if Container.Constant_Reference (I).Group = Group then
return I;
end if;
end loop;
return Groups.No_Element;
end Find;
function Is_Empty (Item : Person) return Boolean is
begin
return Item.Name.Is_Null;
end Is_Empty;
function Is_Empty (Item : Work) return Boolean is
begin
return Item.Name.Is_Null;
end Is_Empty;
function Find (Works : Casts.Works.Vector; Name : String)
return Casts.Works.Cursor is
begin
for I in Works.First_Index .. Works.Last_Index loop
if Works.Constant_Reference (I).Name = Name then
return I;
end if;
end loop;
return Casts.Works.No_Element;
end Find;
procedure Exclude_Person (
Cast : in out Casts.Cast_Collection;
Name : in String;
Group : in Integer) is
begin
for IP in Cast.People.First_Index .. Cast.People.Last_Index loop
if Cast.People.Constant_Reference (IP).Name = Name
or else Cast.People.Constant_Reference (IP).Group /= Group
then
Cast.People.Reference(IP).Name := Ada.Strings.Unbounded.Null_Unbounded_String;
end if;
end loop;
end Exclude_Person;
procedure Exclude_Work (
Cast : in out Casts.Cast_Collection;
Name : in String) is
begin
for IW in Cast.Works.First_Index .. Cast.Works.Last_Index loop
if Cast.Works.Constant_Reference(IW).Name = Name then
Cast.Works.Reference(IW).Name := Ada.Strings.Unbounded.Null_Unbounded_String;
exit;
end if;
end loop;
end Exclude_Work;
end Tabula.Casts;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, 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 Ada.Unchecked_Deallocation;
with Web_Services.SOAP.Constants;
with Web_Services.SOAP.Headers.Decoders.Registry;
with Web_Services.SOAP.Payloads.Decoders.Registry;
with Web_Services.SOAP.Payloads.Faults.Simple;
package body Web_Services.SOAP.Message_Decoders is
use Web_Services.SOAP.Constants;
use type League.Strings.Universal_String;
procedure Free is
new Ada.Unchecked_Deallocation
(Web_Services.SOAP.Payloads.Decoders.SOAP_Payload_Decoder'Class,
Web_Services.SOAP.Payloads.Decoders.SOAP_Payload_Decoder_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Web_Services.SOAP.Headers.Decoders.SOAP_Header_Decoder'Class,
Web_Services.SOAP.Headers.Decoders.SOAP_Header_Decoder_Access);
procedure Set_Sender_Fault
(Self : in out SOAP_Message_Decoder'Class;
Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String);
-- Sets error state with specified diagnosis and creates env:Sender fault
-- message.
procedure Set_Must_Understand_Error
(Self : in out SOAP_Message_Decoder'Class;
Diagnosis : League.Strings.Universal_String);
-- Sets error state with specified diagnosis and creates env:MustUnderstand
-- fault message.
procedure Set_Version_Mismatch_Fault
(Self : in out SOAP_Message_Decoder'Class;
Diagnosis : League.Strings.Universal_String);
-- Sets error state with specified diagnosis and creates
-- env:VersionMismatch fault message.
procedure Check_No_SOAP_Encoding_Style_Attribute
(Self : in out SOAP_Message_Decoder'Class;
Local_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Checks that encodingStyle attribute is not present in the given set of
-- attributes.
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out SOAP_Message_Decoder;
Text : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.State = Header_Element and then Self.Depth /= 0 then
Self.Header_Decoder.Characters (Text, Success);
if not Success then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Message header decoder reports error"));
return;
end if;
elsif Self.State = Body_Element and then Self.Depth /= 0 then
Self.Payload_Decoder.Characters (Text, Success);
if not Success then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Message body decoder reports error"));
return;
end if;
end if;
end Characters;
--------------------------------------------
-- Check_No_SOAP_Encoding_Style_Attribute --
--------------------------------------------
procedure Check_No_SOAP_Encoding_Style_Attribute
(Self : in out SOAP_Message_Decoder'Class;
Local_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean) is
begin
for J in 1 .. Attributes.Length loop
if Attributes.Namespace_URI (J) = SOAP_Envelope_URI
and Attributes.Local_Name (J) = SOAP_Encoding_Style_Name
then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Incorrect SOAP Body element serialization"),
"SOAP "
& Local_Name
& " must not have encodingStyle attribute information item.");
Success := False;
return;
end if;
end loop;
end Check_No_SOAP_Encoding_Style_Attribute;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out SOAP_Message_Decoder;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean) is
begin
case Self.State is
when Initial =>
-- Must never be happen.
raise Program_Error;
when Header_Ignore | Body_Ignore =>
-- Decrement depth of ignore element counter.
Self.Depth := Self.Depth - 1;
if Self.Depth = 0 then
-- Change state of decoder on leave of root element.
if Self.State = Header_Ignore then
Self.State := SOAP_Header;
elsif Self.State = Body_Ignore then
Self.State := SOAP_Body;
end if;
end if;
when SOAP_Envelope =>
Self.State := Initial;
when SOAP_Header =>
Self.State := SOAP_Envelope;
when SOAP_Body =>
Self.State := SOAP_Envelope;
when Header_Element =>
-- Decrement depth of nesting XML elements in Header element.
Self.Depth := Self.Depth - 1;
-- Redirect processing to decoder.
Self.Header_Decoder.End_Element
(Namespace_URI, Local_Name, Success);
-- Obtain decoded data.
if Self.Depth = 0 then
declare
Header : constant
Web_Services.SOAP.Headers.SOAP_Header_Access
:= Self.Header_Decoder.Header;
begin
Self.Message.Headers.Insert (Header);
Free (Self.Header_Decoder);
Self.State := SOAP_Header;
end;
end if;
when Body_Element =>
-- Decrement depth of nesting XML elements in Body element.
Self.Depth := Self.Depth - 1;
-- Redirect processing to decoder.
Self.Payload_Decoder.End_Element
(Namespace_URI, Local_Name, Success);
if not Success then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Message body decoder reports error"));
return;
end if;
-- Obtain decoded data.
if Self.Depth = 0 then
Self.Message.Payload := Self.Payload_Decoder.Payload;
Self.Message.Namespace_URI := Namespace_URI;
Self.Message.Local_Name := Local_Name;
Free (Self.Payload_Decoder);
Self.State := SOAP_Body;
end if;
end case;
end End_Element;
-----------
-- Error --
-----------
overriding procedure Error
(Self : in out SOAP_Message_Decoder;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception;
Success : in out Boolean) is
begin
Self.Fatal_Error (Occurrence);
Success := False;
end Error;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : SOAP_Message_Decoder) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
-- This parameter is not used, but defined by profile of overloaded
-- subprogram.
begin
return
League.Strings.To_Universal_String
("Unknown error in SOAP message decoder");
end Error_String;
-----------------
-- Fatal_Error --
-----------------
overriding procedure Fatal_Error
(Self : in out SOAP_Message_Decoder;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception) is
begin
-- Set error message only when there is no previous error message was
-- set.
if Self.Success then
Self.Set_Sender_Fault ("XML error: " & Occurrence.Message);
end if;
end Fatal_Error;
-------------
-- Message --
-------------
function Message
(Self : SOAP_Message_Decoder'Class)
return Web_Services.SOAP.Messages.SOAP_Message_Access is
begin
return Self.Message;
end Message;
----------------------------
-- Processing_Instruction --
----------------------------
overriding procedure Processing_Instruction
(Self : in out SOAP_Message_Decoder;
Target : League.Strings.Universal_String;
Data : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Target);
pragma Unreferenced (Data);
-- These parameters is not used, but defined by profile of overloaded
-- subprogram.
begin
-- [SOAP12] 5. SOAP Message Construct
--
-- "SOAP messages sent by initial SOAP senders MUST NOT contain
-- processing instruction information items. SOAP intermediaries MUST
-- NOT insert processing instruction information items in SOAP messages
-- they relay. SOAP receivers receiving a SOAP message containing a
-- processing instruction information item SHOULD generate a SOAP fault
-- with the Value of Code set to "env:Sender"."
if Self.Mode = Strict then
-- This assertion is checked in strict mode only; otherwise Test:T26
-- testcase of SOAP Conformance Testsuite is failed.
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("SOAP message must not contain processing instruction"));
Success := False;
end if;
end Processing_Instruction;
-------------------------------
-- Set_Must_Understand_Error --
-------------------------------
procedure Set_Must_Understand_Error
(Self : in out SOAP_Message_Decoder'Class;
Diagnosis : League.Strings.Universal_String) is
begin
-- Deallocate decoded SOAP message if any.
Web_Services.SOAP.Messages.Free (Self.Message);
Free (Self.Payload_Decoder);
-- Set error state.
Self.Success := False;
-- Create env:MustUnderstand fault reply.
Self.Message :=
new Web_Services.SOAP.Messages.SOAP_Message'
(Action => <>,
Namespace_URI => <>,
Local_Name => <>,
Output => null,
Headers => <>,
Payload =>
Web_Services.SOAP.Payloads.Faults.Simple
.Create_Must_Understand_Fault (XML_EN_US_Code, Diagnosis));
end Set_Must_Understand_Error;
----------------------
-- Set_Sender_Fault --
----------------------
procedure Set_Sender_Fault
(Self : in out SOAP_Message_Decoder'Class;
Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String) is
begin
-- Deallocate decoded SOAP message if any.
Web_Services.SOAP.Messages.Free (Self.Message);
Free (Self.Payload_Decoder);
-- Set error state and diagnosis.
Self.Success := False;
-- Create env:Sender fault reply.
Self.Message :=
new Web_Services.SOAP.Messages.SOAP_Message'
(Action => <>,
Namespace_URI => <>,
Local_Name => <>,
Output => null,
Headers => <>,
Payload =>
Web_Services.SOAP.Payloads.Faults.Simple.Create_Sender_Fault
(XML_EN_US_Code, Text, Detail));
end Set_Sender_Fault;
--------------------------------
-- Set_Version_Mismatch_Fault --
--------------------------------
procedure Set_Version_Mismatch_Fault
(Self : in out SOAP_Message_Decoder'Class;
Diagnosis : League.Strings.Universal_String) is
begin
-- Deallocate decoded SOAP message if any.
Web_Services.SOAP.Messages.Free (Self.Message);
Free (Self.Payload_Decoder);
-- Set error state and diagnosis.
Self.Success := False;
-- Create env:VersionMismatch fault reply.
Self.Message :=
new Web_Services.SOAP.Messages.SOAP_Message'
(Action => <>,
Namespace_URI => <>,
Local_Name => <>,
Output => null,
Headers => <>,
Payload =>
Web_Services.SOAP.Payloads.Faults.Simple
.Create_Version_Mismatch_Fault (XML_EN_US_Code, Diagnosis));
end Set_Version_Mismatch_Fault;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out SOAP_Message_Decoder;
Success : in out Boolean)
is
pragma Unreferenced (Success);
-- This parameter is not used, but defined by profile of overloaded
-- subprogram.
begin
Self.Message := new Web_Services.SOAP.Messages.SOAP_Message;
end Start_Document;
---------------
-- Start_DTD --
---------------
overriding procedure Start_DTD
(Self : in out SOAP_Message_Decoder;
Name : League.Strings.Universal_String;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Name);
pragma Unreferenced (Public_Id);
pragma Unreferenced (System_Id);
-- These parameters are not used but defined by profile of overrided
-- subprogram.
begin
-- [SOAP12P1] 5. SOAP Message Construct
--
-- "The XML infoset of a SOAP message MUST NOT contain a document type
-- declaration information item."
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("DTD are not supported by SOAP 1.2"));
Success := False;
end Start_DTD;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out SOAP_Message_Decoder;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
use type Web_Services.SOAP.Payloads.Decoders.SOAP_Payload_Decoder_Access;
use type Web_Services.SOAP.Headers.Decoders.SOAP_Header_Decoder_Access;
begin
case Self.State is
when Initial =>
if Namespace_URI = SOAP_Envelope_URI then
if Local_Name = SOAP_Envelope_Name then
-- The encodingStyle attribute MUST NOT appear in SOAP
-- Envelope element.
Self.Check_No_SOAP_Encoding_Style_Attribute
(Local_Name, Attributes, Success);
if not Success then
return;
end if;
end if;
elsif Local_Name = SOAP_Envelope_Name then
-- Root element has correct name, but unknown namespace; report
-- env:VersionMismatch fault.
Self.Set_Version_Mismatch_Fault
(League.Strings.To_Universal_String ("Wrong Version"));
Success := False;
return;
end if;
Self.State := SOAP_Envelope;
when Header_Ignore | Body_Ignore =>
-- Each children element of unknown element increments element
-- ignore counter to proper handling of arbitrary depth of
-- elements.
Self.Depth := Self.Depth + 1;
when SOAP_Envelope =>
if Namespace_URI = SOAP_Envelope_URI then
if Local_Name = SOAP_Header_Name then
-- "Header" element is processed now.
Self.State := SOAP_Header;
elsif Local_Name = SOAP_Body_Name then
-- The encodingStyle attribute MUST NOT appear in SOAP Body
-- element.
Self.Check_No_SOAP_Encoding_Style_Attribute
(Local_Name, Attributes, Success);
if not Success then
return;
end if;
-- Switch state to process content of SOAP Body element.
Self.State := SOAP_Body;
else
Self.Set_Sender_Fault
("Unexpected element {" & Namespace_URI & "}" & Local_Name);
end if;
else
Self.Set_Sender_Fault
("Unexpected element {" & Namespace_URI & "}" & Local_Name);
end if;
when SOAP_Header =>
-- SOAP Header element has been processed, currect element is its
-- child. Appropriate decoder must be created to continue
-- processing.
Self.Header_Decoder :=
Web_Services.SOAP.Headers.Decoders.Registry.Resolve
(Namespace_URI);
-- [SOAP1.2] 5.2.3 SOAP mustUnderstand Attribute
--
-- "Omitting this attribute information item is defined as being
-- semantically equivalent to including it with a value of
-- "false".
--
-- SOAP senders SHOULD NOT generate, but SOAP receivers MUST
-- accept, the SOAP mustUnderstand attribute information item with
-- a value of "false" or "0".
--
-- If generating a SOAP mustUnderstand attribute information item,
-- a SOAP sender SHOULD use the canonical representation "true" of
-- the attribute value (see XML Schema [XML Schema Part 2]). A
-- SOAP receiver MUST accept any valid lexical representation of
-- the attribute value.
--
-- If relaying the message, a SOAP intermediary MAY substitute
-- "true" for the value "1", or "false" for "0". In addition, a
-- SOAP intermediary MAY omit a SOAP mustUnderstand attribute
-- information item if its value is "false" (see 2.7 Relaying SOAP
-- Messages).
--
-- A SOAP sender generating a SOAP message SHOULD use the
-- mustUnderstand attribute information item only on SOAP header
-- blocks. A SOAP receiver MUST ignore this attribute information
-- item if it appears on descendants of a SOAP header block or on
-- a SOAP body child element information item (or its
-- descendents)."
-- XXX Correct processing of literal value of env:mustUnderstand
-- attribute must be implemented.
if Self.Header_Decoder = null
and then Attributes.Is_Specified
(SOAP_Envelope_URI, SOAP_Must_Understand_Name)
and then Attributes.Value
(SOAP_Envelope_URI, SOAP_Must_Understand_Name)
= SOAP_True_Literal
then
-- [SOAP1.2] 5.4.8 SOAP mustUnderstand Faults
--
-- "When a SOAP node generates a fault with a Value of Code set
-- to "env:MustUnderstand", it SHOULD provide NotUnderstood
-- SOAP header blocks in the generated fault message. The
-- NotUnderstood SOAP header blocks, as described below, detail
-- the XML qualified names (per XML Schema [XML Schema Part 2])
-- of the particular SOAP header block(s) which were not
-- understood."
-- XXX Generation of NotUnderstood SOAP header blocks is not
-- implemented yet.
Self.Set_Must_Understand_Error
(League.Strings.To_Universal_String
("One or more mandatory SOAP header blocks not"
& " understood"));
Success := False;
elsif Self.Header_Decoder /= null then
-- Decoder has been found, use it to decode header.
Self.State := Header_Element;
Self.Depth := 1;
-- Redirect handling of current XML element to decoder.
Self.Header_Decoder.Start_Element
(Namespace_URI, Local_Name, Attributes, Success);
else
Self.State := Header_Ignore;
Self.Depth := 1;
end if;
when Header_Element =>
-- Redirect handling of current XML element to decoder.
Self.Header_Decoder.Start_Element
(Namespace_URI, Local_Name, Attributes, Success);
-- Increment depth of nested XML elements in Body element.
Self.Depth := Self.Depth + 1;
when SOAP_Body =>
-- SOAP Body element has been processed, current element is its
-- child. Appropriate decoder must be created to continue
-- processing.
Self.Payload_Decoder :=
Web_Services.SOAP.Payloads.Decoders.Registry.Resolve
(Namespace_URI);
if Self.Payload_Decoder = null then
Self.Set_Sender_Fault
("Unknown namespace URI '"
& Namespace_URI
& "' of the child element of SOAP:Body");
Success := False;
return;
end if;
-- [SOAP1.2P1] 5.1.1 SOAP encodingStyle Attribute
--
-- "The encodingStyle attribute information item MAY appear on the
-- following:"
--
-- ...
--
-- "A child element information item of the SOAP Body element
-- information item (see 5.3.1 SOAP Body child Element) if that
-- child is not a SOAP Fault element information item (see 5.4
-- SOAP Fault)."
-- XXX This check is not implemented yet.
-- Self.Check_No_SOAP_Encoding_Style_Attribute
-- (Local_Name, Attributes, Success);
--
-- if not Success then
-- return;
-- end if;
Self.State := Body_Element;
Self.Depth := 1;
-- Redirect handling of current XML element to decoder.
Self.Payload_Decoder.Start_Element
(Namespace_URI, Local_Name, Attributes, Success);
if not Success then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Message body decoder reports error"));
return;
end if;
when Body_Element =>
-- Redirect handling of current XML element to decoder.
Self.Payload_Decoder.Start_Element
(Namespace_URI, Local_Name, Attributes, Success);
if not Success then
Self.Set_Sender_Fault
(League.Strings.To_Universal_String
("Message body decoder reports error"));
return;
end if;
-- Increment depth of nested XML elements in Body element.
Self.Depth := Self.Depth + 1;
end case;
end Start_Element;
-------------
-- Success --
-------------
function Success (Self : SOAP_Message_Decoder'Class) return Boolean is
begin
return Self.Success;
end Success;
end Web_Services.SOAP.Message_Decoders;
|
-- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Martin Becker (becker@rcs.ei.tum.de)
with Interfaces; use Interfaces;
with HIL; use HIL;
-- @summary convert various types to bytearrays
private package ULog.Conversions with SPARK_Mode is
type Conversion_Tag is private;
procedure New_Conversion (t : out Conversion_Tag);
procedure Set_Name (t : in out Conversion_Tag; s : String)
with Pre => s'Length > 0;
function Get_Size (t : in Conversion_Tag) return Natural;
function Buffer_Overflow (t : in Conversion_Tag) return Boolean;
function Get_Format (t : in Conversion_Tag) return ULog_Format;
function Get_Name (t : in Conversion_Tag) return ULog_Name;
function Get_Labels (t : in Conversion_Tag) return ULog_Label;
procedure Append_Unlabeled_Bytes
(t : in out Conversion_Tag;
buf : in out HIL.Byte_Array;
tail : HIL.Byte_Array);
-- only these should be used by the serialization routines:
procedure Append_Float (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Float)
with Pre => label'Length > 0;
procedure Append_Uint8 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Unsigned_8)
with Pre => label'Length > 0;
procedure Append_Uint16 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Unsigned_16)
with Pre => label'Length > 0;
procedure Append_Uint32 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Unsigned_32)
with Pre => label'Length > 0;
procedure Append_Uint64 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Unsigned_64)
with Pre => label'Length > 0;
procedure Append_Int8 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Integer_8)
with Pre => label'Length > 0;
procedure Append_Int16 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Integer_16)
with Pre => label'Length > 0;
procedure Append_Int32 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Integer_32)
with Pre => label'Length > 0;
procedure Append_Int64 (t : in out Conversion_Tag; label : String;
buf : in out HIL.Byte_Array; tail : Integer_64)
with Pre => label'Length > 0;
procedure Append_String64 (t : in out Conversion_Tag;
label : String;
buf : in out HIL.Byte_Array;
tail : String;
slen : Natural)
with Pre => label'Length > 0 and then slen <= tail'Length;
-- append the part tail'First ... tail'First + slen to buf
-- takes only the first 64 bytes. If longer, then spit before call.
private
type Label_Collect_Type is record
Labels : ULog_Label := (others => HIL.Byte (0));
Length : Natural := 0;
end record;
type Format_Collect_Type is record
Format : ULog_Format := (others => HIL.Byte (0));
Length : Natural := 0;
end record;
type Conversion_Tag is record
Buffer_Fill : Natural := 0;
Label_Collect : Label_Collect_Type;
Format_Collect : Format_Collect_Type;
Name : ULog_Name := (others => HIL.Byte (0));
Buffer_Overflow : Boolean := False;
end record;
end ULog.Conversions;
|
-- linear/geographical conversions
generic
type Real is digits <>;
package Unit_Conversion_Utilities is
type Unit_Converter is tagged private;
procedure Initialize
(This : out Unit_Converter;
LatitudeInit_Rad : Real;
LongitudeInit_rad : Real);
-- FROM LAT/LONG TO NORTH/EAST
procedure Convert_LatLong_Degrees_To_NorthEast_Meters
(This : in out Unit_Converter;
Latitude_Deg : Real;
Longitude_Deg : Real;
North : out Real;
East : out Real);
-- FROM NORTH/EAST TO LAT/LONG
-- ...
-- const double m_dRadiusEquatorial_m{6378135.0};
dRadiusEquatorial_m : constant := 6_378_135.0;
-- const double m_dFlattening{3.352810664724998e-003};
dFlattening : constant := 3.352810664724998e-003;
-- const double m_dEccentricitySquared{6.694379990096503e-003};
dEccentricitySquared : constant := 6.694379990096503e-003;
private
type Unit_Converter is tagged record
-- static double m_dLatitudeInitial_rad;
m_dLatitudeInitial_rad : Real;
-- static double m_dLongitudeInitial_rad;
m_dLongitudeInitial_rad : Real;
-- static double m_dRadiusMeridional_m;
m_dRadiusMeridional_m : Real;
-- static double m_dRadiusTransverse_m;
m_dRadiusTransverse_m : Real;
-- static double m_dRadiusSmallCircleLatitude_m;
m_dRadiusSmallCircleLatitude_m : Real;
-- Static Bool M_BInitialized;
Initialized : Boolean := False;
end record;
end Unit_Conversion_Utilities;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2005, 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. --
-- --
------------------------------------------------------------------------------
-- This package provides an interface to the sockets communication facility
-- provided on many operating systems. This is implemented on the following
-- platforms:
-- All native ports, with restrictions as follows
-- Multicast is available only on systems which provide support for this
-- feature, so it is not available if Multicast is not supported, or not
-- installed. In particular Multicast is not available with the Windows
-- version.
-- The VMS implementation has implemented using the DECC RTL Socket API,
-- and is thus subject to limitations in the implementation of this API.
-- VxWorks cross ports fully implement this package
-- This package is not yet implemented on LynxOS or other cross ports
with Ada.Exceptions;
with Ada.Streams;
with Ada.Unchecked_Deallocation;
with System;
package GNAT.Sockets is
-- Sockets are designed to provide a consistent communication facility
-- between applications. This package provides an Ada-like interface
-- similar to that proposed as part of the BSD socket layer.
-- GNAT.Sockets has been designed with several ideas in mind
-- This is a system independent interface. Therefore, we try as much as
-- possible to mask system incompatibilities. Some functionalities are not
-- available because there are not fully supported on some systems.
-- This is a thick binding. For instance, a major effort has been done to
-- avoid using memory addresses or untyped ints. We preferred to define
-- streams and enumeration types. Errors are not returned as returned
-- values but as exceptions.
-- This package provides a POSIX-compliant interface (between two
-- different implementations of the same routine, we adopt the one closest
-- to the POSIX specification). For instance, using select(), the
-- notification of an asynchronous connect failure is delivered in the
-- write socket set (POSIX) instead of the exception socket set (NT).
-- Here is a typical example of what you can do:
-- with GNAT.Sockets; use GNAT.Sockets;
-- with Ada.Text_IO;
-- with Ada.Exceptions; use Ada.Exceptions;
-- procedure PingPong is
-- Group : constant String := "239.255.128.128";
-- -- Multicast group: administratively scoped IP address
-- task Pong is
-- entry Start;
-- entry Stop;
-- end Pong;
-- task body Pong is
-- Address : Sock_Addr_Type;
-- Server : Socket_Type;
-- Socket : Socket_Type;
-- Channel : Stream_Access;
-- begin
-- accept Start;
--
-- -- Get an Internet address of a host (here the local host name).
-- -- Note that a host can have several addresses. Here we get
-- -- the first one which is supposed to be the official one.
-- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1);
-- -- Get a socket address that is an Internet address and a port
-- Address.Port := 5876;
-- -- The first step is to create a socket. Once created, this
-- -- socket must be associated to with an address. Usually only a
-- -- server (Pong here) needs to bind an address explicitly. Most
-- -- of the time clients can skip this step because the socket
-- -- routines will bind an arbitrary address to an unbound socket.
-- Create_Socket (Server);
-- -- Allow reuse of local addresses
-- Set_Socket_Option
-- (Server,
-- Socket_Level,
-- (Reuse_Address, True));
-- Bind_Socket (Server, Address);
-- -- A server marks a socket as willing to receive connect events
-- Listen_Socket (Server);
-- -- Once a server calls Listen_Socket, incoming connects events
-- -- can be accepted. The returned Socket is a new socket that
-- -- represents the server side of the connection. Server remains
-- -- available to receive further connections.
-- Accept_Socket (Server, Socket, Address);
-- -- Return a stream associated to the connected socket
-- Channel := Stream (Socket);
-- -- Force Pong to block
-- delay 0.2;
-- -- Receive and print message from client Ping
-- declare
-- Message : String := String'Input (Channel);
-- begin
-- Ada.Text_IO.Put_Line (Message);
-- -- Send same message back to client Ping
-- String'Output (Channel, Message);
-- end;
-- Close_Socket (Server);
-- Close_Socket (Socket);
-- -- Part of the multicast example
-- -- Create a datagram socket to send connectionless, unreliable
-- -- messages of a fixed maximum length.
-- Create_Socket (Socket, Family_Inet, Socket_Datagram);
-- -- Allow reuse of local addresses
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
-- -- Join a multicast group
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr));
-- -- Controls the live time of the datagram to avoid it being
-- -- looped forever due to routing errors. Routers decrement
-- -- the TTL of every datagram as it traverses from one network
-- -- to another and when its value reaches 0 the packet is
-- -- dropped. Default is 1.
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_TTL, 1));
-- -- Want the data you send to be looped back to your host
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_Loop, True));
-- -- If this socket is intended to receive messages, bind it
-- -- to a given socket address.
-- Address.Addr := Any_Inet_Addr;
-- Address.Port := 55505;
-- Bind_Socket (Socket, Address);
-- -- If this socket is intended to send messages, provide the
-- -- receiver socket address.
-- Address.Addr := Inet_Addr (Group);
-- Address.Port := 55506;
-- Channel := Stream (Socket, Address);
-- -- Receive and print message from client Ping
-- declare
-- Message : String := String'Input (Channel);
-- begin
-- -- Get the address of the sender
-- Address := Get_Address (Channel);
-- Ada.Text_IO.Put_Line (Message & " from " & Image (Address));
-- -- Send same message back to client Ping
-- String'Output (Channel, Message);
-- end;
-- Close_Socket (Socket);
-- accept Stop;
-- exception when E : others =>
-- Ada.Text_IO.Put_Line
-- (Exception_Name (E) & ": " & Exception_Message (E));
-- end Pong;
-- task Ping is
-- entry Start;
-- entry Stop;
-- end Ping;
-- task body Ping is
-- Address : Sock_Addr_Type;
-- Socket : Socket_Type;
-- Channel : Stream_Access;
-- begin
-- accept Start;
-- -- See comments in Ping section for the first steps
-- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1);
-- Address.Port := 5876;
-- Create_Socket (Socket);
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
-- -- Force Pong to block
-- delay 0.2;
-- -- If the client's socket is not bound, Connect_Socket will
-- -- bind to an unused address. The client uses Connect_Socket to
-- -- create a logical connection between the client's socket and
-- -- a server's socket returned by Accept_Socket.
-- Connect_Socket (Socket, Address);
-- Channel := Stream (Socket);
-- -- Send message to server Pong
-- String'Output (Channel, "Hello world");
-- -- Force Ping to block
-- delay 0.2;
-- -- Receive and print message from server Pong
-- Ada.Text_IO.Put_Line (String'Input (Channel));
-- Close_Socket (Socket);
-- -- Part of multicast example. Code similar to Pong's one
-- Create_Socket (Socket, Family_Inet, Socket_Datagram);
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr));
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_TTL, 1));
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_Loop, True));
-- Address.Addr := Any_Inet_Addr;
-- Address.Port := 55506;
-- Bind_Socket (Socket, Address);
-- Address.Addr := Inet_Addr (Group);
-- Address.Port := 55505;
-- Channel := Stream (Socket, Address);
-- -- Send message to server Pong
-- String'Output (Channel, "Hello world");
-- -- Receive and print message from server Pong
-- declare
-- Message : String := String'Input (Channel);
-- begin
-- Address := Get_Address (Channel);
-- Ada.Text_IO.Put_Line (Message & " from " & Image (Address));
-- end;
-- Close_Socket (Socket);
-- accept Stop;
-- exception when E : others =>
-- Ada.Text_IO.Put_Line
-- (Exception_Name (E) & ": " & Exception_Message (E));
-- end Ping;
-- begin
-- -- Indicate whether the thread library provides process
-- -- blocking IO. Basically, if you are not using FSU threads
-- -- the default is ok.
-- Initialize (Process_Blocking_IO => False);
-- Ping.Start;
-- Pong.Start;
-- Ping.Stop;
-- Pong.Stop;
-- Finalize;
-- end PingPong;
procedure Initialize (Process_Blocking_IO : Boolean := False);
-- Initialize must be called before using any other socket routines. The
-- Process_Blocking_IO parameter indicates whether the thread library
-- provides process-blocking or thread-blocking input/output operations.
-- In the former case (typically with FSU threads) GNAT.Sockets should be
-- initialized with a value of True to provide task-blocking IO through an
-- emulation mechanism. Only the first call to Initialize is taken into
-- account (further calls will be ignored). Note that with the default
-- value of Process_Blocking_IO, this operation is a no-op on UNIX
-- platforms, but applications should make sure to call it if portability
-- is expected: some platforms (such as Windows) require initialization
-- before any other socket operations.
procedure Finalize;
-- After Finalize is called it is not possible to use any routines
-- exported in by this package. This procedure is idempotent.
type Socket_Type is private;
-- Sockets are used to implement a reliable bi-directional point-to-point,
-- stream-based connections between hosts. No_Socket provides a special
-- value to denote uninitialized sockets.
No_Socket : constant Socket_Type;
Socket_Error : exception;
-- There is only one exception in this package to deal with an error during
-- a socket routine. Once raised, its message contains a string describing
-- the error code.
function Image (Socket : Socket_Type) return String;
-- Return a printable string for Socket
function To_C (Socket : Socket_Type) return Integer;
-- Return a file descriptor to be used by external subprograms. This is
-- useful for C functions that are not yet interfaced in this package.
type Family_Type is (Family_Inet, Family_Inet6);
-- Address family (or protocol family) identifies the communication domain
-- and groups protocols with similar address formats. IPv6 will soon be
-- supported.
type Mode_Type is (Socket_Stream, Socket_Datagram);
-- Stream sockets provide connection-oriented byte streams. Datagram
-- sockets support unreliable connectionless message based communication.
type Shutmode_Type is (Shut_Read, Shut_Write, Shut_Read_Write);
-- When a process closes a socket, the policy is to retain any data queued
-- until either a delivery or a timeout expiration (in this case, the data
-- are discarded). A finer control is available through shutdown. With
-- Shut_Read, no more data can be received from the socket. With_Write, no
-- more data can be transmitted. Neither transmission nor reception can be
-- performed with Shut_Read_Write.
type Port_Type is new Natural;
-- Classical port definition. No_Port provides a special value to
-- denote uninitialized port. Any_Port provides a special value
-- enabling all ports.
Any_Port : constant Port_Type;
No_Port : constant Port_Type;
type Inet_Addr_Type (Family : Family_Type := Family_Inet) is private;
-- An Internet address depends on an address family (IPv4 contains 4
-- octets and Ipv6 contains 16 octets). Any_Inet_Addr is a special value
-- treated like a wildcard enabling all addresses. No_Inet_Addr provides a
-- special value to denote uninitialized inet addresses.
Any_Inet_Addr : constant Inet_Addr_Type;
No_Inet_Addr : constant Inet_Addr_Type;
Broadcast_Inet_Addr : constant Inet_Addr_Type;
type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record
Addr : Inet_Addr_Type (Family);
Port : Port_Type;
end record;
-- Socket addresses fully define a socket connection with protocol family,
-- an Internet address and a port. No_Sock_Addr provides a special value
-- for uninitialized socket addresses.
No_Sock_Addr : constant Sock_Addr_Type;
function Image (Value : Inet_Addr_Type) return String;
-- Return an image of an Internet address. IPv4 notation consists in 4
-- octets in decimal format separated by dots. IPv6 notation consists in
-- 16 octets in hexadecimal format separated by colons (and possibly
-- dots).
function Image (Value : Sock_Addr_Type) return String;
-- Return inet address image and port image separated by a colon
function Inet_Addr (Image : String) return Inet_Addr_Type;
-- Convert address image from numbers-and-dots notation into an
-- inet address.
-- Host entries provide complete information on a given host: the official
-- name, an array of alternative names or aliases and array of network
-- addresses.
type Host_Entry_Type
(Aliases_Length, Addresses_Length : Natural) is private;
function Official_Name (E : Host_Entry_Type) return String;
-- Return official name in host entry
function Aliases_Length (E : Host_Entry_Type) return Natural;
-- Return number of aliases in host entry
function Addresses_Length (E : Host_Entry_Type) return Natural;
-- Return number of addresses in host entry
function Aliases
(E : Host_Entry_Type;
N : Positive := 1) return String;
-- Return N'th aliases in host entry. The first index is 1
function Addresses
(E : Host_Entry_Type;
N : Positive := 1) return Inet_Addr_Type;
-- Return N'th addresses in host entry. The first index is 1
Host_Error : exception;
-- Exception raised by the two following procedures. Once raised, its
-- message contains a string describing the error code. This exception is
-- raised when an host entry cannot be retrieved.
function Get_Host_By_Address
(Address : Inet_Addr_Type;
Family : Family_Type := Family_Inet) return Host_Entry_Type;
-- Return host entry structure for the given Inet address. Note that no
-- result will be returned if there is no mapping of this IP address to a
-- host name in the system tables (host database, DNS or otherwise).
function Get_Host_By_Name
(Name : String) return Host_Entry_Type;
-- Return host entry structure for the given host name. Here name is
-- either a host name, or an IP address. If Name is an IP address, this is
-- equivalent to Get_Host_By_Address (Inet_Addr (Name)).
function Host_Name return String;
-- Return the name of the current host
type Service_Entry_Type (Aliases_Length : Natural) is private;
-- Service entries provide complete information on a given service: the
-- official name, an array of alternative names or aliases and the port
-- number.
function Official_Name (S : Service_Entry_Type) return String;
-- Return official name in service entry
function Port_Number (S : Service_Entry_Type) return Port_Type;
-- Return port number in service entry
function Protocol_Name (S : Service_Entry_Type) return String;
-- Return Protocol in service entry (usually UDP or TCP)
function Aliases_Length (S : Service_Entry_Type) return Natural;
-- Return number of aliases in service entry
function Aliases
(S : Service_Entry_Type;
N : Positive := 1) return String;
-- Return N'th aliases in service entry (the first index is 1)
function Get_Service_By_Name
(Name : String;
Protocol : String) return Service_Entry_Type;
-- Return service entry structure for the given service name
function Get_Service_By_Port
(Port : Port_Type;
Protocol : String) return Service_Entry_Type;
-- Return service entry structure for the given service port number
Service_Error : exception;
-- Comment required ???
-- Errors are described by an enumeration type. There is only one
-- exception Socket_Error in this package to deal with an error during a
-- socket routine. Once raised, its message contains the error code
-- between brackets and a string describing the error code.
-- The name of the enumeration constant documents the error condition
type Error_Type is
(Success,
Permission_Denied,
Address_Already_In_Use,
Cannot_Assign_Requested_Address,
Address_Family_Not_Supported_By_Protocol,
Operation_Already_In_Progress,
Bad_File_Descriptor,
Software_Caused_Connection_Abort,
Connection_Refused,
Connection_Reset_By_Peer,
Destination_Address_Required,
Bad_Address,
Host_Is_Down,
No_Route_To_Host,
Operation_Now_In_Progress,
Interrupted_System_Call,
Invalid_Argument,
Input_Output_Error,
Transport_Endpoint_Already_Connected,
Too_Many_Symbolic_Links,
Too_Many_Open_Files,
Message_Too_Long,
File_Name_Too_Long,
Network_Is_Down,
Network_Dropped_Connection_Because_Of_Reset,
Network_Is_Unreachable,
No_Buffer_Space_Available,
Protocol_Not_Available,
Transport_Endpoint_Not_Connected,
Socket_Operation_On_Non_Socket,
Operation_Not_Supported,
Protocol_Family_Not_Supported,
Protocol_Not_Supported,
Protocol_Wrong_Type_For_Socket,
Cannot_Send_After_Transport_Endpoint_Shutdown,
Socket_Type_Not_Supported,
Connection_Timed_Out,
Too_Many_References,
Resource_Temporarily_Unavailable,
Unknown_Host,
Host_Name_Lookup_Failure,
Non_Recoverable_Error,
Unknown_Server_Error,
Cannot_Resolve_Error);
-- Timeval_Duration is a subtype of Standard.Duration because the full
-- range of Standard.Duration cannot be represented in the equivalent C
-- structure. Moreover, negative values are not allowed to avoid system
-- incompatibilities.
Immediate : constant := 0.0;
Forever : constant := Duration (Integer'Last) * 1.0;
subtype Timeval_Duration is Duration range Immediate .. Forever;
-- Get_Socket_Options and Set_Socket_Options manipulate options associated
-- with a socket. Options may exist at multiple protocol levels in the
-- communication stack. Socket_Level is the uppermost socket level.
type Level_Type is (
Socket_Level,
IP_Protocol_For_IP_Level,
IP_Protocol_For_UDP_Level,
IP_Protocol_For_TCP_Level);
-- There are several options available to manipulate sockets. Each option
-- has a name and several values available. Most of the time, the value is
-- a boolean to enable or disable this option.
type Option_Name is (
Keep_Alive, -- Enable sending of keep-alive messages
Reuse_Address, -- Allow bind to reuse local address
Broadcast, -- Enable datagram sockets to recv/send broadcasts
Send_Buffer, -- Set/get the maximum socket send buffer in bytes
Receive_Buffer, -- Set/get the maximum socket recv buffer in bytes
Linger, -- Shutdown wait for msg to be sent or timeout occur
Error, -- Get and clear the pending socket error
No_Delay, -- Do not delay send to coalesce packets (TCP_NODELAY)
Add_Membership, -- Join a multicast group
Drop_Membership, -- Leave a multicast group
Multicast_If, -- Set default outgoing interface for multicast packets
Multicast_TTL, -- Indicate the time-to-live of sent multicast packets
Multicast_Loop, -- Sent multicast packets are looped to local socket
Send_Timeout, -- Set timeout value for output
Receive_Timeout); -- Set timeout value for input
type Option_Type (Name : Option_Name := Keep_Alive) is record
case Name is
when Keep_Alive |
Reuse_Address |
Broadcast |
Linger |
No_Delay |
Multicast_Loop =>
Enabled : Boolean;
case Name is
when Linger =>
Seconds : Natural;
when others =>
null;
end case;
when Send_Buffer |
Receive_Buffer =>
Size : Natural;
when Error =>
Error : Error_Type;
when Add_Membership |
Drop_Membership =>
Multicast_Address : Inet_Addr_Type;
Local_Interface : Inet_Addr_Type;
when Multicast_If =>
Outgoing_If : Inet_Addr_Type;
when Multicast_TTL =>
Time_To_Live : Natural;
when Send_Timeout |
Receive_Timeout =>
Timeout : Timeval_Duration;
end case;
end record;
-- There are several controls available to manipulate sockets. Each option
-- has a name and several values available. These controls differ from the
-- socket options in that they are not specific to sockets but are
-- available for any device.
type Request_Name is (
Non_Blocking_IO, -- Cause a caller not to wait on blocking operations.
N_Bytes_To_Read); -- Return the number of bytes available to read
type Request_Type (Name : Request_Name := Non_Blocking_IO) is record
case Name is
when Non_Blocking_IO =>
Enabled : Boolean;
when N_Bytes_To_Read =>
Size : Natural;
end case;
end record;
-- A request flag allows to specify the type of message transmissions or
-- receptions. A request flag can be combination of zero or more
-- predefined request flags.
type Request_Flag_Type is private;
No_Request_Flag : constant Request_Flag_Type;
-- This flag corresponds to the normal execution of an operation
Process_Out_Of_Band_Data : constant Request_Flag_Type;
-- This flag requests that the receive or send function operates on
-- out-of-band data when the socket supports this notion (e.g.
-- Socket_Stream).
Peek_At_Incoming_Data : constant Request_Flag_Type;
-- This flag causes the receive operation to return data from the
-- beginning of the receive queue without removing that data from the
-- queue. A subsequent receive call will return the same data.
Wait_For_A_Full_Reception : constant Request_Flag_Type;
-- This flag requests that the operation block until the full request is
-- satisfied. However, the call may still return less data than requested
-- if a signal is caught, an error or disconnect occurs, or the next data
-- to be received is of a different type than that returned. Note that
-- this flag depends on support in the underlying sockets implementation,
-- and is not supported under Windows.
Send_End_Of_Record : constant Request_Flag_Type;
-- This flag indicates that the entire message has been sent and so this
-- terminates the record.
function "+" (L, R : Request_Flag_Type) return Request_Flag_Type;
-- Combine flag L with flag R
type Stream_Element_Reference is access all Ada.Streams.Stream_Element;
type Vector_Element is record
Base : Stream_Element_Reference;
Length : Ada.Streams.Stream_Element_Count;
end record;
type Vector_Type is array (Integer range <>) of Vector_Element;
procedure Create_Socket
(Socket : out Socket_Type;
Family : Family_Type := Family_Inet;
Mode : Mode_Type := Socket_Stream);
-- Create an endpoint for communication. Raises Socket_Error on error
procedure Accept_Socket
(Server : Socket_Type;
Socket : out Socket_Type;
Address : out Sock_Addr_Type);
-- Extracts the first connection request on the queue of pending
-- connections, creates a new connected socket with mostly the same
-- properties as Server, and allocates a new socket. The returned Address
-- is filled in with the address of the connection. Raises Socket_Error on
-- error.
procedure Bind_Socket
(Socket : Socket_Type;
Address : Sock_Addr_Type);
-- Once a socket is created, assign a local address to it. Raise
-- Socket_Error on error.
procedure Close_Socket (Socket : Socket_Type);
-- Close a socket and more specifically a non-connected socket
procedure Connect_Socket
(Socket : Socket_Type;
Server : in out Sock_Addr_Type);
-- Make a connection to another socket which has the address of
-- Server. Raises Socket_Error on error.
procedure Control_Socket
(Socket : Socket_Type;
Request : in out Request_Type);
-- Obtain or set parameter values that control the socket. This control
-- differs from the socket options in that they are not specific to
-- sockets but are available for any device.
function Get_Peer_Name (Socket : Socket_Type) return Sock_Addr_Type;
-- Return the peer or remote socket address of a socket. Raise
-- Socket_Error on error.
function Get_Socket_Name (Socket : Socket_Type) return Sock_Addr_Type;
-- Return the local or current socket address of a socket. Return
-- No_Sock_Addr on error (for instance, socket closed or not locally
-- bound).
function Get_Socket_Option
(Socket : Socket_Type;
Level : Level_Type := Socket_Level;
Name : Option_Name) return Option_Type;
-- Get the options associated with a socket. Raises Socket_Error
-- on error.
procedure Listen_Socket
(Socket : Socket_Type;
Length : Positive := 15);
-- To accept connections, a socket is first created with Create_Socket,
-- a willingness to accept incoming connections and a queue Length for
-- incoming connections are specified. Raise Socket_Error on error.
procedure Receive_Socket
(Socket : Socket_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flags : Request_Flag_Type := No_Request_Flag);
-- Receive message from Socket. Last is the index value such that Item
-- (Last) is the last character assigned. Note that Last is set to
-- Item'First - 1 when the socket has been closed by peer. This is not an
-- error and no exception is raised. Flags allows to control the
-- reception. Raise Socket_Error on error.
procedure Receive_Socket
(Socket : Socket_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
From : out Sock_Addr_Type;
Flags : Request_Flag_Type := No_Request_Flag);
-- Receive message from Socket. If Socket is not connection-oriented, the
-- source address From of the message is filled in. Last is the index
-- value such that Item (Last) is the last character assigned. Flags
-- allows to control the reception. Raises Socket_Error on error.
procedure Receive_Vector
(Socket : Socket_Type;
Vector : Vector_Type;
Count : out Ada.Streams.Stream_Element_Count);
-- Receive data from a socket and scatter it into the set of vector
-- elements Vector. Count is set to the count of received stream elements.
function Resolve_Exception
(Occurrence : Ada.Exceptions.Exception_Occurrence) return Error_Type;
-- When Socket_Error or Host_Error are raised, the exception message
-- contains the error code between brackets and a string describing the
-- error code. Resolve_Error extracts the error code from an exception
-- message and translate it into an enumeration value.
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flags : Request_Flag_Type := No_Request_Flag);
-- Transmit a message to another socket. Note that Last is set to
-- Item'First-1 when socket has been closed by peer. This is not
-- considered an error and no exception is raised. Flags allows to control
-- the transmission. Raises Socket_Error on any other error condition.
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
To : Sock_Addr_Type;
Flags : Request_Flag_Type := No_Request_Flag);
-- Transmit a message to another socket. The address is given by To. Flags
-- allows to control the transmission. Raises Socket_Error on error.
procedure Send_Vector
(Socket : Socket_Type;
Vector : Vector_Type;
Count : out Ada.Streams.Stream_Element_Count);
-- Transmit data gathered from the set of vector elements Vector to a
-- socket. Count is set to the count of transmitted stream elements.
procedure Set_Socket_Option
(Socket : Socket_Type;
Level : Level_Type := Socket_Level;
Option : Option_Type);
-- Manipulate socket options. Raises Socket_Error on error
procedure Shutdown_Socket
(Socket : Socket_Type;
How : Shutmode_Type := Shut_Read_Write);
-- Shutdown a connected socket. If How is Shut_Read, further receives will
-- be disallowed. If How is Shut_Write, further sends will be disallowed.
-- If how is Shut_Read_Write, further sends and receives will be
-- disallowed.
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
-- Same interface as Ada.Streams.Stream_IO
function Stream
(Socket : Socket_Type) return Stream_Access;
-- Create a stream associated with a stream-based socket that is
-- already connected.
function Stream
(Socket : Socket_Type;
Send_To : Sock_Addr_Type) return Stream_Access;
-- Create a stream associated with a datagram-based socket that is already
-- bound. Send_To is the socket address to which messages are being sent.
function Get_Address
(Stream : Stream_Access) return Sock_Addr_Type;
-- Return the socket address from which the last message was received
procedure Free is new Ada.Unchecked_Deallocation
(Ada.Streams.Root_Stream_Type'Class, Stream_Access);
-- Destroy a stream created by one of the Stream functions above,
-- releasing the corresponding resources. The user is responsible for
-- calling this subprogram when the stream is not needed anymore.
type Socket_Set_Type is limited private;
-- This type allows to manipulate sets of sockets. It allows to wait for
-- events on multiple endpoints at one time. This is an access type on a
-- system dependent structure. To avoid memory leaks it is highly
-- recommended to clean the access value with procedure Empty.
procedure Clear (Item : in out Socket_Set_Type; Socket : Socket_Type);
-- Remove Socket from Item
procedure Copy (Source : Socket_Set_Type; Target : in out Socket_Set_Type);
-- Copy Source into Target as Socket_Set_Type is limited private
procedure Empty (Item : in out Socket_Set_Type);
-- Remove all Sockets from Item and deallocate internal data
procedure Get (Item : in out Socket_Set_Type; Socket : out Socket_Type);
-- Extract a Socket from socket set Item. Socket is set to
-- No_Socket when the set is empty.
function Is_Empty
(Item : Socket_Set_Type) return Boolean;
-- Return True iff Item is empty
function Is_Set
(Item : Socket_Set_Type;
Socket : Socket_Type) return Boolean;
-- Return True iff Socket is present in Item
procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type);
-- Insert Socket into Item
-- The select(2) system call waits for events to occur on any of a set of
-- file descriptors. Usually, three independent sets of descriptors are
-- watched (read, write and exception). A timeout gives an upper bound
-- on the amount of time elapsed before select returns. This function
-- blocks until an event occurs. On some platforms, the select(2) system
-- can block the full process (not just the calling thread).
--
-- Check_Selector provides the very same behaviour. The only difference is
-- that it does not watch for exception events. Note that on some
-- platforms it is kept process blocking on purpose. The timeout parameter
-- allows the user to have the behaviour he wants. Abort_Selector allows
-- to abort safely a Check_Selector that is blocked forever. A special
-- file descriptor is opened by Create_Selector and included in each call
-- to Check_Selector. Abort_Selector causes an event to occur on this
-- descriptor in order to unblock Check_Selector. The user must call
-- Close_Selector to discard this special file. A reason to abort a select
-- operation is typically to add a socket in one of the socket sets when
-- the timeout is set to forever.
type Selector_Type is limited private;
type Selector_Access is access all Selector_Type;
subtype Selector_Duration is Timeval_Duration;
procedure Create_Selector (Selector : out Selector_Type);
-- Create a new selector
procedure Close_Selector (Selector : in out Selector_Type);
-- Close Selector and all internal descriptors associated
type Selector_Status is (Completed, Expired, Aborted);
procedure Check_Selector
(Selector : in out Selector_Type;
R_Socket_Set : in out Socket_Set_Type;
W_Socket_Set : in out Socket_Set_Type;
Status : out Selector_Status;
Timeout : Selector_Duration := Forever);
-- Return when one Socket in R_Socket_Set has some data to be read or if
-- one Socket in W_Socket_Set is ready to transmit some data. In these
-- cases Status is set to Completed and sockets that are ready are set in
-- R_Socket_Set or W_Socket_Set. Status is set to Expired if no socket was
-- ready after a Timeout expiration. Status is set to Aborted if an abort
-- signal has been received while checking socket status. As this
-- procedure returns when Timeout occurs, it is a design choice to keep
-- this procedure process blocking. Note that a Timeout of 0.0 returns
-- immediately. Also note that two different Socket_Set_Type objects must
-- be passed as R_Socket_Set and W_Socket_Set (even if they denote the
-- same set of Sockets), or some event may be lost.
-- Socket_Error is raised when the select(2) system call returns an
-- error condition, or when a read error occurs on the signalling socket
-- used for the implementation of Abort_Selector.
procedure Check_Selector
(Selector : in out Selector_Type;
R_Socket_Set : in out Socket_Set_Type;
W_Socket_Set : in out Socket_Set_Type;
E_Socket_Set : in out Socket_Set_Type;
Status : out Selector_Status;
Timeout : Selector_Duration := Forever);
-- This refined version of Check_Selector allows to watch for exception
-- events (that is notifications of out-of-band transmission and
-- reception). As above, all of R_Socket_Set, W_Socket_Set and
-- E_Socket_Set must be different objects.
procedure Abort_Selector (Selector : Selector_Type);
-- Send an abort signal to the selector
private
type Socket_Type is new Integer;
No_Socket : constant Socket_Type := -1;
type Selector_Type is limited record
R_Sig_Socket : Socket_Type;
W_Sig_Socket : Socket_Type;
end record;
pragma Volatile (Selector_Type);
-- The two signalling sockets are used to abort a select operation
subtype Socket_Set_Access is System.Address;
No_Socket_Set : constant Socket_Set_Access := System.Null_Address;
type Socket_Set_Type is record
Last : Socket_Type := No_Socket;
Set : Socket_Set_Access := No_Socket_Set;
end record;
subtype Inet_Addr_Comp_Type is Natural range 0 .. 255;
-- Octet for Internet address
type Inet_Addr_VN_Type is array (Natural range <>) of Inet_Addr_Comp_Type;
subtype Inet_Addr_V4_Type is Inet_Addr_VN_Type (1 .. 4);
subtype Inet_Addr_V6_Type is Inet_Addr_VN_Type (1 .. 16);
type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record
case Family is
when Family_Inet =>
Sin_V4 : Inet_Addr_V4_Type := (others => 0);
when Family_Inet6 =>
Sin_V6 : Inet_Addr_V6_Type := (others => 0);
end case;
end record;
Any_Port : constant Port_Type := 0;
No_Port : constant Port_Type := 0;
Any_Inet_Addr : constant Inet_Addr_Type :=
(Family_Inet, (others => 0));
No_Inet_Addr : constant Inet_Addr_Type :=
(Family_Inet, (others => 0));
Broadcast_Inet_Addr : constant Inet_Addr_Type :=
(Family_Inet, (others => 255));
No_Sock_Addr : constant Sock_Addr_Type := (Family_Inet, No_Inet_Addr, 0);
Max_Name_Length : constant := 64;
-- The constant MAXHOSTNAMELEN is usually set to 64
subtype Name_Index is Natural range 1 .. Max_Name_Length;
type Name_Type
(Length : Name_Index := Max_Name_Length)
is record
Name : String (1 .. Length);
end record;
-- We need fixed strings to avoid access types in host entry type
type Name_Array is array (Natural range <>) of Name_Type;
type Inet_Addr_Array is array (Natural range <>) of Inet_Addr_Type;
type Host_Entry_Type (Aliases_Length, Addresses_Length : Natural) is record
Official : Name_Type;
Aliases : Name_Array (1 .. Aliases_Length);
Addresses : Inet_Addr_Array (1 .. Addresses_Length);
end record;
type Service_Entry_Type (Aliases_Length : Natural) is record
Official : Name_Type;
Aliases : Name_Array (1 .. Aliases_Length);
Port : Port_Type;
Protocol : Name_Type;
end record;
type Request_Flag_Type is mod 2 ** 8;
No_Request_Flag : constant Request_Flag_Type := 0;
Process_Out_Of_Band_Data : constant Request_Flag_Type := 1;
Peek_At_Incoming_Data : constant Request_Flag_Type := 2;
Wait_For_A_Full_Reception : constant Request_Flag_Type := 4;
Send_End_Of_Record : constant Request_Flag_Type := 8;
end GNAT.Sockets;
|
with STM32_SVD.SPI;
generic
SPI : in out STM32_SVD.SPI.SPI_Peripheral;
package STM32GD.SPI.Peripheral is
pragma Preelaborate;
procedure Init;
procedure Send (Data : in Byte);
procedure Send (Data : in SPI_Data_8b);
procedure Receive (Data : out Byte);
procedure Receive (Data : out SPI_Data_8b);
procedure Transfer (Data : in out SPI_Data_8b);
end STM32GD.SPI.Peripheral;
|
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line;
procedure Floyd_Triangle is
rows : constant Natural := Natural'Value(Ada.Command_Line.Argument(1));
begin
for r in 1..rows loop
for i in 1..r loop
Ada.Integer_Text_IO.put (r*(r-1)/2+i, Width=> Natural'Image(rows*(rows-1)/2+i)'Length);
end loop;
Ada.Text_IO.New_Line;
end loop;
end Floyd_Triangle;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT INTERFACE COMPONENTS --
-- --
-- A S I S . L I M I T E D _ V I E W S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010-2011, Free Software Foundation, Inc. --
-- --
-- This specification is added to be used together with the Ada Semantic --
-- Interface Specification Standard (ISO/IEC 15291) for use with GNAT. -- --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Elements; use Asis.Elements;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.Asis_Tables;
with A4G.Contt.TT;
with A4G.Contt.UT;
with A4G.Mapping; use A4G.Mapping;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Nlists; use Nlists;
with Sinfo; use Sinfo;
package body Asis.Limited_Views is
Package_Name : constant String := "Asis.Limited_Views.";
-------------------------
-- Get_Nonlimited_View --
-------------------------
function Get_Nonlimited_View (D : Asis.Element) return Asis.Element is
Encl_Unit : Asis.Compilation_Unit;
Arg_Node : Node_Id;
Res_Node : Node_Id;
Def_Name_Case : constant Boolean := Element_Kind (D) = A_Defining_Name;
begin
if not Is_From_Limited_View (D) then
Raise_ASIS_Inappropriate_Element
(Package_Name &
"Is_From_Limited_View (non-limited view as actual)",
Wrong_Kind => Int_Kind (D));
end if;
Encl_Unit := Enclosing_Compilation_Unit (D);
if Has_Limited_View_Only (Encl_Unit) then
return Nil_Element;
end if;
Arg_Node := Node (D);
if Def_Name_Case then
while not (Is_List_Member (Arg_Node)
or else
Nkind (Arg_Node) = N_Package_Declaration)
loop
Arg_Node := Parent (Arg_Node);
end loop;
end if;
A4G.Asis_Tables.Create_Node_Trace (Arg_Node);
A4G.Contt.TT.Reset_Tree_For_Unit (Encl_Unit);
Res_Node := A4G.Contt.TT.Restore_Node_From_Trace (CU => Encl_Unit);
if Def_Name_Case then
if Nkind (Res_Node) = N_Package_Declaration then
if Is_List_Member (Res_Node) then
Res_Node := Defining_Unit_Name (Sinfo.Specification (Res_Node));
else
Res_Node := Defining_Identifier (Res_Node);
end if;
end if;
end if;
return Node_To_Element_New
(Node => Res_Node,
In_Unit => Encl_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => D,
Outer_Call => Package_Name & "Get_Nonlimited_View");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Get_Nonlimited_View",
Ex => Ex,
Arg_Element => D);
end Get_Nonlimited_View;
---------------------------
-- Has_Limited_View_Only --
---------------------------
function Has_Limited_View_Only
(Right : Asis.Compilation_Unit)
return Boolean
is
Result : Boolean := False;
begin
if Unit_Kind (Right) = A_Package
and then
not Is_Standard (Right)
then
Result := A4G.Contt.UT.Has_Limited_View_Only
(Encl_Cont_Id (Right),
Get_Unit_Id (Right));
end if;
return Result;
exception
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Has_Limited_View_Only");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Has_Limited_View_Only",
Ex => Ex,
Arg_CU => Right);
end Has_Limited_View_Only;
--------------------------
-- Is_From_Limited_View --
--------------------------
function Is_From_Limited_View (D : Asis.Element) return Boolean is
begin
return Special_Case (D) = From_Limited_View;
end Is_From_Limited_View;
end Asis.Limited_Views;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Regions.Entities is
pragma Pure;
type Entity is limited interface;
function Is_Assigned (Self : access Entity'Class) return Boolean
is (Self /= null);
not overriding function Is_Package (Self : Entity) return Boolean
is abstract;
type Entity_Access is access all Entity'Class
with Storage_Size => 0;
end Regions.Entities;
|
-- { dg-do compile }
with Text_IO; use Text_IO;
procedure Dump (A : System.Address; Len : Storage_Offset) is
Arr : Storage_Array (1 .. Len);
for Arr'Address use A;
pragma Import (Ada, Arr);
H : constant array (Storage_Element range 0 .. 15) of Character :=
"0123456789abcdef";
begin
for J in Arr'Range loop
Put (' ' & H (Arr (J) / 16) & H (Arr (J) mod 16));
end loop;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Menus --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2014,2018 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.33 $
-- $Date: 2018/07/07 23:36:44 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C.Pointers;
package body Terminal_Interface.Curses.Menus is
type C_Item_Array is array (Natural range <>) of aliased Item;
package I_Array is new
Interfaces.C.Pointers (Natural, Item, C_Item_Array, Null_Item);
subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
------------------------------------------------------------------------------
procedure Request_Name (Key : Menu_Request_Code;
Name : out String)
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
Fill_String (Request_Name (C_Int (Key)), Name);
end Request_Name;
function Request_Name (Key : Menu_Request_Code) return String
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
return Fill_String (Request_Name (C_Int (Key)));
end Request_Name;
function Create (Name : String;
Description : String := "") return Item
is
type Char_Ptr is access all Interfaces.C.char;
function Newitem (Name, Desc : Char_Ptr) return Item;
pragma Import (C, Newitem, "new_item");
type Name_String is new char_array (0 .. Name'Length);
type Name_String_Ptr is access Name_String;
pragma Controlled (Name_String_Ptr);
type Desc_String is new char_array (0 .. Description'Length);
type Desc_String_Ptr is access Desc_String;
pragma Controlled (Desc_String_Ptr);
Name_Str : constant Name_String_Ptr := new Name_String;
Desc_Str : constant Desc_String_Ptr := new Desc_String;
Name_Len, Desc_Len : size_t;
Result : Item;
begin
To_C (Name, Name_Str.all, Name_Len);
To_C (Description, Desc_Str.all, Desc_Len);
Result := Newitem (Name_Str.all (Name_Str.all'First)'Access,
Desc_Str.all (Desc_Str.all'First)'Access);
if Result = Null_Item then
raise Eti_System_Error;
end if;
return Result;
end Create;
procedure Delete (Itm : in out Item)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
function Freeitem (Itm : Item) return Eti_Error;
pragma Import (C, Freeitem, "free_item");
Ptr : chars_ptr;
begin
Ptr := Descname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Ptr := Itemname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Eti_Exception (Freeitem (Itm));
Itm := Null_Item;
end Delete;
-------------------------------------------------------------------------------
procedure Set_Value (Itm : Item;
Value : Boolean := True)
is
function Set_Item_Val (Itm : Item;
Val : C_Int) return Eti_Error;
pragma Import (C, Set_Item_Val, "set_item_value");
begin
Eti_Exception (Set_Item_Val (Itm, Boolean'Pos (Value)));
end Set_Value;
function Value (Itm : Item) return Boolean
is
function Item_Val (Itm : Item) return C_Int;
pragma Import (C, Item_Val, "item_value");
begin
if Item_Val (Itm) = Curses_False then
return False;
else
return True;
end if;
end Value;
-------------------------------------------------------------------------------
function Visible (Itm : Item) return Boolean
is
function Item_Vis (Itm : Item) return C_Int;
pragma Import (C, Item_Vis, "item_visible");
begin
if Item_Vis (Itm) = Curses_False then
return False;
else
return True;
end if;
end Visible;
-------------------------------------------------------------------------------
procedure Set_Options (Itm : Item;
Options : Item_Option_Set)
is
function Set_Item_Opts (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Set_Item_Opts, "set_item_opts");
begin
Eti_Exception (Set_Item_Opts (Itm, Options));
end Set_Options;
procedure Switch_Options (Itm : Item;
Options : Item_Option_Set;
On : Boolean := True)
is
function Item_Opts_On (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_On, "item_opts_on");
function Item_Opts_Off (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_Off, "item_opts_off");
begin
if On then
Eti_Exception (Item_Opts_On (Itm, Options));
else
Eti_Exception (Item_Opts_Off (Itm, Options));
end if;
end Switch_Options;
procedure Get_Options (Itm : Item;
Options : out Item_Option_Set)
is
function Item_Opts (Itm : Item) return Item_Option_Set;
pragma Import (C, Item_Opts, "item_opts");
begin
Options := Item_Opts (Itm);
end Get_Options;
function Get_Options (Itm : Item := Null_Item) return Item_Option_Set
is
Ios : Item_Option_Set;
begin
Get_Options (Itm, Ios);
return Ios;
end Get_Options;
-------------------------------------------------------------------------------
procedure Name (Itm : Item;
Name : out String)
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
Fill_String (Itemname (Itm), Name);
end Name;
function Name (Itm : Item) return String
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
return Fill_String (Itemname (Itm));
end Name;
procedure Description (Itm : Item;
Description : out String)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
Fill_String (Descname (Itm), Description);
end Description;
function Description (Itm : Item) return String
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
return Fill_String (Descname (Itm));
end Description;
-------------------------------------------------------------------------------
procedure Set_Current (Men : Menu;
Itm : Item)
is
function Set_Curr_Item (Men : Menu;
Itm : Item) return Eti_Error;
pragma Import (C, Set_Curr_Item, "set_current_item");
begin
Eti_Exception (Set_Curr_Item (Men, Itm));
end Set_Current;
function Current (Men : Menu) return Item
is
function Curr_Item (Men : Menu) return Item;
pragma Import (C, Curr_Item, "current_item");
Res : constant Item := Curr_Item (Men);
begin
if Res = Null_Item then
raise Menu_Exception;
end if;
return Res;
end Current;
procedure Set_Top_Row (Men : Menu;
Line : Line_Position)
is
function Set_Toprow (Men : Menu;
Line : C_Int) return Eti_Error;
pragma Import (C, Set_Toprow, "set_top_row");
begin
Eti_Exception (Set_Toprow (Men, C_Int (Line)));
end Set_Top_Row;
function Top_Row (Men : Menu) return Line_Position
is
function Toprow (Men : Menu) return C_Int;
pragma Import (C, Toprow, "top_row");
Res : constant C_Int := Toprow (Men);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Line_Position (Res);
end Top_Row;
function Get_Index (Itm : Item) return Positive
is
function Get_Itemindex (Itm : Item) return C_Int;
pragma Import (C, Get_Itemindex, "item_index");
Res : constant C_Int := Get_Itemindex (Itm);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Positive (Natural (Res) + Positive'First);
end Get_Index;
-------------------------------------------------------------------------------
procedure Post (Men : Menu;
Post : Boolean := True)
is
function M_Post (Men : Menu) return Eti_Error;
pragma Import (C, M_Post, "post_menu");
function M_Unpost (Men : Menu) return Eti_Error;
pragma Import (C, M_Unpost, "unpost_menu");
begin
if Post then
Eti_Exception (M_Post (Men));
else
Eti_Exception (M_Unpost (Men));
end if;
end Post;
-------------------------------------------------------------------------------
procedure Set_Options (Men : Menu;
Options : Menu_Option_Set)
is
function Set_Menu_Opts (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Set_Menu_Opts, "set_menu_opts");
begin
Eti_Exception (Set_Menu_Opts (Men, Options));
end Set_Options;
procedure Switch_Options (Men : Menu;
Options : Menu_Option_Set;
On : Boolean := True)
is
function Menu_Opts_On (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_On, "menu_opts_on");
function Menu_Opts_Off (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_Off, "menu_opts_off");
begin
if On then
Eti_Exception (Menu_Opts_On (Men, Options));
else
Eti_Exception (Menu_Opts_Off (Men, Options));
end if;
end Switch_Options;
procedure Get_Options (Men : Menu;
Options : out Menu_Option_Set)
is
function Menu_Opts (Men : Menu) return Menu_Option_Set;
pragma Import (C, Menu_Opts, "menu_opts");
begin
Options := Menu_Opts (Men);
end Get_Options;
function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set
is
Mos : Menu_Option_Set;
begin
Get_Options (Men, Mos);
return Mos;
end Get_Options;
-------------------------------------------------------------------------------
procedure Set_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Win (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Win, "set_menu_win");
begin
Eti_Exception (Set_Menu_Win (Men, Win));
end Set_Window;
function Get_Window (Men : Menu) return Window
is
function Menu_Win (Men : Menu) return Window;
pragma Import (C, Menu_Win, "menu_win");
W : constant Window := Menu_Win (Men);
begin
return W;
end Get_Window;
procedure Set_Sub_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Sub (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Sub, "set_menu_sub");
begin
Eti_Exception (Set_Menu_Sub (Men, Win));
end Set_Sub_Window;
function Get_Sub_Window (Men : Menu) return Window
is
function Menu_Sub (Men : Menu) return Window;
pragma Import (C, Menu_Sub, "menu_sub");
W : constant Window := Menu_Sub (Men);
begin
return W;
end Get_Sub_Window;
procedure Scale (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function M_Scale (Men : Menu;
Yp, Xp : C_Int_Access) return Eti_Error;
pragma Import (C, M_Scale, "scale_menu");
X, Y : aliased C_Int;
begin
Eti_Exception (M_Scale (Men, Y'Access, X'Access));
Lines := Line_Count (Y);
Columns := Column_Count (X);
end Scale;
-------------------------------------------------------------------------------
procedure Position_Cursor (Men : Menu)
is
function Pos_Menu_Cursor (Men : Menu) return Eti_Error;
pragma Import (C, Pos_Menu_Cursor, "pos_menu_cursor");
begin
Eti_Exception (Pos_Menu_Cursor (Men));
end Position_Cursor;
-------------------------------------------------------------------------------
procedure Set_Mark (Men : Menu;
Mark : String)
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Mark (Men : Menu;
Mark : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Mark, "set_menu_mark");
Txt : char_array (0 .. Mark'Length);
Len : size_t;
begin
To_C (Mark, Txt, Len);
Eti_Exception (Set_Mark (Men, Txt (Txt'First)'Access));
end Set_Mark;
procedure Mark (Men : Menu;
Mark : out String)
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
Fill_String (Get_Menu_Mark (Men), Mark);
end Mark;
function Mark (Men : Menu) return String
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
return Fill_String (Get_Menu_Mark (Men));
end Mark;
-------------------------------------------------------------------------------
procedure Set_Foreground
(Men : Menu;
Fore : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Fore (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Fore, "set_menu_fore");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Fore);
begin
Eti_Exception (Set_Menu_Fore (Men, Ch));
end Set_Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
end Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
Color := Menu_Fore (Men).Color;
end Foreground;
procedure Set_Background
(Men : Menu;
Back : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Back (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Back, "set_menu_back");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Back);
begin
Eti_Exception (Set_Menu_Back (Men, Ch));
end Set_Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
end Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
Color := Menu_Back (Men).Color;
end Background;
procedure Set_Grey (Men : Menu;
Grey : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Grey (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Grey, "set_menu_grey");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Grey);
begin
Eti_Exception (Set_Menu_Grey (Men, Ch));
end Set_Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
end Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
Color := Menu_Grey (Men).Color;
end Grey;
procedure Set_Pad_Character (Men : Menu;
Pad : Character := Space)
is
function Set_Menu_Pad (Men : Menu;
Ch : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Pad, "set_menu_pad");
begin
Eti_Exception (Set_Menu_Pad (Men, C_Int (Character'Pos (Pad))));
end Set_Pad_Character;
procedure Pad_Character (Men : Menu;
Pad : out Character)
is
function Menu_Pad (Men : Menu) return C_Int;
pragma Import (C, Menu_Pad, "menu_pad");
begin
Pad := Character'Val (Menu_Pad (Men));
end Pad_Character;
-------------------------------------------------------------------------------
procedure Set_Spacing (Men : Menu;
Descr : Column_Position := 0;
Row : Line_Position := 0;
Col : Column_Position := 0)
is
function Set_Spacing (Men : Menu;
D, R, C : C_Int) return Eti_Error;
pragma Import (C, Set_Spacing, "set_menu_spacing");
begin
Eti_Exception (Set_Spacing (Men,
C_Int (Descr),
C_Int (Row),
C_Int (Col)));
end Set_Spacing;
procedure Spacing (Men : Menu;
Descr : out Column_Position;
Row : out Line_Position;
Col : out Column_Position)
is
type C_Int_Access is access all C_Int;
function Get_Spacing (Men : Menu;
D, R, C : C_Int_Access) return Eti_Error;
pragma Import (C, Get_Spacing, "menu_spacing");
D, R, C : aliased C_Int;
begin
Eti_Exception (Get_Spacing (Men,
D'Access,
R'Access,
C'Access));
Descr := Column_Position (D);
Row := Line_Position (R);
Col := Column_Position (C);
end Spacing;
-------------------------------------------------------------------------------
function Set_Pattern (Men : Menu;
Text : String) return Boolean
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Pattern (Men : Menu;
Pattern : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Pattern, "set_menu_pattern");
S : char_array (0 .. Text'Length);
L : size_t;
Res : Eti_Error;
begin
To_C (Text, S, L);
Res := Set_Pattern (Men, S (S'First)'Access);
case Res is
when E_No_Match =>
return False;
when others =>
Eti_Exception (Res);
return True;
end case;
end Set_Pattern;
procedure Pattern (Men : Menu;
Text : out String)
is
function Get_Pattern (Men : Menu) return chars_ptr;
pragma Import (C, Get_Pattern, "menu_pattern");
begin
Fill_String (Get_Pattern (Men), Text);
end Pattern;
-------------------------------------------------------------------------------
procedure Set_Format (Men : Menu;
Lines : Line_Count;
Columns : Column_Count)
is
function Set_Menu_Fmt (Men : Menu;
Lin : C_Int;
Col : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Fmt, "set_menu_format");
begin
Eti_Exception (Set_Menu_Fmt (Men,
C_Int (Lines),
C_Int (Columns)));
end Set_Format;
procedure Format (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function Menu_Fmt (Men : Menu;
Y, X : C_Int_Access) return Eti_Error;
pragma Import (C, Menu_Fmt, "menu_format");
L, C : aliased C_Int;
begin
Eti_Exception (Menu_Fmt (Men, L'Access, C'Access));
Lines := Line_Count (L);
Columns := Column_Count (C);
end Format;
-------------------------------------------------------------------------------
procedure Set_Item_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Init, "set_item_init");
begin
Eti_Exception (Set_Item_Init (Men, Proc));
end Set_Item_Init_Hook;
procedure Set_Item_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Term, "set_item_term");
begin
Eti_Exception (Set_Item_Term (Men, Proc));
end Set_Item_Term_Hook;
procedure Set_Menu_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Init, "set_menu_init");
begin
Eti_Exception (Set_Menu_Init (Men, Proc));
end Set_Menu_Init_Hook;
procedure Set_Menu_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Term, "set_menu_term");
begin
Eti_Exception (Set_Menu_Term (Men, Proc));
end Set_Menu_Term_Hook;
function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Init, "item_init");
begin
return Item_Init (Men);
end Get_Item_Init_Hook;
function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Term, "item_term");
begin
return Item_Term (Men);
end Get_Item_Term_Hook;
function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Init, "menu_init");
begin
return Menu_Init (Men);
end Get_Menu_Init_Hook;
function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Term, "menu_term");
begin
return Menu_Term (Men);
end Get_Menu_Term_Hook;
-------------------------------------------------------------------------------
procedure Redefine (Men : Menu;
Items : Item_Array_Access)
is
function Set_Items (Men : Menu;
Items : System.Address) return Eti_Error;
pragma Import (C, Set_Items, "set_menu_items");
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
Eti_Exception (Set_Items (Men, Items.all'Address));
end if;
end Redefine;
function Item_Count (Men : Menu) return Natural
is
function Count (Men : Menu) return C_Int;
pragma Import (C, Count, "item_count");
begin
return Natural (Count (Men));
end Item_Count;
function Items (Men : Menu;
Index : Positive) return Item
is
use I_Array;
function C_Mitems (Men : Menu) return Pointer;
pragma Import (C, C_Mitems, "menu_items");
P : Pointer := C_Mitems (Men);
begin
if P = null or else Index > Item_Count (Men) then
raise Menu_Exception;
else
P := P + ptrdiff_t (C_Int (Index) - 1);
return P.all;
end if;
end Items;
-------------------------------------------------------------------------------
function Create (Items : Item_Array_Access) return Menu
is
function Newmenu (Items : System.Address) return Menu;
pragma Import (C, Newmenu, "new_menu");
M : Menu;
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
M := Newmenu (Items.all'Address);
if M = Null_Menu then
raise Menu_Exception;
end if;
return M;
end if;
end Create;
procedure Delete (Men : in out Menu)
is
function Free (Men : Menu) return Eti_Error;
pragma Import (C, Free, "free_menu");
begin
Eti_Exception (Free (Men));
Men := Null_Menu;
end Delete;
------------------------------------------------------------------------------
function Driver (Men : Menu;
Key : Key_Code) return Driver_Result
is
function Driver (Men : Menu;
Key : C_Int) return Eti_Error;
pragma Import (C, Driver, "menu_driver");
R : constant Eti_Error := Driver (Men, C_Int (Key));
begin
case R is
when E_Unknown_Command =>
return Unknown_Request;
when E_No_Match =>
return No_Match;
when E_Request_Denied | E_Not_Selectable =>
return Request_Denied;
when others =>
Eti_Exception (R);
return Menu_Ok;
end case;
end Driver;
procedure Free (IA : in out Item_Array_Access;
Free_Items : Boolean := False)
is
procedure Release is new Ada.Unchecked_Deallocation
(Item_Array, Item_Array_Access);
begin
if IA /= null and then Free_Items then
for I in IA'First .. (IA'Last - 1) loop
if IA.all (I) /= Null_Item then
Delete (IA.all (I));
end if;
end loop;
end if;
Release (IA);
end Free;
-------------------------------------------------------------------------------
function Default_Menu_Options return Menu_Option_Set
is
begin
return Get_Options (Null_Menu);
end Default_Menu_Options;
function Default_Item_Options return Item_Option_Set
is
begin
return Get_Options (Null_Item);
end Default_Item_Options;
-------------------------------------------------------------------------------
end Terminal_Interface.Curses.Menus;
|
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser 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 --
-- --
--------------------------------------------------------------------------------
-- $Author$
-- $Date$
-- $Revision$
with Kernel; use Kernel;
with System.Storage_Elements; use System.Storage_Elements;
with System.Unsigned_Types; use System.Unsigned_Types;
with System.Address_To_Access_Conversions;
with Unchecked_Deallocation;
with Reporter;
with RASCAL.Utility; use RASCAL.Utility;
with RASCAL.OS;
package body RASCAL.Memory is
type MemoryBlock;
type Ptr_MemoryBlock is access MemoryBlock;
type MemoryBlock is array (Integer range <>) of Integer;
type bytearray is array(0..3) of Short_Short_Unsigned;
type halfwordarray is array(0..1) of Short_Short_Unsigned;
type lonely_byte is array(0..0) of Short_Short_Unsigned;
type PString is new String(1..1024);
--
package AddressToStrAccess is new System.Address_To_Access_Conversions
(object => PString);
--
package AddressToIntAccess is new System.Address_To_Access_Conversions
(object => bytearray);
--
package AddressToHWAccess is new System.Address_To_Access_Conversions
(object => halfwordarray);
--
package AddressToByteAccess is new System.Address_To_Access_Conversions
(object => lonely_byte);
type MemoryBlockStructure;
type MemoryBlockStructurePtr is access MemoryBlockStructure;
type MemoryBlockStructure is
record
object_ptr : Ptr_MemoryBlock;
object_adr : mem_adr_type;
next : MemoryBlockStructurePtr := null;
end record;
Anker,ptr : MemoryBlockStructurePtr;
firsttime : Boolean := true;
times : Integer := 0;
times2: Integer := 0;
--procedure FreeMemoryBlock is new Unchecked_Deallocation
-- (MemoryBlock, Ptr_MemoryBlock);
-- now a hack to address bug in GNAT 3.03
procedure FreeMemoryBlock (Mem : in out Ptr_MemoryBlock) is
procedure free (Addr: in System.Address);
pragma Import (C,free);
use type System.Storage_Elements.Storage_Offset;
begin
if Mem /= null then
free (Mem.all'Address - 8);
Mem := null;
end if;
end FreeMemoryBlock;
--end hack
procedure FreeListElement is new Unchecked_Deallocation
(MemoryBlockStructure, MemoryBlockStructurePtr);
function Allocate (amount : in Integer) return mem_adr_type is
pointer : Ptr_MemoryBlock;
returnintptr : mem_adr_type;
iteration : Integer := 0;
byte_amount : Integer;
begin
times := times + 1;
-- Debug.ErrorLog("Allocate Aufruf Nr. "&intstr(times));
if (amount rem 4) = 0 then
byte_amount := amount / 4;
else
byte_amount := (amount / 4) + 1;
end if;
pointer := new MemoryBlock (0..byte_amount-1);
pointer := new MemoryBlock (0..byte_amount-1);
returnintptr := pointer(0)'Address;
if firsttime then
Anker := new MemoryBlockStructure;
firsttime := false;
end if;
ptr := Anker;
while ptr.next /= null loop
ptr := ptr.next;
iteration := iteration + 1;
-- Debug.ErrorLog("Iteration: "&intstr(iteration));
end loop;
ptr.next := new MemoryBlockStructure;
ptr := ptr.next;
ptr.object_ptr := pointer;
ptr.object_adr := returnintptr;
return returnintptr;
end Allocate;
function AllocateFixed (amount : in Integer) return mem_adr_type is
pointer : Ptr_MemoryBlock;
byte_amount : Integer;
begin
if (amount rem 4) = 0 then
byte_amount := amount / 4;
else
byte_amount := (amount / 4) + 1;
end if;
pointer := new MemoryBlock (0..byte_amount-1);
return pointer(0)'Address;
end AllocateFixed;
procedure Deallocate (pointer : in mem_adr_type) is
found : Boolean := false;
index : Integer := 1;
prev : MemoryBlockStructurePtr;
iteration : Integer := 0;
begin
times2 := times2 + 1;
-- Debug.ErrorLog("Deallocate Aufruf Nr. "&intstr(times2));
ptr := Anker;
while not found and ptr.next /= null loop
prev := ptr;
ptr := ptr.next;
iteration := iteration + 1;
-- Debug.ErrorLog("Iteration: "&intstr(iteration));
if ptr.object_adr = pointer then
found := true;
end if;
end loop;
if found then
prev.next := ptr.next;
-- Debug.ErrorLog("Freeing memory...");
-- Debug.ErrorLog("Ptr is: " & intstr(Integer(ptr.object_adr)));
FreeMemoryBlock(ptr.object_ptr);
-- Debug.ErrorLog("Freeing structure...");
FreeListElement(ptr);
end if;
end Deallocate;
--
function GetByte (Adr : in Address;
Offset : in Integer := 0) return Integer is
Ptr : AddressToByteAccess.Object_Pointer;
realword : System.Unsigned_Types.Unsigned := 0;
begin
Ptr := AddressToByteAccess.To_Pointer(Adr+Storage_Offset(Offset));
realword := System.Unsigned_Types.Unsigned(Ptr(0));
return Unsigned_To_Int(realword);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.GetByte"));
raise;
end GetByte;
--
function GetWordBig (Adr : in Address;
Offset : in Integer := 0) return Integer is
Ptr : AddressToIntAccess.Object_Pointer;
realword : System.Unsigned_Types.Unsigned := 0;
begin
Ptr := AddressToIntAccess.To_Pointer(Adr+Storage_Offset(Offset));
realword := System.Unsigned_Types.Unsigned(Ptr(3)) + Shift_Left(System.Unsigned_Types.Unsigned(Ptr(2)),8)
+ Shift_Left(System.Unsigned_Types.Unsigned(Ptr(1)),16)
+ Shift_Left(System.Unsigned_Types.Unsigned(Ptr(0)),24);
return Unsigned_To_Int(realword);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.GetWordBig"));
raise;
end GetWordBig;
--
function GetWord (Adr : in Address;
Offset : in Integer := 0) return Integer is
Ptr : AddressToIntAccess.Object_Pointer;
realword : Unsigned := 0;
begin
Ptr := AddressToIntAccess.To_Pointer(Adr+Storage_Offset(Offset));
realword := Unsigned(Ptr(0)) + Shift_Left(Unsigned(Ptr(1)),8)
+ Shift_Left(Unsigned(Ptr(2)),16)
+ Shift_Left(Unsigned(Ptr(3)),24);
return Unsigned_To_Int(realword);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.GetWord"));
raise;
end GetWord;
--
procedure PutByte (Byte : in Integer;
Adr : in Address;
Offset : in Integer := 0) is
Ptr : AddressToByteAccess.Object_Pointer;
realword : Unsigned;
begin
Ptr := AddressToByteAccess.To_Pointer(Adr+Storage_Offset(Offset));
realword := Int_To_Unsigned (Byte);
Ptr(0) := Short_Short_Unsigned(realword and 16#000000FF#);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.PutByte!"));
raise;
end PutByte;
--
procedure PutWord (Word : in Integer;
Adr : in Address;
Offset : in Integer := 0) is
Ptr : AddressToIntAccess.Object_Pointer;
realword : Unsigned;
begin
Ptr := AddressToIntAccess.To_Pointer(Adr+Storage_Offset(Offset));
realword := Int_To_Unsigned (Word);
Ptr(0) := Short_Short_Unsigned(realword and 16#000000FF#);
Ptr(1) := Short_Short_Unsigned(Shift_Right(realword and 16#0000FF00#,8));
Ptr(2) := Short_Short_Unsigned(Shift_Right(realword and 16#00FF0000#,16));
Ptr(3) := Short_Short_Unsigned(Shift_Right(realword and 16#FF000000#,24));
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.PutWord!"));
raise;
end PutWord;
--
function MemoryToString (Adr : in Address;
Offset : in Integer := 0;
Amount : in Integer) return String is
Str : String(1..1024);
i : Integer := 1;
j : Integer := 1;
Ptr : AddressToStrAccess.Object_Pointer;
Chr : Character;
begin
Ptr := AddressToStrAccess.To_Pointer(Adr+Storage_Offset(Offset));
i := Ptr'First;
Chr := Ptr(i);
while j <= Amount loop
Str(j) := Chr;
j := j + 1;
i := i + 1;
Chr := Ptr(i);
end loop;
return Str(1..j-1);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.MemoryToString!"));
raise;
end MemoryToString;
--
function MemoryToString (Adr : in Address;
Offset : in Integer := 0;
Terminator : in Character := Character'Val(31))
return String is
Str : String(1..1024);
i : Integer := 1;
j : Integer := 1;
Ptr : AddressToStrAccess.Object_Pointer;
Chr : Character;
begin
Ptr := AddressToStrAccess.To_Pointer(Adr+Storage_Offset(Offset));
i := Ptr'First;
Chr := Ptr(i);
while Chr > Terminator loop
Str(j) := Chr;
j := j + 1;
i := i + 1;
Chr := Ptr(i);
end loop;
return Str(1..j-1);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.MemoryToString!"));
raise;
end MemoryToString;
--
function Read_String (Adr : in Address;
Offset : in Integer := 0;
Terminator : in Character := Character'Val(31))
return String is
Str : String(1..1024);
i : Integer := 1;
j : Integer := 1;
Ptr : AddressToStrAccess.Object_Pointer;
Chr : Character;
begin
Ptr := AddressToStrAccess.To_Pointer(Adr+Storage_Offset(Offset));
i := Ptr'First;
Chr := Ptr(i);
while Chr /= Terminator loop
Str(j) := Chr;
j := j + 1;
i := i + 1;
Chr := Ptr(i);
end loop;
return Str(1..j-1);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.MemoryToString!"));
raise;
end Read_String;
--
function Get_Line (Adr : in Address;
Offset : in Integer := 0) return String is
Str : String(1..1024);
i : Integer := 1;
j : Integer := 1;
Ptr : AddressToStrAccess.Object_Pointer;
Chr : Character;
begin
Ptr := AddressToStrAccess.To_Pointer(Adr+Storage_Offset(Offset));
i := Ptr'First;
Chr := Ptr(i);
while Chr /= ASCII.LF loop
Str(j) := Chr;
j := j + 1;
i := i + 1;
Chr := Ptr(i);
end loop;
return Str(1..j-1);
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.Get_line"));
raise;
end Get_Line;
--
procedure StringToMemory (Str : in String;
Adr : in Address;
Offset : in Integer := 0;
padlength : in Integer := 0;
Terminator : in Character := Character'Val(0)) is
Ptr : AddressToStrAccess.Object_Pointer;
i,j : Integer;
begin
Ptr := AddressToStrAccess.To_Pointer(Adr+Storage_Offset(Offset));
i := Str'First;
j := 1;
while i <= Str'Last loop
Ptr(j) := Str(i);
i := i + 1;
j := j + 1;
end loop;
Ptr(j) := Terminator;
for j in Str'Length+1..padlength loop
Ptr(j) := Terminator;
end loop;
exception
when others => pragma Debug(Reporter.Report("Exception raised in Memory.StringToMemory!"));
raise;
end StringToMemory;
--
procedure MemCopy (Sourceadr : in Address;
Destadr : in Address;
Dest_offset : in Integer := 0;
Length : in Integer) is
begin
for i in 0..Length-1 loop
PutByte (GetByte(Sourceadr,i),Destadr,i+Dest_offset);
end loop;
end MemCopy;
--
end RASCAL.Memory;
|
--
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ada.unchecked_conversion;
with m4.layout;
package m4.scb
with spark_mode => on
is
------------------------------------------
-- Interrupt Control and State Register --
------------------------------------------
-- Provides software control of the NMI, PendSV, and SysTick exceptions, and
-- provides interrupt status information (ARMv7-M Arch. Ref. Manual, p.655).
type t_SCB_ICSR is record
VECTACTIVE : bits_9;
RETTOBASE : bit;
VECTPENDING : bits_10;
ISRPENDING : boolean;
PENDSTCLR : bit;
PENDSTSET : bit;
PENDSVCLR : bit;
PENDSVSET : bit;
NMIPENDSET : bit;
end record
with size => 32;
for t_SCB_ICSR use record
VECTACTIVE at 0 range 0 .. 8;
RETTOBASE at 0 range 11 .. 11;
VECTPENDING at 0 range 12 .. 21;
ISRPENDING at 0 range 22 .. 22;
PENDSTCLR at 0 range 25 .. 25;
PENDSTSET at 0 range 26 .. 26;
PENDSVCLR at 0 range 27 .. 27;
PENDSVSET at 0 range 28 .. 28;
NMIPENDSET at 0 range 31 .. 31;
end record;
------------------------------------------------------
-- Application interrupt and reset control register --
------------------------------------------------------
type t_SCB_AIRCR is record
VECTKEY : unsigned_16;
ENDIANESS : bit;
reserved_11_14 : bits_4;
PRIGROUP : bits_3;
reserved_3_7 : bits_5;
SYSRESETREQ : bit;
VECTCLRACTIVE : bit;
VECTRESET : bit;
end record
with size => 32;
for t_SCB_AIRCR use record
VECTKEY at 0 range 16 .. 31;
ENDIANESS at 0 range 15 .. 15;
reserved_11_14 at 0 range 11 .. 14;
PRIGROUP at 0 range 8 .. 10;
reserved_3_7 at 0 range 3 .. 7;
SYSRESETREQ at 0 range 2 .. 2;
VECTCLRACTIVE at 0 range 1 .. 1;
VECTRESET at 0 range 0 .. 0;
end record;
----------------------------------------------
-- Configuration and control register (CCR) --
----------------------------------------------
-- The CCR controls entry to Thread mode
type t_SCB_CCR is record
NONBASETHRDENA : boolean; -- If true, processor can enter Thread mode
-- from any level under the control of an
-- EXC_RETURN
USERSETMPEND : boolean;
UNALIGN_TRP : boolean;
DIV_0_TRP : boolean;
BFHFNMIGN : boolean;
STKALIGN : boolean;
end record
with size => 32;
for t_SCB_CCR use record
NONBASETHRDENA at 0 range 0 .. 0;
USERSETMPEND at 0 range 1 .. 1;
UNALIGN_TRP at 0 range 3 .. 3;
DIV_0_TRP at 0 range 4 .. 4;
BFHFNMIGN at 0 range 8 .. 8;
STKALIGN at 0 range 9 .. 9;
end record;
-----------------------------------------------
-- System handler priority registers (SHPRx) --
-----------------------------------------------
type t_priority is record
reserved : bits_4;
priority : bits_4;
end record
with pack, size => 8;
-- SHPR1
type t_SCB_SHPR1 is record
mem_fault : t_priority;
bus_fault : t_priority;
usage_fault : t_priority;
end record
with size => 32;
for t_SCB_SHPR1 use record
mem_fault at 0 range 0 .. 7;
bus_fault at 0 range 8 .. 15;
usage_fault at 0 range 16 .. 23;
end record;
-- SHPR2
type t_SCB_SHPR2 is record
svc_call : t_priority;
end record
with size => 32;
for t_SCB_SHPR2 use record
svc_call at 0 range 24 .. 31;
end record;
-- SHPR3
type t_SCB_SHPR3 is record
pendsv : t_priority;
systick : t_priority;
end record
with size => 32;
for t_SCB_SHPR3 use record
pendsv at 0 range 16 .. 23;
systick at 0 range 24 .. 31;
end record;
-----------------------------------------------
-- System Handler Control and State Register --
-----------------------------------------------
type t_SCB_SHCSR is record
MEMFAULTACT : boolean; -- MemManage exception active
BUSFAULTACT : boolean; -- BusFault exception active
reserved_3 : bit;
USGFAULTACT : boolean; -- UsageFault exception active
reserved_4_6 : bits_3;
SVCALLACT : boolean; -- SVCall active
MONITORACT : boolean; -- Debug monitor active
reserved_9 : bit;
PENDSVACT : boolean; -- PendSV exception active
SYSTICKACT : boolean; -- SysTick exception active
USGFAULTPENDED : boolean; -- UsageFault pending
MEMFAULTPENDED : boolean; -- MemManage pending
BUSFAULTPENDED : boolean; -- BusFault pending
SVCALLPENDED : boolean; -- SVCall pending
MEMFAULTENA : boolean; -- MemManage enable
BUSFAULTENA : boolean; -- BusFault enable
USGFAULTENA : boolean; -- UsageFault enable
end record
with size => 32;
for t_SCB_SHCSR use record
MEMFAULTACT at 0 range 0 .. 0;
BUSFAULTACT at 0 range 1 .. 1;
reserved_3 at 0 range 2 .. 2;
USGFAULTACT at 0 range 3 .. 3;
reserved_4_6 at 0 range 4 .. 6;
SVCALLACT at 0 range 7 .. 7;
MONITORACT at 0 range 8 .. 8;
reserved_9 at 0 range 9 .. 9;
PENDSVACT at 0 range 10 .. 10;
SYSTICKACT at 0 range 11 .. 11;
USGFAULTPENDED at 0 range 12 .. 12;
MEMFAULTPENDED at 0 range 13 .. 13;
BUSFAULTPENDED at 0 range 14 .. 14;
SVCALLPENDED at 0 range 15 .. 15;
MEMFAULTENA at 0 range 16 .. 16;
BUSFAULTENA at 0 range 17 .. 17;
USGFAULTENA at 0 range 18 .. 18;
end record;
----------------------------------------
-- Configurable Fault Status Register --
----------------------------------------
--
-- Memory Management Fault Status Register
--
type t_MMFSR is record
IACCVIOL : boolean;
DACCVIOL : boolean;
reserved_2 : bit;
MUNSTKERR : boolean;
MSTKERR : boolean;
MLSPERR : boolean;
reserved_6 : bit;
MMARVALID : boolean;
end record
with size => 8;
pragma pack (t_MMFSR);
--
-- Bus Fault Status Register
--
type t_BFSR is record
IBUSERR : boolean;
PRECISERR : boolean;
IMPRECISERR : boolean;
UNSTKERR : boolean;
STKERR : boolean;
LSPERR : boolean;
reserved_6 : bit;
BFARVALID : boolean;
end record
with size => 8;
pragma pack (t_BFSR);
--
-- Usage Fault Status Register
--
type t_UFSR is record
UNDEFINSTR : boolean;
INVSTATE : boolean;
INVPC : boolean;
NOCP : boolean;
UNALIGNED : boolean;
DIVBYZERO : boolean;
end record
with size => 16;
for t_UFSR use record
UNDEFINSTR at 0 range 0 .. 0;
INVSTATE at 0 range 1 .. 1;
INVPC at 0 range 2 .. 2;
NOCP at 0 range 3 .. 3;
UNALIGNED at 0 range 8 .. 8;
DIVBYZERO at 0 range 9 .. 9;
end record;
type t_SCB_CFSR is record
MMFSR : t_MMFSR;
BFSR : t_BFSR;
UFSR : t_UFSR;
end record
with size => 32;
function to_unsigned_32 is new ada.unchecked_conversion
(t_SCB_CFSR, unsigned_32);
--------------------------------
-- Hard fault status register --
--------------------------------
type t_SCB_HFSR is record
VECTTBL : boolean; -- Vector table hard fault
FORCED : boolean; -- Forced hard fault
DEBUG_VT : bit; -- Reserved for Debug use
end record
with size => 32;
for t_SCB_HFSR use record
VECTTBL at 0 range 1 .. 1;
FORCED at 0 range 30 .. 30;
DEBUG_VT at 0 range 31 .. 31;
end record;
--------------------------------------
-- MemManage Fault Address Register --
--------------------------------------
type t_SCB_MMFAR is record
ADDRESS : system_address;
end record
with size => 32;
--------------------
-- SCB peripheral --
--------------------
-- /!\ ACTLR register is not in the same record
type t_SCB_peripheral is record
ICSR : t_SCB_ICSR;
VTOR : system_address;
AIRCR : t_SCB_AIRCR;
CCR : t_SCB_CCR;
SHPR1 : t_SCB_SHPR1;
SHPR2 : t_SCB_SHPR2;
SHPR3 : t_SCB_SHPR3;
SHCSR : t_SCB_SHCSR;
CFSR : t_SCB_CFSR;
HFSR : t_SCB_HFSR;
MMFAR : t_SCB_MMFAR;
end record;
for t_SCB_peripheral use record
ICSR at 16#04# range 0 .. 31;
VTOR at 16#08# range 0 .. 31;
AIRCR at 16#0C# range 0 .. 31;
CCR at 16#14# range 0 .. 31;
SHPR1 at 16#18# range 0 .. 31;
SHPR2 at 16#1C# range 0 .. 31;
SHPR3 at 16#20# range 0 .. 31;
SHCSR at 16#24# range 0 .. 31;
CFSR at 16#28# range 0 .. 31;
HFSR at 16#2C# range 0 .. 31;
MMFAR at 16#34# range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
SCB : t_SCB_peripheral
with
import,
volatile,
address => m4.layout.SCB_base2;
procedure reset;
end m4.scb;
|
with Unchecked_Conversion;
package Atomic5 is
type Byte is mod 2 ** 8;
for Byte'Size use 8;
type Unsigned_32 is mod 2 ** 32;
for Unsigned_32'Size use 32;
type R is record
A,B,C,D : Byte;
end record;
for R'Alignment use 4;
pragma Atomic (R);
function Conv is new Unchecked_Conversion (R, Unsigned_32);
procedure Proc1;
procedure Proc2;
end Atomic5;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2011, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.CMOF;
with Matreshka.Internals.Strings;
package AMF.Internals.Tables.CMOF_Attributes is
function Internal_Get_Alias
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Alias
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- ElementImport => ElementImport::alias
function Internal_Get_Annotated_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Comment => Comment::annotatedElement
function Internal_Get_Association
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Association
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Property => Property::association
function Internal_Get_Attribute
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Classifier::attribute
-- Class => Classifier::attribute
-- DataType => Classifier::attribute
-- Enumeration => Classifier::attribute
-- PrimitiveType => Classifier::attribute
function Internal_Get_Body
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_String;
-- OpaqueExpression => OpaqueExpression::body
function Internal_Get_Body
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Body
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- Comment => Comment::body
function Internal_Get_Body_Condition
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Body_Condition
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Operation => Operation::bodyCondition
function Internal_Get_Class
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Class
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Operation => Operation::class
-- Property => Property::class
function Internal_Get_Constrained_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Constraint => Constraint::constrainedElement
function Internal_Get_Context
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Context
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Constraint => Constraint::context
function Internal_Get_Datatype
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Datatype
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Operation => Operation::datatype
-- Property => Property::datatype
function Internal_Get_Default
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Default
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- Parameter => Parameter::default
-- Property => Property::default
function Internal_Get_Direction
(Self : AMF.Internals.AMF_Element)
return AMF.CMOF.CMOF_Parameter_Direction_Kind;
procedure Internal_Set_Direction
(Self : AMF.Internals.AMF_Element;
To : AMF.CMOF.CMOF_Parameter_Direction_Kind);
-- Parameter => Parameter::direction
function Internal_Get_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Tag => Tag::element
function Internal_Get_Element_Import
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::elementImport
-- Class => Namespace::elementImport
-- DataType => Namespace::elementImport
-- Enumeration => Namespace::elementImport
-- Operation => Namespace::elementImport
-- Package => Namespace::elementImport
-- PrimitiveType => Namespace::elementImport
function Internal_Get_End_Type
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Association::endType
function Internal_Get_Enumeration
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Enumeration
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- EnumerationLiteral => EnumerationLiteral::enumeration
function Internal_Get_Feature
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Classifier::feature
-- Class => Classifier::feature
-- DataType => Classifier::feature
-- Enumeration => Classifier::feature
-- PrimitiveType => Classifier::feature
function Internal_Get_Featuring_Classifier
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Feature::featuringClassifier
-- Property => Feature::featuringClassifier
function Internal_Get_General
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Classifier::general
-- Class => Classifier::general
-- DataType => Classifier::general
-- Enumeration => Classifier::general
-- PrimitiveType => Classifier::general
function Internal_Get_Imported_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Imported_Element
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- ElementImport => ElementImport::importedElement
function Internal_Get_Imported_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::importedMember
-- Class => Namespace::importedMember
-- DataType => Namespace::importedMember
-- Enumeration => Namespace::importedMember
-- Operation => Namespace::importedMember
-- Package => Namespace::importedMember
-- PrimitiveType => Namespace::importedMember
function Internal_Get_Imported_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Imported_Package
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- PackageImport => PackageImport::importedPackage
function Internal_Get_Importing_Namespace
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Importing_Namespace
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- ElementImport => ElementImport::importingNamespace
-- PackageImport => PackageImport::importingNamespace
function Internal_Get_Inherited_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Classifier::inheritedMember
-- Class => Classifier::inheritedMember
-- DataType => Classifier::inheritedMember
-- Enumeration => Classifier::inheritedMember
-- PrimitiveType => Classifier::inheritedMember
function Internal_Get_Is_Abstract
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Abstract
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Class => Class::isAbstract
function Internal_Get_Is_Composite
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Composite
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Property => Property::isComposite
function Internal_Get_Is_Derived
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Derived
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Association => Association::isDerived
-- Property => Property::isDerived
function Internal_Get_Is_Derived_Union
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Derived_Union
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Property => Property::isDerivedUnion
function Internal_Get_Is_Final_Specialization
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Final_Specialization
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Association => Classifier::isFinalSpecialization
-- Class => Classifier::isFinalSpecialization
-- DataType => Classifier::isFinalSpecialization
-- Enumeration => Classifier::isFinalSpecialization
-- PrimitiveType => Classifier::isFinalSpecialization
function Internal_Get_Is_Leaf
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Leaf
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Operation => RedefinableElement::isLeaf
-- Property => RedefinableElement::isLeaf
function Internal_Get_Is_Ordered
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Ordered
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Operation => Operation::isOrdered
-- Parameter => MultiplicityElement::isOrdered
-- Property => MultiplicityElement::isOrdered
function Internal_Get_Is_Query
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Query
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Operation => Operation::isQuery
function Internal_Get_Is_Read_Only
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Read_Only
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Property => Property::isReadOnly
function Internal_Get_Is_Unique
(Self : AMF.Internals.AMF_Element)
return Boolean;
procedure Internal_Set_Is_Unique
(Self : AMF.Internals.AMF_Element;
To : Boolean);
-- Operation => Operation::isUnique
-- Parameter => MultiplicityElement::isUnique
-- Property => MultiplicityElement::isUnique
function Internal_Get_Language
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_String;
-- OpaqueExpression => OpaqueExpression::language
function Internal_Get_Lower
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Integer;
procedure Internal_Set_Lower
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Integer);
-- Operation => Operation::lower
-- Parameter => MultiplicityElement::lower
-- Property => MultiplicityElement::lower
function Internal_Get_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::member
-- Class => Namespace::member
-- DataType => Namespace::member
-- Enumeration => Namespace::member
-- Operation => Namespace::member
-- Package => Namespace::member
-- PrimitiveType => Namespace::member
function Internal_Get_Member_End
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Association::memberEnd
function Internal_Get_Merged_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Merged_Package
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- PackageMerge => PackageMerge::mergedPackage
function Internal_Get_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Name
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- Association => NamedElement::name
-- Class => NamedElement::name
-- Constraint => NamedElement::name
-- DataType => NamedElement::name
-- Enumeration => NamedElement::name
-- EnumerationLiteral => NamedElement::name
-- Expression => NamedElement::name
-- OpaqueExpression => NamedElement::name
-- Operation => NamedElement::name
-- Package => NamedElement::name
-- Parameter => NamedElement::name
-- PrimitiveType => NamedElement::name
-- Property => NamedElement::name
-- Tag => Tag::name
function Internal_Get_Namespace
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
-- Association => NamedElement::namespace
-- Class => NamedElement::namespace
-- Constraint => NamedElement::namespace
-- DataType => NamedElement::namespace
-- Enumeration => NamedElement::namespace
-- EnumerationLiteral => NamedElement::namespace
-- Expression => NamedElement::namespace
-- OpaqueExpression => NamedElement::namespace
-- Operation => NamedElement::namespace
-- Package => NamedElement::namespace
-- Parameter => NamedElement::namespace
-- PrimitiveType => NamedElement::namespace
-- Property => NamedElement::namespace
function Internal_Get_Navigable_Owned_End
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Association::navigableOwnedEnd
function Internal_Get_Nested_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Package => Package::nestedPackage
function Internal_Get_Nesting_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Nesting_Package
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Package => Package::nestingPackage
function Internal_Get_Operand
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Expression => Expression::operand
function Internal_Get_Operation
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Operation
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Parameter => Parameter::operation
function Internal_Get_Opposite
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Opposite
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Property => Property::opposite
function Internal_Get_Owned_Attribute
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Class => Class::ownedAttribute
-- DataType => DataType::ownedAttribute
-- Enumeration => DataType::ownedAttribute
-- PrimitiveType => DataType::ownedAttribute
function Internal_Get_Owned_Comment
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Element::ownedComment
-- Class => Element::ownedComment
-- Comment => Element::ownedComment
-- Constraint => Element::ownedComment
-- DataType => Element::ownedComment
-- ElementImport => Element::ownedComment
-- Enumeration => Element::ownedComment
-- EnumerationLiteral => Element::ownedComment
-- Expression => Element::ownedComment
-- OpaqueExpression => Element::ownedComment
-- Operation => Element::ownedComment
-- Package => Element::ownedComment
-- PackageImport => Element::ownedComment
-- PackageMerge => Element::ownedComment
-- Parameter => Element::ownedComment
-- PrimitiveType => Element::ownedComment
-- Property => Element::ownedComment
-- Tag => Element::ownedComment
function Internal_Get_Owned_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Element::ownedElement
-- Class => Element::ownedElement
-- Comment => Element::ownedElement
-- Constraint => Element::ownedElement
-- DataType => Element::ownedElement
-- ElementImport => Element::ownedElement
-- Enumeration => Element::ownedElement
-- EnumerationLiteral => Element::ownedElement
-- Expression => Element::ownedElement
-- OpaqueExpression => Element::ownedElement
-- Operation => Element::ownedElement
-- Package => Element::ownedElement
-- PackageImport => Element::ownedElement
-- PackageMerge => Element::ownedElement
-- Parameter => Element::ownedElement
-- PrimitiveType => Element::ownedElement
-- Property => Element::ownedElement
-- Tag => Element::ownedElement
function Internal_Get_Owned_End
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Association::ownedEnd
function Internal_Get_Owned_Literal
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Enumeration => Enumeration::ownedLiteral
function Internal_Get_Owned_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::ownedMember
-- Class => Namespace::ownedMember
-- DataType => Namespace::ownedMember
-- Enumeration => Namespace::ownedMember
-- Operation => Namespace::ownedMember
-- Package => Namespace::ownedMember
-- PrimitiveType => Namespace::ownedMember
function Internal_Get_Owned_Operation
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Class => Class::ownedOperation
-- DataType => DataType::ownedOperation
-- Enumeration => DataType::ownedOperation
-- PrimitiveType => DataType::ownedOperation
function Internal_Get_Owned_Parameter
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Operation::ownedParameter
function Internal_Get_Owned_Rule
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::ownedRule
-- Class => Namespace::ownedRule
-- DataType => Namespace::ownedRule
-- Enumeration => Namespace::ownedRule
-- Operation => Namespace::ownedRule
-- Package => Namespace::ownedRule
-- PrimitiveType => Namespace::ownedRule
function Internal_Get_Owned_Type
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Package => Package::ownedType
function Internal_Get_Owner
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
-- Association => Element::owner
-- Class => Element::owner
-- Comment => Element::owner
-- Constraint => Element::owner
-- DataType => Element::owner
-- ElementImport => Element::owner
-- Enumeration => Element::owner
-- EnumerationLiteral => Element::owner
-- Expression => Element::owner
-- OpaqueExpression => Element::owner
-- Operation => Element::owner
-- Package => Element::owner
-- PackageImport => Element::owner
-- PackageMerge => Element::owner
-- Parameter => Element::owner
-- PrimitiveType => Element::owner
-- Property => Element::owner
-- Tag => Element::owner
function Internal_Get_Owning_Association
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Owning_Association
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Property => Property::owningAssociation
function Internal_Get_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Package
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Association => Type::package
-- Class => Type::package
-- DataType => Type::package
-- Enumeration => Type::package
-- PrimitiveType => Type::package
function Internal_Get_Package_Import
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Namespace::packageImport
-- Class => Namespace::packageImport
-- DataType => Namespace::packageImport
-- Enumeration => Namespace::packageImport
-- Operation => Namespace::packageImport
-- Package => Namespace::packageImport
-- PrimitiveType => Namespace::packageImport
function Internal_Get_Package_Merge
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Package => Package::packageMerge
function Internal_Get_Packaged_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Package => Package::packagedElement
function Internal_Get_Postcondition
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Operation::postcondition
function Internal_Get_Precondition
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Operation::precondition
function Internal_Get_Qualified_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
-- Association => NamedElement::qualifiedName
-- Class => NamedElement::qualifiedName
-- Constraint => NamedElement::qualifiedName
-- DataType => NamedElement::qualifiedName
-- Enumeration => NamedElement::qualifiedName
-- EnumerationLiteral => NamedElement::qualifiedName
-- Expression => NamedElement::qualifiedName
-- OpaqueExpression => NamedElement::qualifiedName
-- Operation => NamedElement::qualifiedName
-- Package => NamedElement::qualifiedName
-- Parameter => NamedElement::qualifiedName
-- PrimitiveType => NamedElement::qualifiedName
-- Property => NamedElement::qualifiedName
function Internal_Get_Raised_Exception
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Operation::raisedException
function Internal_Get_Receiving_Package
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Receiving_Package
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- PackageMerge => PackageMerge::receivingPackage
function Internal_Get_Redefined_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => RedefinableElement::redefinedElement
-- Property => RedefinableElement::redefinedElement
function Internal_Get_Redefined_Operation
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => Operation::redefinedOperation
function Internal_Get_Redefined_Property
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Property => Property::redefinedProperty
function Internal_Get_Redefinition_Context
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Operation => RedefinableElement::redefinitionContext
-- Property => RedefinableElement::redefinitionContext
function Internal_Get_Related_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Association => Relationship::relatedElement
-- ElementImport => Relationship::relatedElement
-- PackageImport => Relationship::relatedElement
-- PackageMerge => Relationship::relatedElement
function Internal_Get_Source
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- ElementImport => DirectedRelationship::source
-- PackageImport => DirectedRelationship::source
-- PackageMerge => DirectedRelationship::source
function Internal_Get_Specification
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Specification
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Constraint => Constraint::specification
function Internal_Get_Subsetted_Property
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Property => Property::subsettedProperty
function Internal_Get_Super_Class
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- Class => Class::superClass
function Internal_Get_Tag_Owner
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Tag_Owner
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Tag => Tag::tagOwner
function Internal_Get_Target
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element;
-- ElementImport => DirectedRelationship::target
-- PackageImport => DirectedRelationship::target
-- PackageMerge => DirectedRelationship::target
function Internal_Get_Type
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element;
procedure Internal_Set_Type
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element);
-- Expression => TypedElement::type
-- OpaqueExpression => TypedElement::type
-- Operation => Operation::type
-- Parameter => TypedElement::type
-- Property => TypedElement::type
function Internal_Get_Upper
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Unlimited_Natural;
procedure Internal_Set_Upper
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Unlimited_Natural);
-- Operation => Operation::upper
-- Parameter => MultiplicityElement::upper
-- Property => MultiplicityElement::upper
function Internal_Get_Uri
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Uri
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- Package => Package::uri
function Internal_Get_Value
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access;
procedure Internal_Set_Value
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access);
-- Tag => Tag::value
function Internal_Get_Visibility
(Self : AMF.Internals.AMF_Element)
return AMF.CMOF.CMOF_Visibility_Kind;
procedure Internal_Set_Visibility
(Self : AMF.Internals.AMF_Element;
To : AMF.CMOF.CMOF_Visibility_Kind);
-- ElementImport => ElementImport::visibility
-- PackageImport => PackageImport::visibility
function Internal_Get_Visibility
(Self : AMF.Internals.AMF_Element)
return AMF.CMOF.Optional_CMOF_Visibility_Kind;
procedure Internal_Set_Visibility
(Self : AMF.Internals.AMF_Element;
To : AMF.CMOF.Optional_CMOF_Visibility_Kind);
-- Association => NamedElement::visibility
-- Class => NamedElement::visibility
-- Constraint => NamedElement::visibility
-- DataType => NamedElement::visibility
-- Enumeration => NamedElement::visibility
-- EnumerationLiteral => NamedElement::visibility
-- Expression => NamedElement::visibility
-- OpaqueExpression => NamedElement::visibility
-- Operation => NamedElement::visibility
-- Package => NamedElement::visibility
-- Parameter => NamedElement::visibility
-- PrimitiveType => NamedElement::visibility
-- Property => NamedElement::visibility
end AMF.Internals.Tables.CMOF_Attributes;
|
package Lv.Hal.Tick is
-- You have to call this function periodically
-- @param tick_period the call period of this function in milliseconds
procedure Inc (Tick_Period : Uint32_T);
-- Get the elapsed milliseconds since start up
-- @return the elapsed milliseconds
function Get return Uint32_T;
-- Get the elapsed milliseconds since a previous time stamp
-- @param prev_tick a previous time stamp (return value of systick_get() )
-- @return the elapsed milliseconds since 'prev_tick'
function Elaps (Prev_Tick : Uint32_T) return Uint32_T;
-------------
-- Imports --
-------------
pragma Import (C, Inc, "lv_tick_inc");
pragma Import (C, Get, "lv_tick_get");
pragma Import (C, Elaps, "lv_tick_elaps");
end Lv.Hal.Tick;
|
pragma License (Unrestricted);
with Ada.Exceptions;
with Ada.Task_Identification;
package Ada.Task_Termination is
pragma Preelaborate;
type Cause_Of_Termination is (Normal, Abnormal, Unhandled_Exception);
type Termination_Handler is access protected procedure (
Cause : Cause_Of_Termination;
T : Task_Identification.Task_Id;
X : Exceptions.Exception_Occurrence);
procedure Set_Dependents_Fallback_Handler (Handler : Termination_Handler);
function Current_Task_Fallback_Handler return Termination_Handler;
procedure Set_Specific_Handler (
T : Task_Identification.Task_Id;
Handler : Termination_Handler);
function Specific_Handler (T : Task_Identification.Task_Id)
return Termination_Handler;
pragma Inline (Set_Specific_Handler);
pragma Inline (Specific_Handler);
end Ada.Task_Termination;
|
-----------------------------------------------------------------------
-- util-encoders-aes -- AES encryption and decryption
-- Copyright (C) 2017, 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces;
private with Ada.Finalization;
-- The <b>Util.Encodes.SHA1</b> package generates SHA-1 hash according to
-- RFC3174 or [FIPS-180-1].
package Util.Encoders.AES is
type AES_Mode is (ECB, CBC, PCBC, CFB, OFB, CTR);
type AES_Padding is (NO_PADDING, ZERO_PADDING, PKCS7_PADDING);
type Key_Type is private;
-- ------------------------------
-- ------------------------------
subtype Block_Type is Ada.Streams.Stream_Element_Array (1 .. 16);
AES_128_Length : constant := 16;
AES_192_Length : constant := 24;
AES_256_Length : constant := 32;
subtype AES_128_Key is Ada.Streams.Stream_Element_Array (1 .. 16);
subtype AES_192_Key is Ada.Streams.Stream_Element_Array (1 .. 24);
subtype AES_256_Key is Ada.Streams.Stream_Element_Array (1 .. 32);
-- Align the size on an AES block size.
function Align (Size : in Ada.Streams.Stream_Element_Offset)
return Ada.Streams.Stream_Element_Offset is
(Block_Type'Length * ((Size + Block_Type'Length - 1) / Block_Type'Length));
type Word_Block_Type is array (1 .. 4) of Interfaces.Unsigned_32;
procedure Set_Encrypt_Key (Key : out Key_Type;
Data : in Secret_Key)
with Pre => Data.Length = 16 or Data.Length = 24 or Data.Length = 32;
procedure Set_Decrypt_Key (Key : out Key_Type;
Data : in Secret_Key)
with Pre => Data.Length = 16 or Data.Length = 24 or Data.Length = 32;
procedure Encrypt (Data : in out Word_Block_Type;
Key : in Key_Type);
procedure Encrypt (Input : in Block_Type;
Output : out Block_Type;
Key : in Key_Type);
procedure Encrypt (Input : in Word_Block_Type;
Output : out Word_Block_Type;
Key : in Key_Type);
procedure Encrypt (Input : in Ada.Streams.Stream_Element_Array;
Output : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Key : in Key_Type);
procedure Decrypt (Input : in Block_Type;
Output : out Block_Type;
Key : in Key_Type);
procedure Decrypt (Input : in Word_Block_Type;
Output : out Word_Block_Type;
Key : in Key_Type);
type Cipher is tagged limited private;
-- Set the encryption initialization vector before starting the encryption.
procedure Set_IV (E : in out Cipher;
IV : in Word_Block_Type);
procedure Set_IV (E : in out Cipher;
Key : in Secret_Key)
with Pre => Key.Length = 16;
procedure Set_IV (E : in out Cipher;
Key : in Secret_Key;
IV : in Word_Block_Type);
-- Set the padding.
procedure Set_Padding (E : in out Cipher;
Padding : in AES_Padding);
-- Get the padding used.
function Padding (E : in Cipher) return AES_Padding;
-- Return true if the cipher has a encryption/decryption key configured.
function Has_Key (E : in Cipher) return Boolean;
-- ------------------------------
-- AES encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- an SHA1 hexadecimal stream. The encoding alphabet is: 0123456789ABCDEF.
type Encoder is new Cipher and Util.Encoders.Transformer with private;
-- Set the encryption key to use.
procedure Set_Key (E : in out Encoder;
Data : in Secret_Key;
Mode : in AES_Mode := CBC);
-- Encodes the binary input stream represented by <b>Data</b> into
-- an SHA-1 hash output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Encoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset) with
Pre => E.Has_Key;
-- Finish encoding the input array.
overriding
procedure Finish (E : in out Encoder;
Into : in out Ada.Streams.Stream_Element_Array;
Last : in out Ada.Streams.Stream_Element_Offset) with
Pre => E.Has_Key and Into'Length >= Block_Type'Length,
Post => Last = Into'First - 1 or Last = Into'First + Block_Type'Length - 1;
-- Encrypt the secret using the encoder and return the encrypted value in the buffer.
-- The target buffer must be a multiple of 16-bytes block.
procedure Encrypt_Secret (E : in out Encoder;
Secret : in Secret_Key;
Into : out Ada.Streams.Stream_Element_Array) with
Pre => Into'Length mod 16 = 0 and
(case E.Padding is
when NO_PADDING => Secret.Length = Into'Length,
when PKCS7_PADDING | ZERO_PADDING => 16 * (1 + (Secret.Length / 16)) = Into'Length);
-- ------------------------------
-- AES encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- an SHA1 hexadecimal stream. The encoding alphabet is: 0123456789ABCDEF.
type Decoder is new Cipher and Util.Encoders.Transformer with private;
-- Set the decryption key to use.
procedure Set_Key (E : in out Decoder;
Data : in Secret_Key;
Mode : in AES_Mode := CBC);
-- Encodes the binary input stream represented by <b>Data</b> into
-- an SHA-1 hash output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Decoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset) with
Pre => E.Has_Key;
-- Finish encoding the input array.
overriding
procedure Finish (E : in out Decoder;
Into : in out Ada.Streams.Stream_Element_Array;
Last : in out Ada.Streams.Stream_Element_Offset);
-- Decrypt the content using the decoder and build the secret key.
procedure Decrypt_Secret (E : in out Decoder;
Data : in Ada.Streams.Stream_Element_Array;
Secret : in out Secret_Key) with
Pre => Data'Length mod 16 = 0 and
(case E.Padding is
when NO_PADDING => Secret.Length = Data'Length,
when PKCS7_PADDING | ZERO_PADDING => 16 * (1 + (Secret.Length / 16)) = Data'Length);
private
use Interfaces;
subtype Count_Type is Ada.Streams.Stream_Element_Offset range 0 .. 16;
type Block_Key is array (0 .. 59) of Unsigned_32;
type Key_Type is record
Key : Block_Key := (others => 0);
Rounds : Natural := 0;
end record;
type Cipher is limited new Ada.Finalization.Limited_Controlled with record
IV : Word_Block_Type := (others => 0);
Key : Key_Type;
Mode : AES_Mode := CBC;
Padding : AES_Padding := PKCS7_PADDING;
Data_Count : Count_Type := 0;
Data : Block_Type;
Data2 : Block_Type;
end record;
overriding
procedure Finalize (Object : in out Cipher);
type Encoder is new Cipher and Util.Encoders.Transformer with null record;
type Decoder is new Cipher and Util.Encoders.Transformer with null record;
end Util.Encoders.AES;
|
with Ada.Exceptions;
with Ada.Interrupts.Names;
with Ada.Unchecked_Conversion;
with System.Formatting;
with System.Long_Long_Integer_Types;
with System.Unwind.Occurrences;
with C.signal;
package body System.Native_Interrupts.Vector is
use type Ada.Interrupts.Parameterless_Handler;
use type C.signed_int;
use type C.unsigned_int;
use type C.signal.p_sig_fn_t;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
procedure Report (
Interrupt : Interrupt_Id;
X : Ada.Exceptions.Exception_Occurrence);
procedure Report (
Interrupt : Interrupt_Id;
X : Ada.Exceptions.Exception_Occurrence)
is
function Cast is
new Ada.Unchecked_Conversion (
Ada.Exceptions.Exception_Occurrence,
Unwind.Exception_Occurrence);
Name_Prefix : constant String := "Interrupt ";
Name : String (1 .. Name_Prefix'Length + Interrupt_Id'Width);
Name_Last : Natural;
Error : Boolean;
begin
Name (1 .. Name_Prefix'Length) := Name_Prefix;
Formatting.Image (
Word_Unsigned (Interrupt),
Name (Name_Prefix'Length + 1 .. Name'Last),
Name_Last,
Error => Error);
Unwind.Occurrences.Report (Cast (X), Name (1 .. Name_Last));
end Report;
type Signal_Rec is record
Installed_Handler : Parameterless_Handler;
Saved : aliased C.signal.p_sig_fn_t;
end record;
pragma Suppress_Initialization (Signal_Rec);
type Signal_Vec is
array (
C.signed_int range
C.signed_int (Ada.Interrupts.Names.First_Interrupt_Id) ..
C.signed_int (Ada.Interrupts.Names.Last_Interrupt_Id)) of
Signal_Rec;
pragma Suppress_Initialization (Signal_Vec);
Table : Signal_Vec;
procedure Handler (Signal_Number : C.signed_int)
with Convention => C;
procedure Handler (Signal_Number : C.signed_int) is
begin
Table (Signal_Number).Installed_Handler.all;
exception -- CXC3004, an exception propagated from a handler has no effect
when E : others =>
Report (Interrupt_Id (Signal_Number), E);
end Handler;
-- implementation
function Current_Handler (Interrupt : Interrupt_Id)
return Parameterless_Handler is
begin
return Table (Interrupt).Installed_Handler;
end Current_Handler;
procedure Exchange_Handler (
Old_Handler : out Parameterless_Handler;
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_Id)
is
Item : Signal_Rec
renames Table (Interrupt);
begin
Old_Handler := Item.Installed_Handler;
if Old_Handler = null and then New_Handler /= null then
declare
Old_Action : C.signal.p_sig_fn_t;
begin
Old_Action := C.signal.signal (
C.signed_int (Interrupt),
Handler'Access);
if Old_Action = C.signal.SIG_ERR then
raise Program_Error;
end if;
Old_Action := Item.Saved;
end;
elsif Old_Handler /= null and then New_Handler = null then
declare
Old_Action : C.signal.p_sig_fn_t;
begin
Old_Action := C.signal.signal (
C.signed_int (Interrupt),
Item.Saved);
if Old_Action = C.signal.SIG_ERR then
raise Program_Error;
end if;
end;
end if;
Item.Installed_Handler := New_Handler;
end Exchange_Handler;
end System.Native_Interrupts.Vector;
|
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Incr.Nodes.Joints is
type Joint (Document : Documents.Document_Access;
Arity : Natural) is new Node with private;
type Joint_Access is access all Joint'Class;
package Constructors is
procedure Initialize
(Self : aliased out Joint'Class;
Kind : Node_Kind;
Children : Node_Array);
procedure Initialize_Ancient
(Self : out Joint'Class;
Parent : Node_Access);
end Constructors;
private
type Versioned_Node_Array is array (Positive range <>) of
Versioned_Nodes.Container;
type Cached_Integer is record
Value : Integer := -1; -- -1 means invalid cache
Time : Version_Trees.Version;
end record;
type Cached_Spans is array (Span_Kinds) of Cached_Integer;
type Joint (Document : Documents.Document_Access;
Arity : Natural) is
new Node_With_Parent (Document) with
record
Kind : Node_Kind;
Kids : Versioned_Node_Array (1 .. Arity);
NC : Versioned_Booleans.Container;
NE : Versioned_Booleans.Container;
Span_Cache : Cached_Spans;
end record;
overriding function Arity (Self : Joint) return Natural;
overriding function Is_Token (Self : Joint) return Boolean;
overriding function Kind (Self : Joint) return Node_Kind;
overriding function Child
(Self : Joint;
Index : Positive;
Time : Version_Trees.Version) return Node_Access;
overriding procedure Set_Child
(Self : aliased in out Joint;
Index : Positive;
Value : Node_Access);
overriding function Nested_Changes
(Self : Joint;
From : Version_Trees.Version;
To : Version_Trees.Version) return Boolean;
overriding function Nested_Errors
(Self : Joint;
Time : Version_Trees.Version) return Boolean;
overriding function Span
(Self : aliased in out Joint;
Kind : Span_Kinds;
Time : Version_Trees.Version) return Natural;
overriding procedure Discard (Self : in out Joint);
overriding procedure On_Commit
(Self : in out Joint;
Parent : Node_Access);
end Incr.Nodes.Joints;
|
with Ada.Strings.Unbounded.Text_Io;
with Ada.Text_Io;
with Aof.Core.Objects;
with My_Objects;
-- This example highlights what I envision to be a typical use of the
-- object system. Here we define a widget object type (in the
-- package Widgets), which is inherited from the Objects.Object base
-- class. We then create several widgets and place them in an object
-- hierarchy (different than the inheritance hierarchy). We then
-- repaint the widgets.
procedure Object_Hierarchy is
procedure Dump_Object (This : in out Aof.Core.Objects.Access_Object) is
begin
Ada.Text_Io.Put_Line("Object: " & This.Get_Name);
end;
procedure Dump_Object_Tree is new Aof.Core.Objects.Iterate(Proc => Dump_Object);
begin
-- Set the object_name properties of the widgets:
My_Objects.Top.Set_Name("Top");
My_Objects.Form.Set_Name("Form");
My_Objects.Label.Set_Name("Label");
My_Objects.Row_Column_Layout.Set_Name("Row_Column_Layout");
My_Objects.Ok.Set_Name("Ok");
My_Objects.Cancel.Set_Name("Cancel");
-- Construct the object hierarchy:
My_Objects.Form.Set_Parent (My_Objects.Top_Ptr);
My_Objects.Label.Set_Parent (My_Objects.Form_Ptr);
My_Objects.Row_Column_Layout.Set_Parent (My_Objects.Form_Ptr);
My_Objects.Ok.Set_Parent (My_Objects.Row_Column_Layout_Ptr);
My_Objects.Cancel.Set_Parent (My_Objects.Row_Column_Layout_Ptr);
-- Set the label text:
My_Objects.Label.Label_Text.Set(Ada.Strings.Unbounded.To_Unbounded_String("Hello, World!"));
-- Print the label text for kicks:
Ada.Strings.Unbounded.Text_Io.Put_Line (My_Objects.Label.Label_Text.Get);
-- Dump the widget hierarchy:
Dump_Object_Tree(My_Objects.Top_Ptr);
end Object_Hierarchy;
|
-- { dg-do compile }
-- { dg-options "-O3" }
with Opt18_Pkg; use Opt18_Pkg;
package body Opt18 is
function Mag (Item : in Cart_Vector_Type) return Float is
begin
return Sqrt (Item (X) * Item (X) + Item (Y) * Item (Y)
+ Item (Z) * Item (Z));
end;
function Unit_Quaternion_To_Mag_Axis (Quaternion : in Unit_Quaternion_Type)
return Mag_Axis_Type is
Sin_Half : Float
:= Mag (Cart_Vector_Type'(Quaternion.X, Quaternion.Y, Quaternion.Z));
begin
if Sin_Half > 3.0 * First_Order_Trig then
return
(Mag => Atan2 (Double_Trig (Unchecked_Trig_Pair (Sin_Half,
Quaternion.S))),
Axis => Unit_Vector_Type'(Quaternion.X / Sin_Half,
Quaternion.Y / Sin_Half,
Quaternion.Z / Sin_Half));
else
return (0.0, X_Unit);
end if;
end;
end Opt18;
|
-- { dg-do compile }
-- { dg-options "-O2" }
package Opt28 is
function Full_Filename (Filename : String) return String;
end Opt28;
|
with Clenshaw;
with Chebychev;
with gauss_quadrature_61;
with chebychev_quadrature;
with Text_IO; use Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
-- Use data structure in Chebychev to instantiate Clenshaw, and make
-- Chebychev polynomials of the 2nd kind.
-- Chebychev polynomials should be normalized respect a weight W(x).
-- In other words, Integral (Poly(x)*Poly(x)*W(x)) = 1.0
-- Test should show that Chebychev Quadrature works flawlessly on
-- Chebychev polynomials; Gaussian Quadrature less so; Summing
-- rectangles is worst of all.
procedure Chebychev_Tst_1 is
type Real is digits 15;
package Maths is new Ada.Numerics.Generic_Elementary_Functions (Real);
use Maths;
package Chebychev_Polys is new Chebychev (Real, Exp, Log);
use Chebychev_Polys;
Poly_Limit : constant Poly_ID_Integer := 200;
package Cheby is new
Clenshaw (Real, Poly_ID_Integer, Poly_Limit, Alpha, Beta, Q_0);
use Cheby;
package realio is new Float_IO(Real);
use Realio;
package Gaussian_Quad is new gauss_quadrature_61 (Real);
use Gaussian_Quad;
package Cheby_Quad is new Chebychev_Quadrature (Real, 2**6, Cos, Sin);
-- Divide [-1,1] on X axis into 2**n parts:
No_of_Intervals : constant := 2**0; -- power of 2 best
type X_axis is range 1 .. No_of_Intervals;
DeltaX : constant Real := (X_Upper_Bound - X_Lower_Bound) / Real (No_of_Intervals);
W, X, Y : Real;
Q : Poly_Values;
d_Area, Area, Error : Real;
X_Start, X_Final : Real;
X_gauss : Gauss_Values;
F_val : Function_Values;
-- gaussian quadrature over segments of (-1, 1).
X_gauss_Cheby : Cheby_Quad.Gauss_Values;
F_val_Cheby : Cheby_Quad.Function_Values;
begin
-- Sum rectangles for area:
new_line(2); put ("Check normalization. Sum rectangles for area:");
new_line(2);
Sum_Rectangles:
declare
No_of_Subdivisions : constant Positive := 256;
dX : constant Real := DeltaX / Real (No_of_Subdivisions);
begin
for k in Poly_Id_Type range Poly_Id_Type'First .. Poly_Id_Type'First+20 loop
Area := 0.0;
X := X_Lower_Bound + 0.5 * dX;
for m in 1 .. No_of_Subdivisions loop
for i in X_Axis loop
Evaluate_Qs (X, Q, k);
Y := Q(k);
W := Poly_Weight (X);
Area := Area + W*Y*Y;
X := X + dX;
end loop;
end loop;
new_line; put ("k = "); put (Poly_Id_Type'Image(k));
put(" Norm = "); put (Area * dX / Norm (k));
end loop;
end Sum_Rectangles;
new_line(2);
put ("Check normalization. Use gaussian quadrature for area: ");
new_line(1);
for k in Poly_Id_Type range Poly_Id_Type'First .. Poly_Id_Type'First+30 loop
Area := 0.0;
for i in X_Axis loop
X_start := X_Lower_Bound + DeltaX * (Real (i) - Real (X_Axis'First));
X_Final := X_Start + DeltaX;
-- Interval of Gaussian quadrature.
Find_Gauss_Nodes (X_Start, X_Final, X_gauss);
for N in Gauss_Index_61 loop
Evaluate_Qs (X_gauss(N), Q, k);
Y := Q(k);
W := Poly_Weight (X_gauss(N));
F_val (N) := W*Y*Y;
end loop;
Get_Integral (F_val, X_Start, X_Final, d_Area, Error);
Area := Area + d_Area;
end loop;
new_line; put ("k = "); put (Poly_Id_Type'Image(k));
put(" Norm = "); put (Area / Norm (k));
end loop;
new_line(2);
put ("Check normalization. Use chebychev quadrature for area: ");
new_line(1);
for k in Poly_Id_Type range Poly_Id_Type'First .. Poly_Id_Type'First+32 loop
Area := 0.0;
for i in X_Axis loop
X_start := X_Lower_Bound + DeltaX * (Real (i) - Real (X_Axis'First));
X_Final := X_Start + DeltaX;
-- Interval of Gaussian quadrature.
Cheby_Quad.Find_Gauss_Nodes (X_Start, X_Final, X_gauss_Cheby);
for N in Cheby_Quad.Gauss_Index loop
Evaluate_Qs (X_gauss_Cheby(N), Q, k);
Y := Q(k);
W := Poly_Weight (X_gauss_Cheby(N));
F_val_Cheby (N) := W*Y*Y;
end loop;
Cheby_Quad.Get_Integral (F_val_Cheby, X_Start, X_Final, d_Area);
Area := Area + d_Area;
end loop;
new_line; put ("k = "); put (Poly_Id_Type'Image(k));
put(" Norm = "); put (Area / Norm (k));
end loop;
end Chebychev_Tst_1;
|
with dpila;
generic
type key is private;
type item is private;
with function "<" (k1, k2: in key) return boolean;
with function ">" (k1, k2: in key) return boolean;
package davl is
type conjunto is limited private;
espacio_desbordado: exception;
ya_existe: exception;
no_existe: exception;
procedure cvacio (s: out conjunto);
procedure poner (s: in out conjunto; k: in key; x: in item);
procedure consultar (s: in conjunto; k:in key; x: out item);
procedure borrar (s: in out conjunto; k: in key);
procedure actualiza (s: in out conjunto; k: in key; x: in item);
-- Iterator
type iterator is limited private;
bad_use: exception;
procedure first (s: in conjunto; it: out iterator);
procedure next (s: in conjunto; it: in out iterator);
function is_valid (it: in iterator) return boolean;
procedure get(s: in conjunto; it: in iterator; k: out key; x: out item);
private
type nodo;
type pnodo is access nodo;
type factor_balanceo is new integer range -1..1;
type nodo is record
k: key;
x: item;
bl: factor_balanceo;
lc, rc: pnodo;
end record;
type conjunto is record
raiz: pnodo;
end record;
package dnodestack is new dpila(pnodo);
use dnodestack;
type iterator is
record
st: pila;
end record;
end davl;
|
-- 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 Ada.Finalization;
with Ada.Streams;
package JSON.Streams with SPARK_Mode => On is
pragma Preelaborate;
pragma Elaborate_Body;
package AS renames Ada.Streams;
type Stream is tagged private;
type Stream_Ptr is not null access all Streams.Stream;
function Has_Buffered_Character (Object : Stream) return Boolean;
function Read_Character (Object : in out Stream) return Character
with Post => not Object.Has_Buffered_Character;
function Read_Character
(Object : in out Stream;
Index : out AS.Stream_Element_Offset) return Character
with Post => not Object.Has_Buffered_Character;
-- Writes the offset of the read character to Index. This is needed
-- for string tokens.
procedure Write_Character (Object : in out Stream; Next : Character)
with Pre => not Object.Has_Buffered_Character;
function Is_Equal_String
(Object : Stream;
Offset, Length : AS.Stream_Element_Offset;
Value : String) return Boolean;
function Get_String
(Object : Stream;
Offset, Length : AS.Stream_Element_Offset) return String;
type Stream_Element_Array_Access is access all AS.Stream_Element_Array;
function Create_Stream
(Bytes : not null Stream_Element_Array_Access) return Stream;
-----------------------------------------------------------------------------
function From_File
(File_Name : String) return Stream_Element_Array_Access;
function From_Text
(Text : String) return Stream_Element_Array_Access;
private
type Stream is tagged record
Bytes : not null Stream_Element_Array_Access;
Next_Character : Character;
Index : AS.Stream_Element_Offset;
end record;
end JSON.Streams;
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="15">
<syndb class_id="0" tracking_level="0" version="0">
<userIPLatency>-1</userIPLatency>
<userIPName></userIPName>
<cdfg class_id="1" tracking_level="1" version="0" object_id="_0">
<name>Tema1Func</name>
<ret_bitwidth>0</ret_bitwidth>
<ports class_id="2" tracking_level="0" version="0">
<count>7</count>
<item_version>0</item_version>
<item class_id="3" tracking_level="1" version="0" object_id="_1">
<Value class_id="4" tracking_level="0" version="0">
<Obj class_id="5" tracking_level="0" version="0">
<type>1</type>
<id>1</id>
<name>E</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo class_id="6" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>E</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>4294967292</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs class_id="7" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_2">
<Value>
<Obj>
<type>1</type>
<id>2</id>
<name>S</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>S</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>25</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_3">
<Value>
<Obj>
<type>1</type>
<id>3</id>
<name>V</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>V</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>4</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_4">
<Value>
<Obj>
<type>1</type>
<id>4</id>
<name>N</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>N</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>585</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_5">
<Value>
<Obj>
<type>1</type>
<id>5</id>
<name>rule</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>rule</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>763721081</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_6">
<Value>
<Obj>
<type>1</type>
<id>6</id>
<name>EW</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>EW</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>1021029246</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_7">
<Value>
<Obj>
<type>1</type>
<id>7</id>
<name>NS</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>NS</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>539107436</coreId>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
</ports>
<nodes class_id="8" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="9" tracking_level="1" version="0" object_id="_8">
<Value>
<Obj>
<type>0</type>
<id>24</id>
<name>_ln12</name>
<fileName>Tema1CN/tema1Curs.cpp</fileName>
<fileDirectory>C:\Users\Catalin\Desktop\CN2CURS</fileDirectory>
<lineNumber>12</lineNumber>
<contextFuncName>Tema1Func</contextFuncName>
<contextNormFuncName>Tema1Func</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item class_id="10" tracking_level="0" version="0">
<first>C:\Users\Catalin\Desktop\CN2CURS</first>
<second class_id="11" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="12" tracking_level="0" version="0">
<first class_id="13" tracking_level="0" version="0">
<first>Tema1CN/tema1Curs.cpp</first>
<second>Tema1Func</second>
</first>
<second>12</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>540684654</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>0</count>
<item_version>0</item_version>
</oprand_edges>
<opcode>ret</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>0.00</m_delay>
<m_topoIndex>1</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
</nodes>
<consts class_id="15" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</consts>
<blocks class_id="16" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="17" tracking_level="1" version="0" object_id="_9">
<Obj>
<type>3</type>
<id>25</id>
<name>Tema1Func</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>1815806096</coreId>
</Obj>
<node_objs>
<count>1</count>
<item_version>0</item_version>
<item>24</item>
</node_objs>
</item>
</blocks>
<edges class_id="18" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</edges>
</cdfg>
<cdfg_regions class_id="19" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="20" tracking_level="1" version="0" object_id="_10">
<mId>1</mId>
<mTag>Tema1Func</mTag>
<mNormTag>Tema1Func</mNormTag>
<mType>0</mType>
<sub_regions>
<count>0</count>
<item_version>0</item_version>
</sub_regions>
<basic_blocks>
<count>1</count>
<item_version>0</item_version>
<item>25</item>
</basic_blocks>
<mII>-1</mII>
<mDepth>-1</mDepth>
<mMinTripCount>-1</mMinTripCount>
<mMaxTripCount>-1</mMaxTripCount>
<mMinLatency>0</mMinLatency>
<mMaxLatency>0</mMaxLatency>
<mIsDfPipe>0</mIsDfPipe>
<mDfPipe class_id="-1"></mDfPipe>
</item>
</cdfg_regions>
<fsm class_id="22" tracking_level="1" version="0" object_id="_11">
<states class_id="23" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="24" tracking_level="1" version="0" object_id="_12">
<id>1</id>
<operations class_id="25" tracking_level="0" version="0">
<count>17</count>
<item_version>0</item_version>
<item class_id="26" tracking_level="1" version="0" object_id="_13">
<id>8</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_14">
<id>9</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_15">
<id>10</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_16">
<id>11</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_17">
<id>12</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_18">
<id>13</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_19">
<id>14</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_20">
<id>15</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_21">
<id>16</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_22">
<id>17</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_23">
<id>18</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_24">
<id>19</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_25">
<id>20</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_26">
<id>21</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_27">
<id>22</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_28">
<id>23</id>
<stage>1</stage>
<latency>1</latency>
</item>
<item class_id_reference="26" object_id="_29">
<id>24</id>
<stage>1</stage>
<latency>1</latency>
</item>
</operations>
</item>
</states>
<transitions class_id="27" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</transitions>
</fsm>
<res class_id="-1"></res>
<node_label_latency class_id="29" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="30" tracking_level="0" version="0">
<first>24</first>
<second class_id="31" tracking_level="0" version="0">
<first>0</first>
<second>0</second>
</second>
</item>
</node_label_latency>
<bblk_ent_exit class_id="32" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="33" tracking_level="0" version="0">
<first>25</first>
<second class_id="34" tracking_level="0" version="0">
<first>0</first>
<second>0</second>
</second>
</item>
</bblk_ent_exit>
<regions class_id="35" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</regions>
<dp_fu_nodes class_id="36" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes>
<dp_fu_nodes_expression class_id="37" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_expression>
<dp_fu_nodes_module>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_module>
<dp_fu_nodes_io>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_io>
<return_ports>
<count>0</count>
<item_version>0</item_version>
</return_ports>
<dp_mem_port_nodes class_id="38" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_mem_port_nodes>
<dp_reg_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_reg_nodes>
<dp_regname_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_regname_nodes>
<dp_reg_phi>
<count>0</count>
<item_version>0</item_version>
</dp_reg_phi>
<dp_regname_phi>
<count>0</count>
<item_version>0</item_version>
</dp_regname_phi>
<dp_port_io_nodes class_id="39" tracking_level="0" version="0">
<count>7</count>
<item_version>0</item_version>
<item class_id="40" tracking_level="0" version="0">
<first>E</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>EW</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>N</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>NS</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>S</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>V</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
<item>
<first>rule</first>
<second>
<count>0</count>
<item_version>0</item_version>
</second>
</item>
</dp_port_io_nodes>
<port2core>
<count>0</count>
<item_version>0</item_version>
</port2core>
<node2core>
<count>0</count>
<item_version>0</item_version>
</node2core>
</syndb>
</boost_serialization>
|
------------------------------------------------------------------------------
-- reporter.adb
--
-- Implementation of the Reporter package.
------------------------------------------------------------------------------
with Ada.Text_IO;
use Ada.Text_IO;
package body Reporter is
protected Output is
procedure Send (Message: String);
end Output;
protected body Output is
procedure Send (Message: String) is
begin
Put_Line (Message);
end Send;
end Output;
procedure Report (Message: String) is
begin
Output.Send (Message);
end Report;
procedure Report (Message: Unbounded_String) is
begin
Output.Send (To_String(Message));
end Report;
end Reporter;
|
-- ----------------------------------------------------------------- --
-- --
-- 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 --
-- ----------------------------------------------------------------- --
-- ----------------------------------------------------------------- --
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
-- ----------------------------------------------------------------- --
-- SERIOUS WARNING: The Ada code in this files may, at some points,
-- rely directly on pointer arithmetic which is considered very
-- unsafe and PRONE TO ERROR. The AdaSDL_Framebuffer examples are
-- more appropriate and easier to understand. They should be used in
-- replacement of this files. Please go there.
-- This file exists only for the sake of completness and to test
-- AdaSDL without the dependency of AdaSDL_Framebuffer.
-- ----------------------------------------------------------------- --
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
-- ----------------------------------------------------------------- --
with Interfaces.C;
with Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with SDL.Quit;
with SDL.Error;
with SDL.Types; use SDL.Types;
with SDL.Timer;
with SDL.Events;
with TestPalette_Sprogs; use TestPalette_Sprogs;
procedure TestPalette is
-- ======================================
package It renames Interfaces;
use type It.Unsigned_32;
package C renames Interfaces.C;
use type C.int;
use type C.size_t;
use type C.unsigned;
use type C.C_float;
package CL renames Ada.Command_Line;
package Er renames SDL.Error;
package Ev renames SDL.Events;
use type Ev.Event_Type;
package T renames SDL.Timer;
use type V.Surface_Flags;
use type V.Surface_ptr;
use Random_Integer;
use V.Color_PtrOps;
package M is new Ada.Numerics.Generic_Elementary_Functions (C.C_float);
screen, bg : V.Surface_ptr;
type boat_Array is array (0 .. 1) of V.Surface_ptr;
boat : boat_Array;
vidflags : V.Surface_Flags := 0;
start : C.unsigned;
fade_max : C.int := 400;
fade_level, fade_dir : C.int;
boatcols, frames, red : C.int;
type boats_Array is array (C.unsigned range 0 .. NBOATS - 1) of C.int;
boatx, boaty, boatdir : boats_Array;
gamma_fade : C.int := 0;
gamma_ramp : C.int := 0;
argc : Integer := CL.Argument_Count;
begin
if SDL.Init (SDL.INIT_VIDEO) < 0 then
sdlerr ("initializing SDL");
end if;
SDL.Quit.atexit (SDL.SDL_Quit'Access);
while argc > 0 loop
if CL.Argument (argc) = "-hw" then
vidflags := vidflags or V.HWSURFACE;
argc := argc - 1;
elsif CL.Argument (argc) = "-fullscreen" then
vidflags := vidflags or V.FULLSCREEN;
argc := argc - 1;
elsif CL.Argument (argc) = "-nofade" then
fade_max := 1;
argc := argc - 1;
elsif CL.Argument (argc) = "-gamma" then
gamma_fade := 1;
argc := argc - 1;
elsif CL.Argument (argc) = "-gammaramp" then
gamma_ramp := 1;
argc := argc - 1;
else
Put_Line ("Usage: testpalette" &
"[-hw] [-fullscreen] [-nofade] [-gamma] " &
"[-gammaramp]");
GNAT.OS_Lib.OS_Exit (1);
end if;
end loop;
-- Ask explicitly for 8bpp and a hardware palette
screen := V.SetVideoMode (SCRW, SCRH, 8, vidflags or V.HWPALETTE);
if screen = null then
Put_Line ("error setting " & Integer'Image (SCRW) & " " &
Integer'Image (SCRH) & " " & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (1);
end if;
boat (0) := V.LoadBMP (CS.New_String ("sail.bmp"));
if boat (0) = null then
sdlerr ("loading sail.bmp");
end if;
-- We've chosen magenta (#ff00ff) as colour key for the boat
V.SetColorKey (boat (0), V.SRCCOLORKEY or V.RLEACCEL,
V.MapRGB (boat (0).format, 16#FF#, 16#00#, 16#FF#));
boatcols := boat (0).format.palette.ncolors;
boat (1) := hflip (boat (0));
V.SetColorKey (boat (1), V.SRCCOLORKEY or V.RLEACCEL,
V.MapRGB (boat (1).format, 16#FF#, 16#00#, 16#FF#));
-- First set the physical screen palette to black, so the user won't
-- see our initial drawing on the screen.
cmap := (others => (0,0,0,0));
V.SetPalette (screen, V.PHYSPAL, cmap, C.int(cmap'First), C.int(cmap'Length));
-- Proper palette management is important when playing games with the
-- colormap. We have divided the palette as follows:
--
-- index 0..(boatcols-1): used for the boat
-- index boatcols..(boatcols+63): used for the waves
V.SetPalette (screen, V.LOGPAL,
boat (0).format.palette.colors, 0, boatcols);
V.SetPalette (screen, V.LOGPAL, wavemap (0)'Access, boatcols, 64);
-- Now the logical screen palette is set, and will remain unchanged.
-- The boats already have the same palette so fast blits can be used.
V.Color_PtrOps.Copy_Array (Pointer (screen.format.palette.colors),
cmap (0)'Access,
256);
-- save the index of the red colour for later
red := C.int (V.MapRGB (screen.format, 16#FF#, 16#00#, 16#00#));
bg := make_bg (screen, boatcols); -- make a nice wavy background surface
-- initial screen contents
if V.BlitSurface (bg, null, screen, null) < 0 then
sdlerr ("blitting background to screen");
end if; -- actually put the background on screen
V.Flip (screen); -- actually put the background on screen
-- determine initial boat placements
for i in C.unsigned range 0 .. NBOATS - 1 loop
boatx (i) := (C.int (Random (Integer_Generator))
mod (SCRW + boat (0).w)) - boat (0).w;
boaty (i) := C.int (i) * (SCRH - boat (0).h) / (NBOATS - 1);
boatdir (i) := C.int (
It.Shift_Right (
It.Unsigned_32 (Random (Integer_Generator)),
5)
and 1)
* 2 - 1;
end loop;
start := C.unsigned (T.GetTicks);
frames := 0;
fade_dir := 1;
fade_level := 0;
loop
declare
e : aliased Ev.Event;
updates : V.Rects_Array (0 .. NBOATS - 1);
r : aliased V.Rect;
redphase : C.int;
begin
-- A small event loop: just exit on any key or mouse button event
while Ev.PollEvent (e'Access) /= 0 loop
if (e.the_type = Ev.KEYDOWN) or (e.the_type = Ev.QUIT)
or (e.the_type = Ev.MOUSEBUTTONDOWN) then
if fade_dir < 0 then
fade_level := 0;
end if;
fade_dir := -1;
end if;
end loop;
-- move boats
for i in C.unsigned range 0 .. NBOATS - 1 loop
declare
old_x : C.int := boatx (i);
begin
-- update boat position
boatx (i) := boatx (i) + boatdir (i) * SPEED;
if (boatx (i) <= -boat (0).w) or (boatx (i) >= SCRW) then
boatdir (i) := -boatdir (i);
end if;
-- paint over old boat position
r.x := Sint16 (old_x);
r.y := Sint16 (boaty (i));
r.w := Uint16 (boat (0).w);
r.h := Uint16 (boat (0).h);
if V.BlitSurface (bg, r,
screen, r) < 0 then
sdlerr ("blitting background");
end if;
-- construct update rectangle (bounding box of old and new pos)
updates (i).x := Sint16 (C.int'Min (old_x, boatx (i)));
updates (i).y := Sint16 (boaty (i));
updates (i).w := Uint16 (boat (0).w + SPEED);
updates (i).h := Uint16 (boat (0).h);
-- clip update rectangle to screen
if updates (i).x < 0 then
updates (i).w := Uint16 (
Integer(updates (i).w) + Integer (updates (i).x));
updates (i).x := 0;
end if;
if C.int (updates (i).x) + C.int (updates (i).w) > SCRW then
updates (i).w := Uint16 (SCRW - updates (i).x);
end if;
end; -- declare
end loop; -- move boats
for i in C.unsigned range 0 .. NBOATS - 1 loop
-- paint boat on new position
r.x := Sint16 (boatx (i));
r.y := Sint16 (boaty (i));
if V.BlitSurface (boat (Integer((boatdir (i) + 1) / 2)),
null,
screen,
r) < 0 then
sdlerr ("blitting boat");
end if;
end loop;
-- cycle wave palette
for i in 0 .. 63 loop
cmap (C.size_t (boatcols)
+ C.size_t ((It.Unsigned_32 (C.int (i) + frames)
and 63)))
:= wavemap (i);
end loop;
if fade_dir /= 0 then
-- Fade the entire palette in/out
fade_level := fade_level + fade_dir;
if gamma_fade /= 0 then
-- Fade linearly in gamma level (lousy)
declare
level : C.C_float := C.C_float (fade_level) / C.C_float (fade_max);
begin
if V.SetGamma (level, level, level) < 0 then
sdlerr ("setting gamma");
end if;
end;
elsif gamma_ramp /= 0 then
-- Fade using gamma ramp (better)
declare
ramp : V.ramp_Array;
begin
for i in Natural range 0 .. 255 loop
ramp (i) := Uint16 (
It.Shift_Left (
It.Unsigned_32 (C.int (i) * fade_level / fade_max),
8));
end loop;
if V.SetGammaRamp (ramp, ramp, ramp) < 0 then
sdlerr ("setting gamma ramp");
end if;
end; -- declare
else
-- Fade using direct palette manipulation (best)
V.Color_PtrOps.Copy_Array (
Pointer (screen.format.palette.colors),
cmap (0)'Access,
C.ptrdiff_t (boatcols));
for i in C.size_t range 0 .. C.size_t (boatcols + 63) loop
cmap (i).r := Uint8 (C.C_float (cmap (i).r)
* C.C_float (fade_level) / C.C_float (fade_max));
cmap (i).g := Uint8 (C.C_float (cmap (i).g)
* C.C_float (fade_level) / C.C_float (fade_max));
cmap (i).b := Uint8 (C.C_float (cmap (i).b)
* C.C_float (fade_level) / C.C_float (fade_max));
end loop;
end if;
if fade_level = fade_max then
fade_dir := 0;
end if;
end if;
-- pulse the red colour (done after the fade, for a night effect)
redphase := frames mod 64;
cmap (C.size_t (red)).r := Uint8 (
C.C_float (255)
* M.Sin (C.C_float (redphase)
* C.C_float (Ada.Numerics.Pi)
/ C.C_float (64)));
V.SetPalette (screen, V.PHYSPAL, cmap (0)'Access, 0, boatcols + 64);
-- update changed ares of the screen
V.UpdateRects (screen, updates'Length, updates);
frames := frames + 1;
exit when fade_level <= 0;
end;
end loop;
Put (C.int'Image (frames) & " frames, ");
Put (Float (1000.0) * Float (frames)
/ Float (T.GetTicks - Uint32 (start))
,3, 2, 0);
Put_Line (" fps");
end TestPalette;
|
with Ada.Text_IO;
procedure main is
Δ : Integer;
begin
Δ := 41;
Δ := Δ + 1;
Ada.Text_IO.Put_Line (Δ'Img);
end main;
|
with Ada.Text_Io;
with Ada.Integer_text_IO;
procedure Call_Back_Example is
-- Purpose: Apply a callback to an array
-- Output: Prints the squares of an integer array to the console
-- Define the callback procedure
procedure Display(Location : Positive; Value : Integer) is
begin
Ada.Text_Io.Put("array(");
Ada.Integer_Text_Io.Put(Item => Location, Width => 1);
Ada.Text_Io.Put(") = ");
Ada.Integer_Text_Io.Put(Item => Value * Value, Width => 1);
Ada.Text_Io.New_Line;
end Display;
-- Define an access type matching the signature of the callback procedure
type Call_Back_Access is access procedure(L : Positive; V : Integer);
-- Define an unconstrained array type
type Value_Array is array(Positive range <>) of Integer;
-- Define the procedure performing the callback
procedure Map(Values : Value_Array; Worker : Call_Back_Access) is
begin
for I in Values'range loop
Worker(I, Values(I));
end loop;
end Map;
-- Define and initialize the actual array
Sample : Value_Array := (5,4,3,2,1);
begin
Map(Sample, Display'access);
end Call_Back_Example;
|
artifacts builderVersion:"1.1", {
version "${buildBaseVersion}", {
group "${groupId}", {
artifact "${artifactId}", {
file "${genroot}/out/mta_plugin_linux_amd64", classifier: "linux", extension: "bin"
file "${genroot}/out/mta_plugin_darwin_amd64", classifier: "darwin", extension: "bin"
file "${genroot}/out/mta_plugin_windows_amd64.exe", classifier: "windows", extension: "exe"
}
}
}
}
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 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 LSC.Internal.Types;
-------------------------------------------------------------------------------
-- Tables for AES
-------------------------------------------------------------------------------
private package LSC.Internal.AES.Tables is
pragma Pure;
type SBox_Type is array (Types.Byte) of Types.Byte;
type Table_Type is array (Types.Byte) of Types.Word32;
subtype Rcon_Index is Types.Index range 1 .. 30;
type Rcon_Type is array (Rcon_Index) of Types.Word32;
S : constant SBox_Type := SBox_Type'
(16#63#, 16#7c#, 16#77#, 16#7b#, 16#f2#, 16#6b#, 16#6f#, 16#c5#,
16#30#, 16#01#, 16#67#, 16#2b#, 16#fe#, 16#d7#, 16#ab#, 16#76#,
16#ca#, 16#82#, 16#c9#, 16#7d#, 16#fa#, 16#59#, 16#47#, 16#f0#,
16#ad#, 16#d4#, 16#a2#, 16#af#, 16#9c#, 16#a4#, 16#72#, 16#c0#,
16#b7#, 16#fd#, 16#93#, 16#26#, 16#36#, 16#3f#, 16#f7#, 16#cc#,
16#34#, 16#a5#, 16#e5#, 16#f1#, 16#71#, 16#d8#, 16#31#, 16#15#,
16#04#, 16#c7#, 16#23#, 16#c3#, 16#18#, 16#96#, 16#05#, 16#9a#,
16#07#, 16#12#, 16#80#, 16#e2#, 16#eb#, 16#27#, 16#b2#, 16#75#,
16#09#, 16#83#, 16#2c#, 16#1a#, 16#1b#, 16#6e#, 16#5a#, 16#a0#,
16#52#, 16#3b#, 16#d6#, 16#b3#, 16#29#, 16#e3#, 16#2f#, 16#84#,
16#53#, 16#d1#, 16#00#, 16#ed#, 16#20#, 16#fc#, 16#b1#, 16#5b#,
16#6a#, 16#cb#, 16#be#, 16#39#, 16#4a#, 16#4c#, 16#58#, 16#cf#,
16#d0#, 16#ef#, 16#aa#, 16#fb#, 16#43#, 16#4d#, 16#33#, 16#85#,
16#45#, 16#f9#, 16#02#, 16#7f#, 16#50#, 16#3c#, 16#9f#, 16#a8#,
16#51#, 16#a3#, 16#40#, 16#8f#, 16#92#, 16#9d#, 16#38#, 16#f5#,
16#bc#, 16#b6#, 16#da#, 16#21#, 16#10#, 16#ff#, 16#f3#, 16#d2#,
16#cd#, 16#0c#, 16#13#, 16#ec#, 16#5f#, 16#97#, 16#44#, 16#17#,
16#c4#, 16#a7#, 16#7e#, 16#3d#, 16#64#, 16#5d#, 16#19#, 16#73#,
16#60#, 16#81#, 16#4f#, 16#dc#, 16#22#, 16#2a#, 16#90#, 16#88#,
16#46#, 16#ee#, 16#b8#, 16#14#, 16#de#, 16#5e#, 16#0b#, 16#db#,
16#e0#, 16#32#, 16#3a#, 16#0a#, 16#49#, 16#06#, 16#24#, 16#5c#,
16#c2#, 16#d3#, 16#ac#, 16#62#, 16#91#, 16#95#, 16#e4#, 16#79#,
16#e7#, 16#c8#, 16#37#, 16#6d#, 16#8d#, 16#d5#, 16#4e#, 16#a9#,
16#6c#, 16#56#, 16#f4#, 16#ea#, 16#65#, 16#7a#, 16#ae#, 16#08#,
16#ba#, 16#78#, 16#25#, 16#2e#, 16#1c#, 16#a6#, 16#b4#, 16#c6#,
16#e8#, 16#dd#, 16#74#, 16#1f#, 16#4b#, 16#bd#, 16#8b#, 16#8a#,
16#70#, 16#3e#, 16#b5#, 16#66#, 16#48#, 16#03#, 16#f6#, 16#0e#,
16#61#, 16#35#, 16#57#, 16#b9#, 16#86#, 16#c1#, 16#1d#, 16#9e#,
16#e1#, 16#f8#, 16#98#, 16#11#, 16#69#, 16#d9#, 16#8e#, 16#94#,
16#9b#, 16#1e#, 16#87#, 16#e9#, 16#ce#, 16#55#, 16#28#, 16#df#,
16#8c#, 16#a1#, 16#89#, 16#0d#, 16#bf#, 16#e6#, 16#42#, 16#68#,
16#41#, 16#99#, 16#2d#, 16#0f#, 16#b0#, 16#54#, 16#bb#, 16#16#);
Si : constant SBox_Type := SBox_Type'
(16#52#, 16#09#, 16#6a#, 16#d5#, 16#30#, 16#36#, 16#a5#, 16#38#,
16#bf#, 16#40#, 16#a3#, 16#9e#, 16#81#, 16#f3#, 16#d7#, 16#fb#,
16#7c#, 16#e3#, 16#39#, 16#82#, 16#9b#, 16#2f#, 16#ff#, 16#87#,
16#34#, 16#8e#, 16#43#, 16#44#, 16#c4#, 16#de#, 16#e9#, 16#cb#,
16#54#, 16#7b#, 16#94#, 16#32#, 16#a6#, 16#c2#, 16#23#, 16#3d#,
16#ee#, 16#4c#, 16#95#, 16#0b#, 16#42#, 16#fa#, 16#c3#, 16#4e#,
16#08#, 16#2e#, 16#a1#, 16#66#, 16#28#, 16#d9#, 16#24#, 16#b2#,
16#76#, 16#5b#, 16#a2#, 16#49#, 16#6d#, 16#8b#, 16#d1#, 16#25#,
16#72#, 16#f8#, 16#f6#, 16#64#, 16#86#, 16#68#, 16#98#, 16#16#,
16#d4#, 16#a4#, 16#5c#, 16#cc#, 16#5d#, 16#65#, 16#b6#, 16#92#,
16#6c#, 16#70#, 16#48#, 16#50#, 16#fd#, 16#ed#, 16#b9#, 16#da#,
16#5e#, 16#15#, 16#46#, 16#57#, 16#a7#, 16#8d#, 16#9d#, 16#84#,
16#90#, 16#d8#, 16#ab#, 16#00#, 16#8c#, 16#bc#, 16#d3#, 16#0a#,
16#f7#, 16#e4#, 16#58#, 16#05#, 16#b8#, 16#b3#, 16#45#, 16#06#,
16#d0#, 16#2c#, 16#1e#, 16#8f#, 16#ca#, 16#3f#, 16#0f#, 16#02#,
16#c1#, 16#af#, 16#bd#, 16#03#, 16#01#, 16#13#, 16#8a#, 16#6b#,
16#3a#, 16#91#, 16#11#, 16#41#, 16#4f#, 16#67#, 16#dc#, 16#ea#,
16#97#, 16#f2#, 16#cf#, 16#ce#, 16#f0#, 16#b4#, 16#e6#, 16#73#,
16#96#, 16#ac#, 16#74#, 16#22#, 16#e7#, 16#ad#, 16#35#, 16#85#,
16#e2#, 16#f9#, 16#37#, 16#e8#, 16#1c#, 16#75#, 16#df#, 16#6e#,
16#47#, 16#f1#, 16#1a#, 16#71#, 16#1d#, 16#29#, 16#c5#, 16#89#,
16#6f#, 16#b7#, 16#62#, 16#0e#, 16#aa#, 16#18#, 16#be#, 16#1b#,
16#fc#, 16#56#, 16#3e#, 16#4b#, 16#c6#, 16#d2#, 16#79#, 16#20#,
16#9a#, 16#db#, 16#c0#, 16#fe#, 16#78#, 16#cd#, 16#5a#, 16#f4#,
16#1f#, 16#dd#, 16#a8#, 16#33#, 16#88#, 16#07#, 16#c7#, 16#31#,
16#b1#, 16#12#, 16#10#, 16#59#, 16#27#, 16#80#, 16#ec#, 16#5f#,
16#60#, 16#51#, 16#7f#, 16#a9#, 16#19#, 16#b5#, 16#4a#, 16#0d#,
16#2d#, 16#e5#, 16#7a#, 16#9f#, 16#93#, 16#c9#, 16#9c#, 16#ef#,
16#a0#, 16#e0#, 16#3b#, 16#4d#, 16#ae#, 16#2a#, 16#f5#, 16#b0#,
16#c8#, 16#eb#, 16#bb#, 16#3c#, 16#83#, 16#53#, 16#99#, 16#61#,
16#17#, 16#2b#, 16#04#, 16#7e#, 16#ba#, 16#77#, 16#d6#, 16#26#,
16#e1#, 16#69#, 16#14#, 16#63#, 16#55#, 16#21#, 16#0c#, 16#7d#);
T1 : constant Table_Type := Table_Type'
(16#C66363a5#, 16#F87c7c84#, 16#Ee777799#, 16#F67b7b8d#,
16#FfF2F20d#, 16#D66b6bBd#, 16#De6f6fB1#, 16#91C5C554#,
16#60303050#, 16#02010103#, 16#Ce6767A9#, 16#562b2b7d#,
16#E7FeFe19#, 16#B5D7D762#, 16#4dAbAbE6#, 16#Ec76769a#,
16#8fCaCa45#, 16#1f82829d#, 16#89C9C940#, 16#Fa7d7d87#,
16#EfFaFa15#, 16#B25959Eb#, 16#8e4747C9#, 16#FbF0F00b#,
16#41AdAdEc#, 16#B3D4D467#, 16#5fA2A2Fd#, 16#45AfAfEa#,
16#239c9cBf#, 16#53A4A4F7#, 16#E4727296#, 16#9bC0C05b#,
16#75B7B7C2#, 16#E1FdFd1c#, 16#3d9393Ae#, 16#4c26266a#,
16#6c36365a#, 16#7e3f3f41#, 16#F5F7F702#, 16#83CcCc4f#,
16#6834345c#, 16#51A5A5F4#, 16#D1E5E534#, 16#F9F1F108#,
16#E2717193#, 16#AbD8D873#, 16#62313153#, 16#2a15153f#,
16#0804040c#, 16#95C7C752#, 16#46232365#, 16#9dC3C35e#,
16#30181828#, 16#379696A1#, 16#0a05050f#, 16#2f9a9aB5#,
16#0e070709#, 16#24121236#, 16#1b80809b#, 16#DfE2E23d#,
16#CdEbEb26#, 16#4e272769#, 16#7fB2B2Cd#, 16#Ea75759f#,
16#1209091b#, 16#1d83839e#, 16#582c2c74#, 16#341a1a2e#,
16#361b1b2d#, 16#Dc6e6eB2#, 16#B45a5aEe#, 16#5bA0A0Fb#,
16#A45252F6#, 16#763b3b4d#, 16#B7D6D661#, 16#7dB3B3Ce#,
16#5229297b#, 16#DdE3E33e#, 16#5e2f2f71#, 16#13848497#,
16#A65353F5#, 16#B9D1D168#, 16#00000000#, 16#C1EdEd2c#,
16#40202060#, 16#E3FcFc1f#, 16#79B1B1C8#, 16#B65b5bEd#,
16#D46a6aBe#, 16#8dCbCb46#, 16#67BeBeD9#, 16#7239394b#,
16#944a4aDe#, 16#984c4cD4#, 16#B05858E8#, 16#85CfCf4a#,
16#BbD0D06b#, 16#C5EfEf2a#, 16#4fAaAaE5#, 16#EdFbFb16#,
16#864343C5#, 16#9a4d4dD7#, 16#66333355#, 16#11858594#,
16#8a4545Cf#, 16#E9F9F910#, 16#04020206#, 16#Fe7f7f81#,
16#A05050F0#, 16#783c3c44#, 16#259f9fBa#, 16#4bA8A8E3#,
16#A25151F3#, 16#5dA3A3Fe#, 16#804040C0#, 16#058f8f8a#,
16#3f9292Ad#, 16#219d9dBc#, 16#70383848#, 16#F1F5F504#,
16#63BcBcDf#, 16#77B6B6C1#, 16#AfDaDa75#, 16#42212163#,
16#20101030#, 16#E5FfFf1a#, 16#FdF3F30e#, 16#BfD2D26d#,
16#81CdCd4c#, 16#180c0c14#, 16#26131335#, 16#C3EcEc2f#,
16#Be5f5fE1#, 16#359797A2#, 16#884444Cc#, 16#2e171739#,
16#93C4C457#, 16#55A7A7F2#, 16#Fc7e7e82#, 16#7a3d3d47#,
16#C86464Ac#, 16#Ba5d5dE7#, 16#3219192b#, 16#E6737395#,
16#C06060A0#, 16#19818198#, 16#9e4f4fD1#, 16#A3DcDc7f#,
16#44222266#, 16#542a2a7e#, 16#3b9090Ab#, 16#0b888883#,
16#8c4646Ca#, 16#C7EeEe29#, 16#6bB8B8D3#, 16#2814143c#,
16#A7DeDe79#, 16#Bc5e5eE2#, 16#160b0b1d#, 16#AdDbDb76#,
16#DbE0E03b#, 16#64323256#, 16#743a3a4e#, 16#140a0a1e#,
16#924949Db#, 16#0c06060a#, 16#4824246c#, 16#B85c5cE4#,
16#9fC2C25d#, 16#BdD3D36e#, 16#43AcAcEf#, 16#C46262A6#,
16#399191A8#, 16#319595A4#, 16#D3E4E437#, 16#F279798b#,
16#D5E7E732#, 16#8bC8C843#, 16#6e373759#, 16#Da6d6dB7#,
16#018d8d8c#, 16#B1D5D564#, 16#9c4e4eD2#, 16#49A9A9E0#,
16#D86c6cB4#, 16#Ac5656Fa#, 16#F3F4F407#, 16#CfEaEa25#,
16#Ca6565Af#, 16#F47a7a8e#, 16#47AeAeE9#, 16#10080818#,
16#6fBaBaD5#, 16#F0787888#, 16#4a25256f#, 16#5c2e2e72#,
16#381c1c24#, 16#57A6A6F1#, 16#73B4B4C7#, 16#97C6C651#,
16#CbE8E823#, 16#A1DdDd7c#, 16#E874749c#, 16#3e1f1f21#,
16#964b4bDd#, 16#61BdBdDc#, 16#0d8b8b86#, 16#0f8a8a85#,
16#E0707090#, 16#7c3e3e42#, 16#71B5B5C4#, 16#Cc6666Aa#,
16#904848D8#, 16#06030305#, 16#F7F6F601#, 16#1c0e0e12#,
16#C26161A3#, 16#6a35355f#, 16#Ae5757F9#, 16#69B9B9D0#,
16#17868691#, 16#99C1C158#, 16#3a1d1d27#, 16#279e9eB9#,
16#D9E1E138#, 16#EbF8F813#, 16#2b9898B3#, 16#22111133#,
16#D26969Bb#, 16#A9D9D970#, 16#078e8e89#, 16#339494A7#,
16#2d9b9bB6#, 16#3c1e1e22#, 16#15878792#, 16#C9E9E920#,
16#87CeCe49#, 16#Aa5555Ff#, 16#50282878#, 16#A5DfDf7a#,
16#038c8c8f#, 16#59A1A1F8#, 16#09898980#, 16#1a0d0d17#,
16#65BfBfDa#, 16#D7E6E631#, 16#844242C6#, 16#D06868B8#,
16#824141C3#, 16#299999B0#, 16#5a2d2d77#, 16#1e0f0f11#,
16#7bB0B0Cb#, 16#A85454Fc#, 16#6dBbBbD6#, 16#2c16163a#);
T2 : constant Table_Type := Table_Type'
(16#A5C66363#, 16#84F87c7c#, 16#99Ee7777#, 16#8dF67b7b#,
16#0dFfF2F2#, 16#BdD66b6b#, 16#B1De6f6f#, 16#5491C5C5#,
16#50603030#, 16#03020101#, 16#A9Ce6767#, 16#7d562b2b#,
16#19E7FeFe#, 16#62B5D7D7#, 16#E64dAbAb#, 16#9aEc7676#,
16#458fCaCa#, 16#9d1f8282#, 16#4089C9C9#, 16#87Fa7d7d#,
16#15EfFaFa#, 16#EbB25959#, 16#C98e4747#, 16#0bFbF0F0#,
16#Ec41AdAd#, 16#67B3D4D4#, 16#Fd5fA2A2#, 16#Ea45AfAf#,
16#Bf239c9c#, 16#F753A4A4#, 16#96E47272#, 16#5b9bC0C0#,
16#C275B7B7#, 16#1cE1FdFd#, 16#Ae3d9393#, 16#6a4c2626#,
16#5a6c3636#, 16#417e3f3f#, 16#02F5F7F7#, 16#4f83CcCc#,
16#5c683434#, 16#F451A5A5#, 16#34D1E5E5#, 16#08F9F1F1#,
16#93E27171#, 16#73AbD8D8#, 16#53623131#, 16#3f2a1515#,
16#0c080404#, 16#5295C7C7#, 16#65462323#, 16#5e9dC3C3#,
16#28301818#, 16#A1379696#, 16#0f0a0505#, 16#B52f9a9a#,
16#090e0707#, 16#36241212#, 16#9b1b8080#, 16#3dDfE2E2#,
16#26CdEbEb#, 16#694e2727#, 16#Cd7fB2B2#, 16#9fEa7575#,
16#1b120909#, 16#9e1d8383#, 16#74582c2c#, 16#2e341a1a#,
16#2d361b1b#, 16#B2Dc6e6e#, 16#EeB45a5a#, 16#Fb5bA0A0#,
16#F6A45252#, 16#4d763b3b#, 16#61B7D6D6#, 16#Ce7dB3B3#,
16#7b522929#, 16#3eDdE3E3#, 16#715e2f2f#, 16#97138484#,
16#F5A65353#, 16#68B9D1D1#, 16#00000000#, 16#2cC1EdEd#,
16#60402020#, 16#1fE3FcFc#, 16#C879B1B1#, 16#EdB65b5b#,
16#BeD46a6a#, 16#468dCbCb#, 16#D967BeBe#, 16#4b723939#,
16#De944a4a#, 16#D4984c4c#, 16#E8B05858#, 16#4a85CfCf#,
16#6bBbD0D0#, 16#2aC5EfEf#, 16#E54fAaAa#, 16#16EdFbFb#,
16#C5864343#, 16#D79a4d4d#, 16#55663333#, 16#94118585#,
16#Cf8a4545#, 16#10E9F9F9#, 16#06040202#, 16#81Fe7f7f#,
16#F0A05050#, 16#44783c3c#, 16#Ba259f9f#, 16#E34bA8A8#,
16#F3A25151#, 16#Fe5dA3A3#, 16#C0804040#, 16#8a058f8f#,
16#Ad3f9292#, 16#Bc219d9d#, 16#48703838#, 16#04F1F5F5#,
16#Df63BcBc#, 16#C177B6B6#, 16#75AfDaDa#, 16#63422121#,
16#30201010#, 16#1aE5FfFf#, 16#0eFdF3F3#, 16#6dBfD2D2#,
16#4c81CdCd#, 16#14180c0c#, 16#35261313#, 16#2fC3EcEc#,
16#E1Be5f5f#, 16#A2359797#, 16#Cc884444#, 16#392e1717#,
16#5793C4C4#, 16#F255A7A7#, 16#82Fc7e7e#, 16#477a3d3d#,
16#AcC86464#, 16#E7Ba5d5d#, 16#2b321919#, 16#95E67373#,
16#A0C06060#, 16#98198181#, 16#D19e4f4f#, 16#7fA3DcDc#,
16#66442222#, 16#7e542a2a#, 16#Ab3b9090#, 16#830b8888#,
16#Ca8c4646#, 16#29C7EeEe#, 16#D36bB8B8#, 16#3c281414#,
16#79A7DeDe#, 16#E2Bc5e5e#, 16#1d160b0b#, 16#76AdDbDb#,
16#3bDbE0E0#, 16#56643232#, 16#4e743a3a#, 16#1e140a0a#,
16#Db924949#, 16#0a0c0606#, 16#6c482424#, 16#E4B85c5c#,
16#5d9fC2C2#, 16#6eBdD3D3#, 16#Ef43AcAc#, 16#A6C46262#,
16#A8399191#, 16#A4319595#, 16#37D3E4E4#, 16#8bF27979#,
16#32D5E7E7#, 16#438bC8C8#, 16#596e3737#, 16#B7Da6d6d#,
16#8c018d8d#, 16#64B1D5D5#, 16#D29c4e4e#, 16#E049A9A9#,
16#B4D86c6c#, 16#FaAc5656#, 16#07F3F4F4#, 16#25CfEaEa#,
16#AfCa6565#, 16#8eF47a7a#, 16#E947AeAe#, 16#18100808#,
16#D56fBaBa#, 16#88F07878#, 16#6f4a2525#, 16#725c2e2e#,
16#24381c1c#, 16#F157A6A6#, 16#C773B4B4#, 16#5197C6C6#,
16#23CbE8E8#, 16#7cA1DdDd#, 16#9cE87474#, 16#213e1f1f#,
16#Dd964b4b#, 16#Dc61BdBd#, 16#860d8b8b#, 16#850f8a8a#,
16#90E07070#, 16#427c3e3e#, 16#C471B5B5#, 16#AaCc6666#,
16#D8904848#, 16#05060303#, 16#01F7F6F6#, 16#121c0e0e#,
16#A3C26161#, 16#5f6a3535#, 16#F9Ae5757#, 16#D069B9B9#,
16#91178686#, 16#5899C1C1#, 16#273a1d1d#, 16#B9279e9e#,
16#38D9E1E1#, 16#13EbF8F8#, 16#B32b9898#, 16#33221111#,
16#BbD26969#, 16#70A9D9D9#, 16#89078e8e#, 16#A7339494#,
16#B62d9b9b#, 16#223c1e1e#, 16#92158787#, 16#20C9E9E9#,
16#4987CeCe#, 16#FfAa5555#, 16#78502828#, 16#7aA5DfDf#,
16#8f038c8c#, 16#F859A1A1#, 16#80098989#, 16#171a0d0d#,
16#Da65BfBf#, 16#31D7E6E6#, 16#C6844242#, 16#B8D06868#,
16#C3824141#, 16#B0299999#, 16#775a2d2d#, 16#111e0f0f#,
16#Cb7bB0B0#, 16#FcA85454#, 16#D66dBbBb#, 16#3a2c1616#);
T3 : constant Table_Type := Table_Type'
(16#63A5C663#, 16#7c84F87c#, 16#7799Ee77#, 16#7b8dF67b#,
16#F20dFfF2#, 16#6bBdD66b#, 16#6fB1De6f#, 16#C55491C5#,
16#30506030#, 16#01030201#, 16#67A9Ce67#, 16#2b7d562b#,
16#Fe19E7Fe#, 16#D762B5D7#, 16#AbE64dAb#, 16#769aEc76#,
16#Ca458fCa#, 16#829d1f82#, 16#C94089C9#, 16#7d87Fa7d#,
16#Fa15EfFa#, 16#59EbB259#, 16#47C98e47#, 16#F00bFbF0#,
16#AdEc41Ad#, 16#D467B3D4#, 16#A2Fd5fA2#, 16#AfEa45Af#,
16#9cBf239c#, 16#A4F753A4#, 16#7296E472#, 16#C05b9bC0#,
16#B7C275B7#, 16#Fd1cE1Fd#, 16#93Ae3d93#, 16#266a4c26#,
16#365a6c36#, 16#3f417e3f#, 16#F702F5F7#, 16#Cc4f83Cc#,
16#345c6834#, 16#A5F451A5#, 16#E534D1E5#, 16#F108F9F1#,
16#7193E271#, 16#D873AbD8#, 16#31536231#, 16#153f2a15#,
16#040c0804#, 16#C75295C7#, 16#23654623#, 16#C35e9dC3#,
16#18283018#, 16#96A13796#, 16#050f0a05#, 16#9aB52f9a#,
16#07090e07#, 16#12362412#, 16#809b1b80#, 16#E23dDfE2#,
16#Eb26CdEb#, 16#27694e27#, 16#B2Cd7fB2#, 16#759fEa75#,
16#091b1209#, 16#839e1d83#, 16#2c74582c#, 16#1a2e341a#,
16#1b2d361b#, 16#6eB2Dc6e#, 16#5aEeB45a#, 16#A0Fb5bA0#,
16#52F6A452#, 16#3b4d763b#, 16#D661B7D6#, 16#B3Ce7dB3#,
16#297b5229#, 16#E33eDdE3#, 16#2f715e2f#, 16#84971384#,
16#53F5A653#, 16#D168B9D1#, 16#00000000#, 16#Ed2cC1Ed#,
16#20604020#, 16#Fc1fE3Fc#, 16#B1C879B1#, 16#5bEdB65b#,
16#6aBeD46a#, 16#Cb468dCb#, 16#BeD967Be#, 16#394b7239#,
16#4aDe944a#, 16#4cD4984c#, 16#58E8B058#, 16#Cf4a85Cf#,
16#D06bBbD0#, 16#Ef2aC5Ef#, 16#AaE54fAa#, 16#Fb16EdFb#,
16#43C58643#, 16#4dD79a4d#, 16#33556633#, 16#85941185#,
16#45Cf8a45#, 16#F910E9F9#, 16#02060402#, 16#7f81Fe7f#,
16#50F0A050#, 16#3c44783c#, 16#9fBa259f#, 16#A8E34bA8#,
16#51F3A251#, 16#A3Fe5dA3#, 16#40C08040#, 16#8f8a058f#,
16#92Ad3f92#, 16#9dBc219d#, 16#38487038#, 16#F504F1F5#,
16#BcDf63Bc#, 16#B6C177B6#, 16#Da75AfDa#, 16#21634221#,
16#10302010#, 16#Ff1aE5Ff#, 16#F30eFdF3#, 16#D26dBfD2#,
16#Cd4c81Cd#, 16#0c14180c#, 16#13352613#, 16#Ec2fC3Ec#,
16#5fE1Be5f#, 16#97A23597#, 16#44Cc8844#, 16#17392e17#,
16#C45793C4#, 16#A7F255A7#, 16#7e82Fc7e#, 16#3d477a3d#,
16#64AcC864#, 16#5dE7Ba5d#, 16#192b3219#, 16#7395E673#,
16#60A0C060#, 16#81981981#, 16#4fD19e4f#, 16#Dc7fA3Dc#,
16#22664422#, 16#2a7e542a#, 16#90Ab3b90#, 16#88830b88#,
16#46Ca8c46#, 16#Ee29C7Ee#, 16#B8D36bB8#, 16#143c2814#,
16#De79A7De#, 16#5eE2Bc5e#, 16#0b1d160b#, 16#Db76AdDb#,
16#E03bDbE0#, 16#32566432#, 16#3a4e743a#, 16#0a1e140a#,
16#49Db9249#, 16#060a0c06#, 16#246c4824#, 16#5cE4B85c#,
16#C25d9fC2#, 16#D36eBdD3#, 16#AcEf43Ac#, 16#62A6C462#,
16#91A83991#, 16#95A43195#, 16#E437D3E4#, 16#798bF279#,
16#E732D5E7#, 16#C8438bC8#, 16#37596e37#, 16#6dB7Da6d#,
16#8d8c018d#, 16#D564B1D5#, 16#4eD29c4e#, 16#A9E049A9#,
16#6cB4D86c#, 16#56FaAc56#, 16#F407F3F4#, 16#Ea25CfEa#,
16#65AfCa65#, 16#7a8eF47a#, 16#AeE947Ae#, 16#08181008#,
16#BaD56fBa#, 16#7888F078#, 16#256f4a25#, 16#2e725c2e#,
16#1c24381c#, 16#A6F157A6#, 16#B4C773B4#, 16#C65197C6#,
16#E823CbE8#, 16#Dd7cA1Dd#, 16#749cE874#, 16#1f213e1f#,
16#4bDd964b#, 16#BdDc61Bd#, 16#8b860d8b#, 16#8a850f8a#,
16#7090E070#, 16#3e427c3e#, 16#B5C471B5#, 16#66AaCc66#,
16#48D89048#, 16#03050603#, 16#F601F7F6#, 16#0e121c0e#,
16#61A3C261#, 16#355f6a35#, 16#57F9Ae57#, 16#B9D069B9#,
16#86911786#, 16#C15899C1#, 16#1d273a1d#, 16#9eB9279e#,
16#E138D9E1#, 16#F813EbF8#, 16#98B32b98#, 16#11332211#,
16#69BbD269#, 16#D970A9D9#, 16#8e89078e#, 16#94A73394#,
16#9bB62d9b#, 16#1e223c1e#, 16#87921587#, 16#E920C9E9#,
16#Ce4987Ce#, 16#55FfAa55#, 16#28785028#, 16#Df7aA5Df#,
16#8c8f038c#, 16#A1F859A1#, 16#89800989#, 16#0d171a0d#,
16#BfDa65Bf#, 16#E631D7E6#, 16#42C68442#, 16#68B8D068#,
16#41C38241#, 16#99B02999#, 16#2d775a2d#, 16#0f111e0f#,
16#B0Cb7bB0#, 16#54FcA854#, 16#BbD66dBb#, 16#163a2c16#);
T4 : constant Table_Type := Table_Type'
(16#6363A5C6#, 16#7c7c84F8#, 16#777799Ee#, 16#7b7b8dF6#,
16#F2F20dFf#, 16#6b6bBdD6#, 16#6f6fB1De#, 16#C5C55491#,
16#30305060#, 16#01010302#, 16#6767A9Ce#, 16#2b2b7d56#,
16#FeFe19E7#, 16#D7D762B5#, 16#AbAbE64d#, 16#76769aEc#,
16#CaCa458f#, 16#82829d1f#, 16#C9C94089#, 16#7d7d87Fa#,
16#FaFa15Ef#, 16#5959EbB2#, 16#4747C98e#, 16#F0F00bFb#,
16#AdAdEc41#, 16#D4D467B3#, 16#A2A2Fd5f#, 16#AfAfEa45#,
16#9c9cBf23#, 16#A4A4F753#, 16#727296E4#, 16#C0C05b9b#,
16#B7B7C275#, 16#FdFd1cE1#, 16#9393Ae3d#, 16#26266a4c#,
16#36365a6c#, 16#3f3f417e#, 16#F7F702F5#, 16#CcCc4f83#,
16#34345c68#, 16#A5A5F451#, 16#E5E534D1#, 16#F1F108F9#,
16#717193E2#, 16#D8D873Ab#, 16#31315362#, 16#15153f2a#,
16#04040c08#, 16#C7C75295#, 16#23236546#, 16#C3C35e9d#,
16#18182830#, 16#9696A137#, 16#05050f0a#, 16#9a9aB52f#,
16#0707090e#, 16#12123624#, 16#80809b1b#, 16#E2E23dDf#,
16#EbEb26Cd#, 16#2727694e#, 16#B2B2Cd7f#, 16#75759fEa#,
16#09091b12#, 16#83839e1d#, 16#2c2c7458#, 16#1a1a2e34#,
16#1b1b2d36#, 16#6e6eB2Dc#, 16#5a5aEeB4#, 16#A0A0Fb5b#,
16#5252F6A4#, 16#3b3b4d76#, 16#D6D661B7#, 16#B3B3Ce7d#,
16#29297b52#, 16#E3E33eDd#, 16#2f2f715e#, 16#84849713#,
16#5353F5A6#, 16#D1D168B9#, 16#00000000#, 16#EdEd2cC1#,
16#20206040#, 16#FcFc1fE3#, 16#B1B1C879#, 16#5b5bEdB6#,
16#6a6aBeD4#, 16#CbCb468d#, 16#BeBeD967#, 16#39394b72#,
16#4a4aDe94#, 16#4c4cD498#, 16#5858E8B0#, 16#CfCf4a85#,
16#D0D06bBb#, 16#EfEf2aC5#, 16#AaAaE54f#, 16#FbFb16Ed#,
16#4343C586#, 16#4d4dD79a#, 16#33335566#, 16#85859411#,
16#4545Cf8a#, 16#F9F910E9#, 16#02020604#, 16#7f7f81Fe#,
16#5050F0A0#, 16#3c3c4478#, 16#9f9fBa25#, 16#A8A8E34b#,
16#5151F3A2#, 16#A3A3Fe5d#, 16#4040C080#, 16#8f8f8a05#,
16#9292Ad3f#, 16#9d9dBc21#, 16#38384870#, 16#F5F504F1#,
16#BcBcDf63#, 16#B6B6C177#, 16#DaDa75Af#, 16#21216342#,
16#10103020#, 16#FfFf1aE5#, 16#F3F30eFd#, 16#D2D26dBf#,
16#CdCd4c81#, 16#0c0c1418#, 16#13133526#, 16#EcEc2fC3#,
16#5f5fE1Be#, 16#9797A235#, 16#4444Cc88#, 16#1717392e#,
16#C4C45793#, 16#A7A7F255#, 16#7e7e82Fc#, 16#3d3d477a#,
16#6464AcC8#, 16#5d5dE7Ba#, 16#19192b32#, 16#737395E6#,
16#6060A0C0#, 16#81819819#, 16#4f4fD19e#, 16#DcDc7fA3#,
16#22226644#, 16#2a2a7e54#, 16#9090Ab3b#, 16#8888830b#,
16#4646Ca8c#, 16#EeEe29C7#, 16#B8B8D36b#, 16#14143c28#,
16#DeDe79A7#, 16#5e5eE2Bc#, 16#0b0b1d16#, 16#DbDb76Ad#,
16#E0E03bDb#, 16#32325664#, 16#3a3a4e74#, 16#0a0a1e14#,
16#4949Db92#, 16#06060a0c#, 16#24246c48#, 16#5c5cE4B8#,
16#C2C25d9f#, 16#D3D36eBd#, 16#AcAcEf43#, 16#6262A6C4#,
16#9191A839#, 16#9595A431#, 16#E4E437D3#, 16#79798bF2#,
16#E7E732D5#, 16#C8C8438b#, 16#3737596e#, 16#6d6dB7Da#,
16#8d8d8c01#, 16#D5D564B1#, 16#4e4eD29c#, 16#A9A9E049#,
16#6c6cB4D8#, 16#5656FaAc#, 16#F4F407F3#, 16#EaEa25Cf#,
16#6565AfCa#, 16#7a7a8eF4#, 16#AeAeE947#, 16#08081810#,
16#BaBaD56f#, 16#787888F0#, 16#25256f4a#, 16#2e2e725c#,
16#1c1c2438#, 16#A6A6F157#, 16#B4B4C773#, 16#C6C65197#,
16#E8E823Cb#, 16#DdDd7cA1#, 16#74749cE8#, 16#1f1f213e#,
16#4b4bDd96#, 16#BdBdDc61#, 16#8b8b860d#, 16#8a8a850f#,
16#707090E0#, 16#3e3e427c#, 16#B5B5C471#, 16#6666AaCc#,
16#4848D890#, 16#03030506#, 16#F6F601F7#, 16#0e0e121c#,
16#6161A3C2#, 16#35355f6a#, 16#5757F9Ae#, 16#B9B9D069#,
16#86869117#, 16#C1C15899#, 16#1d1d273a#, 16#9e9eB927#,
16#E1E138D9#, 16#F8F813Eb#, 16#9898B32b#, 16#11113322#,
16#6969BbD2#, 16#D9D970A9#, 16#8e8e8907#, 16#9494A733#,
16#9b9bB62d#, 16#1e1e223c#, 16#87879215#, 16#E9E920C9#,
16#CeCe4987#, 16#5555FfAa#, 16#28287850#, 16#DfDf7aA5#,
16#8c8c8f03#, 16#A1A1F859#, 16#89898009#, 16#0d0d171a#,
16#BfBfDa65#, 16#E6E631D7#, 16#4242C684#, 16#6868B8D0#,
16#4141C382#, 16#9999B029#, 16#2d2d775a#, 16#0f0f111e#,
16#B0B0Cb7b#, 16#5454FcA8#, 16#BbBbD66d#, 16#16163a2c#);
T5 : constant Table_Type := Table_Type'
(16#51F4A750#, 16#7e416553#, 16#1a17A4C3#, 16#3a275e96#,
16#3bAb6bCb#, 16#1f9d45F1#, 16#AcFa58Ab#, 16#4bE30393#,
16#2030Fa55#, 16#Ad766dF6#, 16#88Cc7691#, 16#F5024c25#,
16#4fE5D7Fc#, 16#C52aCbD7#, 16#26354480#, 16#B562A38f#,
16#DeB15a49#, 16#25Ba1b67#, 16#45Ea0e98#, 16#5dFeC0E1#,
16#C32f7502#, 16#814cF012#, 16#8d4697A3#, 16#6bD3F9C6#,
16#038f5fE7#, 16#15929c95#, 16#Bf6d7aEb#, 16#955259Da#,
16#D4Be832d#, 16#587421D3#, 16#49E06929#, 16#8eC9C844#,
16#75C2896a#, 16#F48e7978#, 16#99583e6b#, 16#27B971Dd#,
16#BeE14fB6#, 16#F088Ad17#, 16#C920Ac66#, 16#7dCe3aB4#,
16#63Df4a18#, 16#E51a3182#, 16#97513360#, 16#62537f45#,
16#B16477E0#, 16#Bb6bAe84#, 16#Fe81A01c#, 16#F9082b94#,
16#70486858#, 16#8f45Fd19#, 16#94De6c87#, 16#527bF8B7#,
16#Ab73D323#, 16#724b02E2#, 16#E31f8f57#, 16#6655Ab2a#,
16#B2Eb2807#, 16#2fB5C203#, 16#86C57b9a#, 16#D33708A5#,
16#302887F2#, 16#23BfA5B2#, 16#02036aBa#, 16#Ed16825c#,
16#8aCf1c2b#, 16#A779B492#, 16#F307F2F0#, 16#4e69E2A1#,
16#65DaF4Cd#, 16#0605BeD5#, 16#D134621f#, 16#C4A6Fe8a#,
16#342e539d#, 16#A2F355A0#, 16#058aE132#, 16#A4F6Eb75#,
16#0b83Ec39#, 16#4060EfAa#, 16#5e719f06#, 16#Bd6e1051#,
16#3e218aF9#, 16#96Dd063d#, 16#Dd3e05Ae#, 16#4dE6Bd46#,
16#91548dB5#, 16#71C45d05#, 16#0406D46f#, 16#605015Ff#,
16#1998Fb24#, 16#D6BdE997#, 16#894043Cc#, 16#67D99e77#,
16#B0E842Bd#, 16#07898b88#, 16#E7195b38#, 16#79C8EeDb#,
16#A17c0a47#, 16#7c420fE9#, 16#F8841eC9#, 16#00000000#,
16#09808683#, 16#322bEd48#, 16#1e1170Ac#, 16#6c5a724e#,
16#Fd0eFfFb#, 16#0f853856#, 16#3dAeD51e#, 16#362d3927#,
16#0a0fD964#, 16#685cA621#, 16#9b5b54D1#, 16#24362e3a#,
16#0c0a67B1#, 16#9357E70f#, 16#B4Ee96D2#, 16#1b9b919e#,
16#80C0C54f#, 16#61Dc20A2#, 16#5a774b69#, 16#1c121a16#,
16#E293Ba0a#, 16#C0A02aE5#, 16#3c22E043#, 16#121b171d#,
16#0e090d0b#, 16#F28bC7Ad#, 16#2dB6A8B9#, 16#141eA9C8#,
16#57F11985#, 16#Af75074c#, 16#Ee99DdBb#, 16#A37f60Fd#,
16#F701269f#, 16#5c72F5Bc#, 16#44663bC5#, 16#5bFb7e34#,
16#8b432976#, 16#Cb23C6Dc#, 16#B6EdFc68#, 16#B8E4F163#,
16#D731DcCa#, 16#42638510#, 16#13972240#, 16#84C61120#,
16#854a247d#, 16#D2Bb3dF8#, 16#AeF93211#, 16#C729A16d#,
16#1d9e2f4b#, 16#DcB230F3#, 16#0d8652Ec#, 16#77C1E3D0#,
16#2bB3166c#, 16#A970B999#, 16#119448Fa#, 16#47E96422#,
16#A8Fc8cC4#, 16#A0F03f1a#, 16#567d2cD8#, 16#223390Ef#,
16#87494eC7#, 16#D938D1C1#, 16#8cCaA2Fe#, 16#98D40b36#,
16#A6F581Cf#, 16#A57aDe28#, 16#DaB78e26#, 16#3fAdBfA4#,
16#2c3a9dE4#, 16#5078920d#, 16#6a5fCc9b#, 16#547e4662#,
16#F68d13C2#, 16#90D8B8E8#, 16#2e39F75e#, 16#82C3AfF5#,
16#9f5d80Be#, 16#69D0937c#, 16#6fD52dA9#, 16#Cf2512B3#,
16#C8Ac993b#, 16#10187dA7#, 16#E89c636e#, 16#Db3bBb7b#,
16#Cd267809#, 16#6e5918F4#, 16#Ec9aB701#, 16#834f9aA8#,
16#E6956e65#, 16#AaFfE67e#, 16#21BcCf08#, 16#Ef15E8E6#,
16#BaE79bD9#, 16#4a6f36Ce#, 16#Ea9f09D4#, 16#29B07cD6#,
16#31A4B2Af#, 16#2a3f2331#, 16#C6A59430#, 16#35A266C0#,
16#744eBc37#, 16#Fc82CaA6#, 16#E090D0B0#, 16#33A7D815#,
16#F104984a#, 16#41EcDaF7#, 16#7fCd500e#, 16#1791F62f#,
16#764dD68d#, 16#43EfB04d#, 16#CcAa4d54#, 16#E49604Df#,
16#9eD1B5E3#, 16#4c6a881b#, 16#C12c1fB8#, 16#4665517f#,
16#9d5eEa04#, 16#018c355d#, 16#Fa877473#, 16#Fb0b412e#,
16#B3671d5a#, 16#92DbD252#, 16#E9105633#, 16#6dD64713#,
16#9aD7618c#, 16#37A10c7a#, 16#59F8148e#, 16#Eb133c89#,
16#CeA927Ee#, 16#B761C935#, 16#E11cE5Ed#, 16#7a47B13c#,
16#9cD2Df59#, 16#55F2733f#, 16#1814Ce79#, 16#73C737Bf#,
16#53F7CdEa#, 16#5fFdAa5b#, 16#Df3d6f14#, 16#7844Db86#,
16#CaAfF381#, 16#B968C43e#, 16#3824342c#, 16#C2A3405f#,
16#161dC372#, 16#BcE2250c#, 16#283c498b#, 16#Ff0d9541#,
16#39A80171#, 16#080cB3De#, 16#D8B4E49c#, 16#6456C190#,
16#7bCb8461#, 16#D532B670#, 16#486c5c74#, 16#D0B85742#);
T6 : constant Table_Type := Table_Type'
(16#5051F4A7#, 16#537e4165#, 16#C31a17A4#, 16#963a275e#,
16#Cb3bAb6b#, 16#F11f9d45#, 16#AbAcFa58#, 16#934bE303#,
16#552030Fa#, 16#F6Ad766d#, 16#9188Cc76#, 16#25F5024c#,
16#Fc4fE5D7#, 16#D7C52aCb#, 16#80263544#, 16#8fB562A3#,
16#49DeB15a#, 16#6725Ba1b#, 16#9845Ea0e#, 16#E15dFeC0#,
16#02C32f75#, 16#12814cF0#, 16#A38d4697#, 16#C66bD3F9#,
16#E7038f5f#, 16#9515929c#, 16#EbBf6d7a#, 16#Da955259#,
16#2dD4Be83#, 16#D3587421#, 16#2949E069#, 16#448eC9C8#,
16#6a75C289#, 16#78F48e79#, 16#6b99583e#, 16#Dd27B971#,
16#B6BeE14f#, 16#17F088Ad#, 16#66C920Ac#, 16#B47dCe3a#,
16#1863Df4a#, 16#82E51a31#, 16#60975133#, 16#4562537f#,
16#E0B16477#, 16#84Bb6bAe#, 16#1cFe81A0#, 16#94F9082b#,
16#58704868#, 16#198f45Fd#, 16#8794De6c#, 16#B7527bF8#,
16#23Ab73D3#, 16#E2724b02#, 16#57E31f8f#, 16#2a6655Ab#,
16#07B2Eb28#, 16#032fB5C2#, 16#9a86C57b#, 16#A5D33708#,
16#F2302887#, 16#B223BfA5#, 16#Ba02036a#, 16#5cEd1682#,
16#2b8aCf1c#, 16#92A779B4#, 16#F0F307F2#, 16#A14e69E2#,
16#Cd65DaF4#, 16#D50605Be#, 16#1fD13462#, 16#8aC4A6Fe#,
16#9d342e53#, 16#A0A2F355#, 16#32058aE1#, 16#75A4F6Eb#,
16#390b83Ec#, 16#Aa4060Ef#, 16#065e719f#, 16#51Bd6e10#,
16#F93e218a#, 16#3d96Dd06#, 16#AeDd3e05#, 16#464dE6Bd#,
16#B591548d#, 16#0571C45d#, 16#6f0406D4#, 16#Ff605015#,
16#241998Fb#, 16#97D6BdE9#, 16#Cc894043#, 16#7767D99e#,
16#BdB0E842#, 16#8807898b#, 16#38E7195b#, 16#Db79C8Ee#,
16#47A17c0a#, 16#E97c420f#, 16#C9F8841e#, 16#00000000#,
16#83098086#, 16#48322bEd#, 16#Ac1e1170#, 16#4e6c5a72#,
16#FbFd0eFf#, 16#560f8538#, 16#1e3dAeD5#, 16#27362d39#,
16#640a0fD9#, 16#21685cA6#, 16#D19b5b54#, 16#3a24362e#,
16#B10c0a67#, 16#0f9357E7#, 16#D2B4Ee96#, 16#9e1b9b91#,
16#4f80C0C5#, 16#A261Dc20#, 16#695a774b#, 16#161c121a#,
16#0aE293Ba#, 16#E5C0A02a#, 16#433c22E0#, 16#1d121b17#,
16#0b0e090d#, 16#AdF28bC7#, 16#B92dB6A8#, 16#C8141eA9#,
16#8557F119#, 16#4cAf7507#, 16#BbEe99Dd#, 16#FdA37f60#,
16#9fF70126#, 16#Bc5c72F5#, 16#C544663b#, 16#345bFb7e#,
16#768b4329#, 16#DcCb23C6#, 16#68B6EdFc#, 16#63B8E4F1#,
16#CaD731Dc#, 16#10426385#, 16#40139722#, 16#2084C611#,
16#7d854a24#, 16#F8D2Bb3d#, 16#11AeF932#, 16#6dC729A1#,
16#4b1d9e2f#, 16#F3DcB230#, 16#Ec0d8652#, 16#D077C1E3#,
16#6c2bB316#, 16#99A970B9#, 16#Fa119448#, 16#2247E964#,
16#C4A8Fc8c#, 16#1aA0F03f#, 16#D8567d2c#, 16#Ef223390#,
16#C787494e#, 16#C1D938D1#, 16#Fe8cCaA2#, 16#3698D40b#,
16#CfA6F581#, 16#28A57aDe#, 16#26DaB78e#, 16#A43fAdBf#,
16#E42c3a9d#, 16#0d507892#, 16#9b6a5fCc#, 16#62547e46#,
16#C2F68d13#, 16#E890D8B8#, 16#5e2e39F7#, 16#F582C3Af#,
16#Be9f5d80#, 16#7c69D093#, 16#A96fD52d#, 16#B3Cf2512#,
16#3bC8Ac99#, 16#A710187d#, 16#6eE89c63#, 16#7bDb3bBb#,
16#09Cd2678#, 16#F46e5918#, 16#01Ec9aB7#, 16#A8834f9a#,
16#65E6956e#, 16#7eAaFfE6#, 16#0821BcCf#, 16#E6Ef15E8#,
16#D9BaE79b#, 16#Ce4a6f36#, 16#D4Ea9f09#, 16#D629B07c#,
16#Af31A4B2#, 16#312a3f23#, 16#30C6A594#, 16#C035A266#,
16#37744eBc#, 16#A6Fc82Ca#, 16#B0E090D0#, 16#1533A7D8#,
16#4aF10498#, 16#F741EcDa#, 16#0e7fCd50#, 16#2f1791F6#,
16#8d764dD6#, 16#4d43EfB0#, 16#54CcAa4d#, 16#DfE49604#,
16#E39eD1B5#, 16#1b4c6a88#, 16#B8C12c1f#, 16#7f466551#,
16#049d5eEa#, 16#5d018c35#, 16#73Fa8774#, 16#2eFb0b41#,
16#5aB3671d#, 16#5292DbD2#, 16#33E91056#, 16#136dD647#,
16#8c9aD761#, 16#7a37A10c#, 16#8e59F814#, 16#89Eb133c#,
16#EeCeA927#, 16#35B761C9#, 16#EdE11cE5#, 16#3c7a47B1#,
16#599cD2Df#, 16#3f55F273#, 16#791814Ce#, 16#Bf73C737#,
16#Ea53F7Cd#, 16#5b5fFdAa#, 16#14Df3d6f#, 16#867844Db#,
16#81CaAfF3#, 16#3eB968C4#, 16#2c382434#, 16#5fC2A340#,
16#72161dC3#, 16#0cBcE225#, 16#8b283c49#, 16#41Ff0d95#,
16#7139A801#, 16#De080cB3#, 16#9cD8B4E4#, 16#906456C1#,
16#617bCb84#, 16#70D532B6#, 16#74486c5c#, 16#42D0B857#);
T7 : constant Table_Type := Table_Type'
(16#A75051F4#, 16#65537e41#, 16#A4C31a17#, 16#5e963a27#,
16#6bCb3bAb#, 16#45F11f9d#, 16#58AbAcFa#, 16#03934bE3#,
16#Fa552030#, 16#6dF6Ad76#, 16#769188Cc#, 16#4c25F502#,
16#D7Fc4fE5#, 16#CbD7C52a#, 16#44802635#, 16#A38fB562#,
16#5a49DeB1#, 16#1b6725Ba#, 16#0e9845Ea#, 16#C0E15dFe#,
16#7502C32f#, 16#F012814c#, 16#97A38d46#, 16#F9C66bD3#,
16#5fE7038f#, 16#9c951592#, 16#7aEbBf6d#, 16#59Da9552#,
16#832dD4Be#, 16#21D35874#, 16#692949E0#, 16#C8448eC9#,
16#896a75C2#, 16#7978F48e#, 16#3e6b9958#, 16#71Dd27B9#,
16#4fB6BeE1#, 16#Ad17F088#, 16#Ac66C920#, 16#3aB47dCe#,
16#4a1863Df#, 16#3182E51a#, 16#33609751#, 16#7f456253#,
16#77E0B164#, 16#Ae84Bb6b#, 16#A01cFe81#, 16#2b94F908#,
16#68587048#, 16#Fd198f45#, 16#6c8794De#, 16#F8B7527b#,
16#D323Ab73#, 16#02E2724b#, 16#8f57E31f#, 16#Ab2a6655#,
16#2807B2Eb#, 16#C2032fB5#, 16#7b9a86C5#, 16#08A5D337#,
16#87F23028#, 16#A5B223Bf#, 16#6aBa0203#, 16#825cEd16#,
16#1c2b8aCf#, 16#B492A779#, 16#F2F0F307#, 16#E2A14e69#,
16#F4Cd65Da#, 16#BeD50605#, 16#621fD134#, 16#Fe8aC4A6#,
16#539d342e#, 16#55A0A2F3#, 16#E132058a#, 16#Eb75A4F6#,
16#Ec390b83#, 16#EfAa4060#, 16#9f065e71#, 16#1051Bd6e#,
16#8aF93e21#, 16#063d96Dd#, 16#05AeDd3e#, 16#Bd464dE6#,
16#8dB59154#, 16#5d0571C4#, 16#D46f0406#, 16#15Ff6050#,
16#Fb241998#, 16#E997D6Bd#, 16#43Cc8940#, 16#9e7767D9#,
16#42BdB0E8#, 16#8b880789#, 16#5b38E719#, 16#EeDb79C8#,
16#0a47A17c#, 16#0fE97c42#, 16#1eC9F884#, 16#00000000#,
16#86830980#, 16#Ed48322b#, 16#70Ac1e11#, 16#724e6c5a#,
16#FfFbFd0e#, 16#38560f85#, 16#D51e3dAe#, 16#3927362d#,
16#D9640a0f#, 16#A621685c#, 16#54D19b5b#, 16#2e3a2436#,
16#67B10c0a#, 16#E70f9357#, 16#96D2B4Ee#, 16#919e1b9b#,
16#C54f80C0#, 16#20A261Dc#, 16#4b695a77#, 16#1a161c12#,
16#Ba0aE293#, 16#2aE5C0A0#, 16#E0433c22#, 16#171d121b#,
16#0d0b0e09#, 16#C7AdF28b#, 16#A8B92dB6#, 16#A9C8141e#,
16#198557F1#, 16#074cAf75#, 16#DdBbEe99#, 16#60FdA37f#,
16#269fF701#, 16#F5Bc5c72#, 16#3bC54466#, 16#7e345bFb#,
16#29768b43#, 16#C6DcCb23#, 16#Fc68B6Ed#, 16#F163B8E4#,
16#DcCaD731#, 16#85104263#, 16#22401397#, 16#112084C6#,
16#247d854a#, 16#3dF8D2Bb#, 16#3211AeF9#, 16#A16dC729#,
16#2f4b1d9e#, 16#30F3DcB2#, 16#52Ec0d86#, 16#E3D077C1#,
16#166c2bB3#, 16#B999A970#, 16#48Fa1194#, 16#642247E9#,
16#8cC4A8Fc#, 16#3f1aA0F0#, 16#2cD8567d#, 16#90Ef2233#,
16#4eC78749#, 16#D1C1D938#, 16#A2Fe8cCa#, 16#0b3698D4#,
16#81CfA6F5#, 16#De28A57a#, 16#8e26DaB7#, 16#BfA43fAd#,
16#9dE42c3a#, 16#920d5078#, 16#Cc9b6a5f#, 16#4662547e#,
16#13C2F68d#, 16#B8E890D8#, 16#F75e2e39#, 16#AfF582C3#,
16#80Be9f5d#, 16#937c69D0#, 16#2dA96fD5#, 16#12B3Cf25#,
16#993bC8Ac#, 16#7dA71018#, 16#636eE89c#, 16#Bb7bDb3b#,
16#7809Cd26#, 16#18F46e59#, 16#B701Ec9a#, 16#9aA8834f#,
16#6e65E695#, 16#E67eAaFf#, 16#Cf0821Bc#, 16#E8E6Ef15#,
16#9bD9BaE7#, 16#36Ce4a6f#, 16#09D4Ea9f#, 16#7cD629B0#,
16#B2Af31A4#, 16#23312a3f#, 16#9430C6A5#, 16#66C035A2#,
16#Bc37744e#, 16#CaA6Fc82#, 16#D0B0E090#, 16#D81533A7#,
16#984aF104#, 16#DaF741Ec#, 16#500e7fCd#, 16#F62f1791#,
16#D68d764d#, 16#B04d43Ef#, 16#4d54CcAa#, 16#04DfE496#,
16#B5E39eD1#, 16#881b4c6a#, 16#1fB8C12c#, 16#517f4665#,
16#Ea049d5e#, 16#355d018c#, 16#7473Fa87#, 16#412eFb0b#,
16#1d5aB367#, 16#D25292Db#, 16#5633E910#, 16#47136dD6#,
16#618c9aD7#, 16#0c7a37A1#, 16#148e59F8#, 16#3c89Eb13#,
16#27EeCeA9#, 16#C935B761#, 16#E5EdE11c#, 16#B13c7a47#,
16#Df599cD2#, 16#733f55F2#, 16#Ce791814#, 16#37Bf73C7#,
16#CdEa53F7#, 16#Aa5b5fFd#, 16#6f14Df3d#, 16#Db867844#,
16#F381CaAf#, 16#C43eB968#, 16#342c3824#, 16#405fC2A3#,
16#C372161d#, 16#250cBcE2#, 16#498b283c#, 16#9541Ff0d#,
16#017139A8#, 16#B3De080c#, 16#E49cD8B4#, 16#C1906456#,
16#84617bCb#, 16#B670D532#, 16#5c74486c#, 16#5742D0B8#);
T8 : constant Table_Type := Table_Type'
(16#F4A75051#, 16#4165537e#, 16#17A4C31a#, 16#275e963a#,
16#Ab6bCb3b#, 16#9d45F11f#, 16#Fa58AbAc#, 16#E303934b#,
16#30Fa5520#, 16#766dF6Ad#, 16#Cc769188#, 16#024c25F5#,
16#E5D7Fc4f#, 16#2aCbD7C5#, 16#35448026#, 16#62A38fB5#,
16#B15a49De#, 16#Ba1b6725#, 16#Ea0e9845#, 16#FeC0E15d#,
16#2f7502C3#, 16#4cF01281#, 16#4697A38d#, 16#D3F9C66b#,
16#8f5fE703#, 16#929c9515#, 16#6d7aEbBf#, 16#5259Da95#,
16#Be832dD4#, 16#7421D358#, 16#E0692949#, 16#C9C8448e#,
16#C2896a75#, 16#8e7978F4#, 16#583e6b99#, 16#B971Dd27#,
16#E14fB6Be#, 16#88Ad17F0#, 16#20Ac66C9#, 16#Ce3aB47d#,
16#Df4a1863#, 16#1a3182E5#, 16#51336097#, 16#537f4562#,
16#6477E0B1#, 16#6bAe84Bb#, 16#81A01cFe#, 16#082b94F9#,
16#48685870#, 16#45Fd198f#, 16#De6c8794#, 16#7bF8B752#,
16#73D323Ab#, 16#4b02E272#, 16#1f8f57E3#, 16#55Ab2a66#,
16#Eb2807B2#, 16#B5C2032f#, 16#C57b9a86#, 16#3708A5D3#,
16#2887F230#, 16#BfA5B223#, 16#036aBa02#, 16#16825cEd#,
16#Cf1c2b8a#, 16#79B492A7#, 16#07F2F0F3#, 16#69E2A14e#,
16#DaF4Cd65#, 16#05BeD506#, 16#34621fD1#, 16#A6Fe8aC4#,
16#2e539d34#, 16#F355A0A2#, 16#8aE13205#, 16#F6Eb75A4#,
16#83Ec390b#, 16#60EfAa40#, 16#719f065e#, 16#6e1051Bd#,
16#218aF93e#, 16#Dd063d96#, 16#3e05AeDd#, 16#E6Bd464d#,
16#548dB591#, 16#C45d0571#, 16#06D46f04#, 16#5015Ff60#,
16#98Fb2419#, 16#BdE997D6#, 16#4043Cc89#, 16#D99e7767#,
16#E842BdB0#, 16#898b8807#, 16#195b38E7#, 16#C8EeDb79#,
16#7c0a47A1#, 16#420fE97c#, 16#841eC9F8#, 16#00000000#,
16#80868309#, 16#2bEd4832#, 16#1170Ac1e#, 16#5a724e6c#,
16#0eFfFbFd#, 16#8538560f#, 16#AeD51e3d#, 16#2d392736#,
16#0fD9640a#, 16#5cA62168#, 16#5b54D19b#, 16#362e3a24#,
16#0a67B10c#, 16#57E70f93#, 16#Ee96D2B4#, 16#9b919e1b#,
16#C0C54f80#, 16#Dc20A261#, 16#774b695a#, 16#121a161c#,
16#93Ba0aE2#, 16#A02aE5C0#, 16#22E0433c#, 16#1b171d12#,
16#090d0b0e#, 16#8bC7AdF2#, 16#B6A8B92d#, 16#1eA9C814#,
16#F1198557#, 16#75074cAf#, 16#99DdBbEe#, 16#7f60FdA3#,
16#01269fF7#, 16#72F5Bc5c#, 16#663bC544#, 16#Fb7e345b#,
16#4329768b#, 16#23C6DcCb#, 16#EdFc68B6#, 16#E4F163B8#,
16#31DcCaD7#, 16#63851042#, 16#97224013#, 16#C6112084#,
16#4a247d85#, 16#Bb3dF8D2#, 16#F93211Ae#, 16#29A16dC7#,
16#9e2f4b1d#, 16#B230F3Dc#, 16#8652Ec0d#, 16#C1E3D077#,
16#B3166c2b#, 16#70B999A9#, 16#9448Fa11#, 16#E9642247#,
16#Fc8cC4A8#, 16#F03f1aA0#, 16#7d2cD856#, 16#3390Ef22#,
16#494eC787#, 16#38D1C1D9#, 16#CaA2Fe8c#, 16#D40b3698#,
16#F581CfA6#, 16#7aDe28A5#, 16#B78e26Da#, 16#AdBfA43f#,
16#3a9dE42c#, 16#78920d50#, 16#5fCc9b6a#, 16#7e466254#,
16#8d13C2F6#, 16#D8B8E890#, 16#39F75e2e#, 16#C3AfF582#,
16#5d80Be9f#, 16#D0937c69#, 16#D52dA96f#, 16#2512B3Cf#,
16#Ac993bC8#, 16#187dA710#, 16#9c636eE8#, 16#3bBb7bDb#,
16#267809Cd#, 16#5918F46e#, 16#9aB701Ec#, 16#4f9aA883#,
16#956e65E6#, 16#FfE67eAa#, 16#BcCf0821#, 16#15E8E6Ef#,
16#E79bD9Ba#, 16#6f36Ce4a#, 16#9f09D4Ea#, 16#B07cD629#,
16#A4B2Af31#, 16#3f23312a#, 16#A59430C6#, 16#A266C035#,
16#4eBc3774#, 16#82CaA6Fc#, 16#90D0B0E0#, 16#A7D81533#,
16#04984aF1#, 16#EcDaF741#, 16#Cd500e7f#, 16#91F62f17#,
16#4dD68d76#, 16#EfB04d43#, 16#Aa4d54Cc#, 16#9604DfE4#,
16#D1B5E39e#, 16#6a881b4c#, 16#2c1fB8C1#, 16#65517f46#,
16#5eEa049d#, 16#8c355d01#, 16#877473Fa#, 16#0b412eFb#,
16#671d5aB3#, 16#DbD25292#, 16#105633E9#, 16#D647136d#,
16#D7618c9a#, 16#A10c7a37#, 16#F8148e59#, 16#133c89Eb#,
16#A927EeCe#, 16#61C935B7#, 16#1cE5EdE1#, 16#47B13c7a#,
16#D2Df599c#, 16#F2733f55#, 16#14Ce7918#, 16#C737Bf73#,
16#F7CdEa53#, 16#FdAa5b5f#, 16#3d6f14Df#, 16#44Db8678#,
16#AfF381Ca#, 16#68C43eB9#, 16#24342c38#, 16#A3405fC2#,
16#1dC37216#, 16#E2250cBc#, 16#3c498b28#, 16#0d9541Ff#,
16#A8017139#, 16#0cB3De08#, 16#B4E49cD8#, 16#56C19064#,
16#Cb84617b#, 16#32B670D5#, 16#6c5c7448#, 16#B85742D0#);
U1 : constant Table_Type := Table_Type'
(16#00000000#, 16#0e090d0b#, 16#1c121a16#, 16#121b171d#,
16#3824342c#, 16#362d3927#, 16#24362e3a#, 16#2a3f2331#,
16#70486858#, 16#7e416553#, 16#6c5a724e#, 16#62537f45#,
16#486c5c74#, 16#4665517f#, 16#547e4662#, 16#5a774b69#,
16#E090D0B0#, 16#Ee99DdBb#, 16#Fc82CaA6#, 16#F28bC7Ad#,
16#D8B4E49c#, 16#D6BdE997#, 16#C4A6Fe8a#, 16#CaAfF381#,
16#90D8B8E8#, 16#9eD1B5E3#, 16#8cCaA2Fe#, 16#82C3AfF5#,
16#A8Fc8cC4#, 16#A6F581Cf#, 16#B4Ee96D2#, 16#BaE79bD9#,
16#Db3bBb7b#, 16#D532B670#, 16#C729A16d#, 16#C920Ac66#,
16#E31f8f57#, 16#Ed16825c#, 16#Ff0d9541#, 16#F104984a#,
16#Ab73D323#, 16#A57aDe28#, 16#B761C935#, 16#B968C43e#,
16#9357E70f#, 16#9d5eEa04#, 16#8f45Fd19#, 16#814cF012#,
16#3bAb6bCb#, 16#35A266C0#, 16#27B971Dd#, 16#29B07cD6#,
16#038f5fE7#, 16#0d8652Ec#, 16#1f9d45F1#, 16#119448Fa#,
16#4bE30393#, 16#45Ea0e98#, 16#57F11985#, 16#59F8148e#,
16#73C737Bf#, 16#7dCe3aB4#, 16#6fD52dA9#, 16#61Dc20A2#,
16#Ad766dF6#, 16#A37f60Fd#, 16#B16477E0#, 16#Bf6d7aEb#,
16#955259Da#, 16#9b5b54D1#, 16#894043Cc#, 16#87494eC7#,
16#Dd3e05Ae#, 16#D33708A5#, 16#C12c1fB8#, 16#Cf2512B3#,
16#E51a3182#, 16#Eb133c89#, 16#F9082b94#, 16#F701269f#,
16#4dE6Bd46#, 16#43EfB04d#, 16#51F4A750#, 16#5fFdAa5b#,
16#75C2896a#, 16#7bCb8461#, 16#69D0937c#, 16#67D99e77#,
16#3dAeD51e#, 16#33A7D815#, 16#21BcCf08#, 16#2fB5C203#,
16#058aE132#, 16#0b83Ec39#, 16#1998Fb24#, 16#1791F62f#,
16#764dD68d#, 16#7844Db86#, 16#6a5fCc9b#, 16#6456C190#,
16#4e69E2A1#, 16#4060EfAa#, 16#527bF8B7#, 16#5c72F5Bc#,
16#0605BeD5#, 16#080cB3De#, 16#1a17A4C3#, 16#141eA9C8#,
16#3e218aF9#, 16#302887F2#, 16#223390Ef#, 16#2c3a9dE4#,
16#96Dd063d#, 16#98D40b36#, 16#8aCf1c2b#, 16#84C61120#,
16#AeF93211#, 16#A0F03f1a#, 16#B2Eb2807#, 16#BcE2250c#,
16#E6956e65#, 16#E89c636e#, 16#Fa877473#, 16#F48e7978#,
16#DeB15a49#, 16#D0B85742#, 16#C2A3405f#, 16#CcAa4d54#,
16#41EcDaF7#, 16#4fE5D7Fc#, 16#5dFeC0E1#, 16#53F7CdEa#,
16#79C8EeDb#, 16#77C1E3D0#, 16#65DaF4Cd#, 16#6bD3F9C6#,
16#31A4B2Af#, 16#3fAdBfA4#, 16#2dB6A8B9#, 16#23BfA5B2#,
16#09808683#, 16#07898b88#, 16#15929c95#, 16#1b9b919e#,
16#A17c0a47#, 16#Af75074c#, 16#Bd6e1051#, 16#B3671d5a#,
16#99583e6b#, 16#97513360#, 16#854a247d#, 16#8b432976#,
16#D134621f#, 16#Df3d6f14#, 16#Cd267809#, 16#C32f7502#,
16#E9105633#, 16#E7195b38#, 16#F5024c25#, 16#Fb0b412e#,
16#9aD7618c#, 16#94De6c87#, 16#86C57b9a#, 16#88Cc7691#,
16#A2F355A0#, 16#AcFa58Ab#, 16#BeE14fB6#, 16#B0E842Bd#,
16#Ea9f09D4#, 16#E49604Df#, 16#F68d13C2#, 16#F8841eC9#,
16#D2Bb3dF8#, 16#DcB230F3#, 16#CeA927Ee#, 16#C0A02aE5#,
16#7a47B13c#, 16#744eBc37#, 16#6655Ab2a#, 16#685cA621#,
16#42638510#, 16#4c6a881b#, 16#5e719f06#, 16#5078920d#,
16#0a0fD964#, 16#0406D46f#, 16#161dC372#, 16#1814Ce79#,
16#322bEd48#, 16#3c22E043#, 16#2e39F75e#, 16#2030Fa55#,
16#Ec9aB701#, 16#E293Ba0a#, 16#F088Ad17#, 16#Fe81A01c#,
16#D4Be832d#, 16#DaB78e26#, 16#C8Ac993b#, 16#C6A59430#,
16#9cD2Df59#, 16#92DbD252#, 16#80C0C54f#, 16#8eC9C844#,
16#A4F6Eb75#, 16#AaFfE67e#, 16#B8E4F163#, 16#B6EdFc68#,
16#0c0a67B1#, 16#02036aBa#, 16#10187dA7#, 16#1e1170Ac#,
16#342e539d#, 16#3a275e96#, 16#283c498b#, 16#26354480#,
16#7c420fE9#, 16#724b02E2#, 16#605015Ff#, 16#6e5918F4#,
16#44663bC5#, 16#4a6f36Ce#, 16#587421D3#, 16#567d2cD8#,
16#37A10c7a#, 16#39A80171#, 16#2bB3166c#, 16#25Ba1b67#,
16#0f853856#, 16#018c355d#, 16#13972240#, 16#1d9e2f4b#,
16#47E96422#, 16#49E06929#, 16#5bFb7e34#, 16#55F2733f#,
16#7fCd500e#, 16#71C45d05#, 16#63Df4a18#, 16#6dD64713#,
16#D731DcCa#, 16#D938D1C1#, 16#Cb23C6Dc#, 16#C52aCbD7#,
16#Ef15E8E6#, 16#E11cE5Ed#, 16#F307F2F0#, 16#Fd0eFfFb#,
16#A779B492#, 16#A970B999#, 16#Bb6bAe84#, 16#B562A38f#,
16#9f5d80Be#, 16#91548dB5#, 16#834f9aA8#, 16#8d4697A3#);
U2 : constant Table_Type := Table_Type'
(16#00000000#, 16#0b0e090d#, 16#161c121a#, 16#1d121b17#,
16#2c382434#, 16#27362d39#, 16#3a24362e#, 16#312a3f23#,
16#58704868#, 16#537e4165#, 16#4e6c5a72#, 16#4562537f#,
16#74486c5c#, 16#7f466551#, 16#62547e46#, 16#695a774b#,
16#B0E090D0#, 16#BbEe99Dd#, 16#A6Fc82Ca#, 16#AdF28bC7#,
16#9cD8B4E4#, 16#97D6BdE9#, 16#8aC4A6Fe#, 16#81CaAfF3#,
16#E890D8B8#, 16#E39eD1B5#, 16#Fe8cCaA2#, 16#F582C3Af#,
16#C4A8Fc8c#, 16#CfA6F581#, 16#D2B4Ee96#, 16#D9BaE79b#,
16#7bDb3bBb#, 16#70D532B6#, 16#6dC729A1#, 16#66C920Ac#,
16#57E31f8f#, 16#5cEd1682#, 16#41Ff0d95#, 16#4aF10498#,
16#23Ab73D3#, 16#28A57aDe#, 16#35B761C9#, 16#3eB968C4#,
16#0f9357E7#, 16#049d5eEa#, 16#198f45Fd#, 16#12814cF0#,
16#Cb3bAb6b#, 16#C035A266#, 16#Dd27B971#, 16#D629B07c#,
16#E7038f5f#, 16#Ec0d8652#, 16#F11f9d45#, 16#Fa119448#,
16#934bE303#, 16#9845Ea0e#, 16#8557F119#, 16#8e59F814#,
16#Bf73C737#, 16#B47dCe3a#, 16#A96fD52d#, 16#A261Dc20#,
16#F6Ad766d#, 16#FdA37f60#, 16#E0B16477#, 16#EbBf6d7a#,
16#Da955259#, 16#D19b5b54#, 16#Cc894043#, 16#C787494e#,
16#AeDd3e05#, 16#A5D33708#, 16#B8C12c1f#, 16#B3Cf2512#,
16#82E51a31#, 16#89Eb133c#, 16#94F9082b#, 16#9fF70126#,
16#464dE6Bd#, 16#4d43EfB0#, 16#5051F4A7#, 16#5b5fFdAa#,
16#6a75C289#, 16#617bCb84#, 16#7c69D093#, 16#7767D99e#,
16#1e3dAeD5#, 16#1533A7D8#, 16#0821BcCf#, 16#032fB5C2#,
16#32058aE1#, 16#390b83Ec#, 16#241998Fb#, 16#2f1791F6#,
16#8d764dD6#, 16#867844Db#, 16#9b6a5fCc#, 16#906456C1#,
16#A14e69E2#, 16#Aa4060Ef#, 16#B7527bF8#, 16#Bc5c72F5#,
16#D50605Be#, 16#De080cB3#, 16#C31a17A4#, 16#C8141eA9#,
16#F93e218a#, 16#F2302887#, 16#Ef223390#, 16#E42c3a9d#,
16#3d96Dd06#, 16#3698D40b#, 16#2b8aCf1c#, 16#2084C611#,
16#11AeF932#, 16#1aA0F03f#, 16#07B2Eb28#, 16#0cBcE225#,
16#65E6956e#, 16#6eE89c63#, 16#73Fa8774#, 16#78F48e79#,
16#49DeB15a#, 16#42D0B857#, 16#5fC2A340#, 16#54CcAa4d#,
16#F741EcDa#, 16#Fc4fE5D7#, 16#E15dFeC0#, 16#Ea53F7Cd#,
16#Db79C8Ee#, 16#D077C1E3#, 16#Cd65DaF4#, 16#C66bD3F9#,
16#Af31A4B2#, 16#A43fAdBf#, 16#B92dB6A8#, 16#B223BfA5#,
16#83098086#, 16#8807898b#, 16#9515929c#, 16#9e1b9b91#,
16#47A17c0a#, 16#4cAf7507#, 16#51Bd6e10#, 16#5aB3671d#,
16#6b99583e#, 16#60975133#, 16#7d854a24#, 16#768b4329#,
16#1fD13462#, 16#14Df3d6f#, 16#09Cd2678#, 16#02C32f75#,
16#33E91056#, 16#38E7195b#, 16#25F5024c#, 16#2eFb0b41#,
16#8c9aD761#, 16#8794De6c#, 16#9a86C57b#, 16#9188Cc76#,
16#A0A2F355#, 16#AbAcFa58#, 16#B6BeE14f#, 16#BdB0E842#,
16#D4Ea9f09#, 16#DfE49604#, 16#C2F68d13#, 16#C9F8841e#,
16#F8D2Bb3d#, 16#F3DcB230#, 16#EeCeA927#, 16#E5C0A02a#,
16#3c7a47B1#, 16#37744eBc#, 16#2a6655Ab#, 16#21685cA6#,
16#10426385#, 16#1b4c6a88#, 16#065e719f#, 16#0d507892#,
16#640a0fD9#, 16#6f0406D4#, 16#72161dC3#, 16#791814Ce#,
16#48322bEd#, 16#433c22E0#, 16#5e2e39F7#, 16#552030Fa#,
16#01Ec9aB7#, 16#0aE293Ba#, 16#17F088Ad#, 16#1cFe81A0#,
16#2dD4Be83#, 16#26DaB78e#, 16#3bC8Ac99#, 16#30C6A594#,
16#599cD2Df#, 16#5292DbD2#, 16#4f80C0C5#, 16#448eC9C8#,
16#75A4F6Eb#, 16#7eAaFfE6#, 16#63B8E4F1#, 16#68B6EdFc#,
16#B10c0a67#, 16#Ba02036a#, 16#A710187d#, 16#Ac1e1170#,
16#9d342e53#, 16#963a275e#, 16#8b283c49#, 16#80263544#,
16#E97c420f#, 16#E2724b02#, 16#Ff605015#, 16#F46e5918#,
16#C544663b#, 16#Ce4a6f36#, 16#D3587421#, 16#D8567d2c#,
16#7a37A10c#, 16#7139A801#, 16#6c2bB316#, 16#6725Ba1b#,
16#560f8538#, 16#5d018c35#, 16#40139722#, 16#4b1d9e2f#,
16#2247E964#, 16#2949E069#, 16#345bFb7e#, 16#3f55F273#,
16#0e7fCd50#, 16#0571C45d#, 16#1863Df4a#, 16#136dD647#,
16#CaD731Dc#, 16#C1D938D1#, 16#DcCb23C6#, 16#D7C52aCb#,
16#E6Ef15E8#, 16#EdE11cE5#, 16#F0F307F2#, 16#FbFd0eFf#,
16#92A779B4#, 16#99A970B9#, 16#84Bb6bAe#, 16#8fB562A3#,
16#Be9f5d80#, 16#B591548d#, 16#A8834f9a#, 16#A38d4697#);
U3 : constant Table_Type := Table_Type'
(16#00000000#, 16#0d0b0e09#, 16#1a161c12#, 16#171d121b#,
16#342c3824#, 16#3927362d#, 16#2e3a2436#, 16#23312a3f#,
16#68587048#, 16#65537e41#, 16#724e6c5a#, 16#7f456253#,
16#5c74486c#, 16#517f4665#, 16#4662547e#, 16#4b695a77#,
16#D0B0E090#, 16#DdBbEe99#, 16#CaA6Fc82#, 16#C7AdF28b#,
16#E49cD8B4#, 16#E997D6Bd#, 16#Fe8aC4A6#, 16#F381CaAf#,
16#B8E890D8#, 16#B5E39eD1#, 16#A2Fe8cCa#, 16#AfF582C3#,
16#8cC4A8Fc#, 16#81CfA6F5#, 16#96D2B4Ee#, 16#9bD9BaE7#,
16#Bb7bDb3b#, 16#B670D532#, 16#A16dC729#, 16#Ac66C920#,
16#8f57E31f#, 16#825cEd16#, 16#9541Ff0d#, 16#984aF104#,
16#D323Ab73#, 16#De28A57a#, 16#C935B761#, 16#C43eB968#,
16#E70f9357#, 16#Ea049d5e#, 16#Fd198f45#, 16#F012814c#,
16#6bCb3bAb#, 16#66C035A2#, 16#71Dd27B9#, 16#7cD629B0#,
16#5fE7038f#, 16#52Ec0d86#, 16#45F11f9d#, 16#48Fa1194#,
16#03934bE3#, 16#0e9845Ea#, 16#198557F1#, 16#148e59F8#,
16#37Bf73C7#, 16#3aB47dCe#, 16#2dA96fD5#, 16#20A261Dc#,
16#6dF6Ad76#, 16#60FdA37f#, 16#77E0B164#, 16#7aEbBf6d#,
16#59Da9552#, 16#54D19b5b#, 16#43Cc8940#, 16#4eC78749#,
16#05AeDd3e#, 16#08A5D337#, 16#1fB8C12c#, 16#12B3Cf25#,
16#3182E51a#, 16#3c89Eb13#, 16#2b94F908#, 16#269fF701#,
16#Bd464dE6#, 16#B04d43Ef#, 16#A75051F4#, 16#Aa5b5fFd#,
16#896a75C2#, 16#84617bCb#, 16#937c69D0#, 16#9e7767D9#,
16#D51e3dAe#, 16#D81533A7#, 16#Cf0821Bc#, 16#C2032fB5#,
16#E132058a#, 16#Ec390b83#, 16#Fb241998#, 16#F62f1791#,
16#D68d764d#, 16#Db867844#, 16#Cc9b6a5f#, 16#C1906456#,
16#E2A14e69#, 16#EfAa4060#, 16#F8B7527b#, 16#F5Bc5c72#,
16#BeD50605#, 16#B3De080c#, 16#A4C31a17#, 16#A9C8141e#,
16#8aF93e21#, 16#87F23028#, 16#90Ef2233#, 16#9dE42c3a#,
16#063d96Dd#, 16#0b3698D4#, 16#1c2b8aCf#, 16#112084C6#,
16#3211AeF9#, 16#3f1aA0F0#, 16#2807B2Eb#, 16#250cBcE2#,
16#6e65E695#, 16#636eE89c#, 16#7473Fa87#, 16#7978F48e#,
16#5a49DeB1#, 16#5742D0B8#, 16#405fC2A3#, 16#4d54CcAa#,
16#DaF741Ec#, 16#D7Fc4fE5#, 16#C0E15dFe#, 16#CdEa53F7#,
16#EeDb79C8#, 16#E3D077C1#, 16#F4Cd65Da#, 16#F9C66bD3#,
16#B2Af31A4#, 16#BfA43fAd#, 16#A8B92dB6#, 16#A5B223Bf#,
16#86830980#, 16#8b880789#, 16#9c951592#, 16#919e1b9b#,
16#0a47A17c#, 16#074cAf75#, 16#1051Bd6e#, 16#1d5aB367#,
16#3e6b9958#, 16#33609751#, 16#247d854a#, 16#29768b43#,
16#621fD134#, 16#6f14Df3d#, 16#7809Cd26#, 16#7502C32f#,
16#5633E910#, 16#5b38E719#, 16#4c25F502#, 16#412eFb0b#,
16#618c9aD7#, 16#6c8794De#, 16#7b9a86C5#, 16#769188Cc#,
16#55A0A2F3#, 16#58AbAcFa#, 16#4fB6BeE1#, 16#42BdB0E8#,
16#09D4Ea9f#, 16#04DfE496#, 16#13C2F68d#, 16#1eC9F884#,
16#3dF8D2Bb#, 16#30F3DcB2#, 16#27EeCeA9#, 16#2aE5C0A0#,
16#B13c7a47#, 16#Bc37744e#, 16#Ab2a6655#, 16#A621685c#,
16#85104263#, 16#881b4c6a#, 16#9f065e71#, 16#920d5078#,
16#D9640a0f#, 16#D46f0406#, 16#C372161d#, 16#Ce791814#,
16#Ed48322b#, 16#E0433c22#, 16#F75e2e39#, 16#Fa552030#,
16#B701Ec9a#, 16#Ba0aE293#, 16#Ad17F088#, 16#A01cFe81#,
16#832dD4Be#, 16#8e26DaB7#, 16#993bC8Ac#, 16#9430C6A5#,
16#Df599cD2#, 16#D25292Db#, 16#C54f80C0#, 16#C8448eC9#,
16#Eb75A4F6#, 16#E67eAaFf#, 16#F163B8E4#, 16#Fc68B6Ed#,
16#67B10c0a#, 16#6aBa0203#, 16#7dA71018#, 16#70Ac1e11#,
16#539d342e#, 16#5e963a27#, 16#498b283c#, 16#44802635#,
16#0fE97c42#, 16#02E2724b#, 16#15Ff6050#, 16#18F46e59#,
16#3bC54466#, 16#36Ce4a6f#, 16#21D35874#, 16#2cD8567d#,
16#0c7a37A1#, 16#017139A8#, 16#166c2bB3#, 16#1b6725Ba#,
16#38560f85#, 16#355d018c#, 16#22401397#, 16#2f4b1d9e#,
16#642247E9#, 16#692949E0#, 16#7e345bFb#, 16#733f55F2#,
16#500e7fCd#, 16#5d0571C4#, 16#4a1863Df#, 16#47136dD6#,
16#DcCaD731#, 16#D1C1D938#, 16#C6DcCb23#, 16#CbD7C52a#,
16#E8E6Ef15#, 16#E5EdE11c#, 16#F2F0F307#, 16#FfFbFd0e#,
16#B492A779#, 16#B999A970#, 16#Ae84Bb6b#, 16#A38fB562#,
16#80Be9f5d#, 16#8dB59154#, 16#9aA8834f#, 16#97A38d46#);
U4 : constant Table_Type := Table_Type'
(16#00000000#, 16#090d0b0e#, 16#121a161c#, 16#1b171d12#,
16#24342c38#, 16#2d392736#, 16#362e3a24#, 16#3f23312a#,
16#48685870#, 16#4165537e#, 16#5a724e6c#, 16#537f4562#,
16#6c5c7448#, 16#65517f46#, 16#7e466254#, 16#774b695a#,
16#90D0B0E0#, 16#99DdBbEe#, 16#82CaA6Fc#, 16#8bC7AdF2#,
16#B4E49cD8#, 16#BdE997D6#, 16#A6Fe8aC4#, 16#AfF381Ca#,
16#D8B8E890#, 16#D1B5E39e#, 16#CaA2Fe8c#, 16#C3AfF582#,
16#Fc8cC4A8#, 16#F581CfA6#, 16#Ee96D2B4#, 16#E79bD9Ba#,
16#3bBb7bDb#, 16#32B670D5#, 16#29A16dC7#, 16#20Ac66C9#,
16#1f8f57E3#, 16#16825cEd#, 16#0d9541Ff#, 16#04984aF1#,
16#73D323Ab#, 16#7aDe28A5#, 16#61C935B7#, 16#68C43eB9#,
16#57E70f93#, 16#5eEa049d#, 16#45Fd198f#, 16#4cF01281#,
16#Ab6bCb3b#, 16#A266C035#, 16#B971Dd27#, 16#B07cD629#,
16#8f5fE703#, 16#8652Ec0d#, 16#9d45F11f#, 16#9448Fa11#,
16#E303934b#, 16#Ea0e9845#, 16#F1198557#, 16#F8148e59#,
16#C737Bf73#, 16#Ce3aB47d#, 16#D52dA96f#, 16#Dc20A261#,
16#766dF6Ad#, 16#7f60FdA3#, 16#6477E0B1#, 16#6d7aEbBf#,
16#5259Da95#, 16#5b54D19b#, 16#4043Cc89#, 16#494eC787#,
16#3e05AeDd#, 16#3708A5D3#, 16#2c1fB8C1#, 16#2512B3Cf#,
16#1a3182E5#, 16#133c89Eb#, 16#082b94F9#, 16#01269fF7#,
16#E6Bd464d#, 16#EfB04d43#, 16#F4A75051#, 16#FdAa5b5f#,
16#C2896a75#, 16#Cb84617b#, 16#D0937c69#, 16#D99e7767#,
16#AeD51e3d#, 16#A7D81533#, 16#BcCf0821#, 16#B5C2032f#,
16#8aE13205#, 16#83Ec390b#, 16#98Fb2419#, 16#91F62f17#,
16#4dD68d76#, 16#44Db8678#, 16#5fCc9b6a#, 16#56C19064#,
16#69E2A14e#, 16#60EfAa40#, 16#7bF8B752#, 16#72F5Bc5c#,
16#05BeD506#, 16#0cB3De08#, 16#17A4C31a#, 16#1eA9C814#,
16#218aF93e#, 16#2887F230#, 16#3390Ef22#, 16#3a9dE42c#,
16#Dd063d96#, 16#D40b3698#, 16#Cf1c2b8a#, 16#C6112084#,
16#F93211Ae#, 16#F03f1aA0#, 16#Eb2807B2#, 16#E2250cBc#,
16#956e65E6#, 16#9c636eE8#, 16#877473Fa#, 16#8e7978F4#,
16#B15a49De#, 16#B85742D0#, 16#A3405fC2#, 16#Aa4d54Cc#,
16#EcDaF741#, 16#E5D7Fc4f#, 16#FeC0E15d#, 16#F7CdEa53#,
16#C8EeDb79#, 16#C1E3D077#, 16#DaF4Cd65#, 16#D3F9C66b#,
16#A4B2Af31#, 16#AdBfA43f#, 16#B6A8B92d#, 16#BfA5B223#,
16#80868309#, 16#898b8807#, 16#929c9515#, 16#9b919e1b#,
16#7c0a47A1#, 16#75074cAf#, 16#6e1051Bd#, 16#671d5aB3#,
16#583e6b99#, 16#51336097#, 16#4a247d85#, 16#4329768b#,
16#34621fD1#, 16#3d6f14Df#, 16#267809Cd#, 16#2f7502C3#,
16#105633E9#, 16#195b38E7#, 16#024c25F5#, 16#0b412eFb#,
16#D7618c9a#, 16#De6c8794#, 16#C57b9a86#, 16#Cc769188#,
16#F355A0A2#, 16#Fa58AbAc#, 16#E14fB6Be#, 16#E842BdB0#,
16#9f09D4Ea#, 16#9604DfE4#, 16#8d13C2F6#, 16#841eC9F8#,
16#Bb3dF8D2#, 16#B230F3Dc#, 16#A927EeCe#, 16#A02aE5C0#,
16#47B13c7a#, 16#4eBc3774#, 16#55Ab2a66#, 16#5cA62168#,
16#63851042#, 16#6a881b4c#, 16#719f065e#, 16#78920d50#,
16#0fD9640a#, 16#06D46f04#, 16#1dC37216#, 16#14Ce7918#,
16#2bEd4832#, 16#22E0433c#, 16#39F75e2e#, 16#30Fa5520#,
16#9aB701Ec#, 16#93Ba0aE2#, 16#88Ad17F0#, 16#81A01cFe#,
16#Be832dD4#, 16#B78e26Da#, 16#Ac993bC8#, 16#A59430C6#,
16#D2Df599c#, 16#DbD25292#, 16#C0C54f80#, 16#C9C8448e#,
16#F6Eb75A4#, 16#FfE67eAa#, 16#E4F163B8#, 16#EdFc68B6#,
16#0a67B10c#, 16#036aBa02#, 16#187dA710#, 16#1170Ac1e#,
16#2e539d34#, 16#275e963a#, 16#3c498b28#, 16#35448026#,
16#420fE97c#, 16#4b02E272#, 16#5015Ff60#, 16#5918F46e#,
16#663bC544#, 16#6f36Ce4a#, 16#7421D358#, 16#7d2cD856#,
16#A10c7a37#, 16#A8017139#, 16#B3166c2b#, 16#Ba1b6725#,
16#8538560f#, 16#8c355d01#, 16#97224013#, 16#9e2f4b1d#,
16#E9642247#, 16#E0692949#, 16#Fb7e345b#, 16#F2733f55#,
16#Cd500e7f#, 16#C45d0571#, 16#Df4a1863#, 16#D647136d#,
16#31DcCaD7#, 16#38D1C1D9#, 16#23C6DcCb#, 16#2aCbD7C5#,
16#15E8E6Ef#, 16#1cE5EdE1#, 16#07F2F0F3#, 16#0eFfFbFd#,
16#79B492A7#, 16#70B999A9#, 16#6bAe84Bb#, 16#62A38fB5#,
16#5d80Be9f#, 16#548dB591#, 16#4f9aA883#, 16#4697A38d#);
Rcon : constant Rcon_Type := Rcon_Type'
(16#0100_0000#, 16#0200_0000#, 16#0400_0000#, 16#0800_0000#,
16#1000_0000#, 16#2000_0000#, 16#4000_0000#, 16#8000_0000#,
16#1b00_0000#, 16#3600_0000#, 16#6c00_0000#, 16#D800_0000#,
16#Ab00_0000#, 16#4d00_0000#, 16#9a00_0000#, 16#2f00_0000#,
16#5e00_0000#, 16#Bc00_0000#, 16#6300_0000#, 16#C600_0000#,
16#9700_0000#, 16#3500_0000#, 16#6a00_0000#, 16#D400_0000#,
16#B300_0000#, 16#7d00_0000#, 16#Fa00_0000#, 16#Ef00_0000#,
16#C500_0000#, 16#9100_0000#);
end LSC.Internal.AES.Tables;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . R E G P A T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1986 by University of Toronto. --
-- Copyright (C) 1996-2010, 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 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 implements roughly the same set of regular expressions as
-- are available in the Perl or Python programming languages.
-- This is an extension of the original V7 style regular expression library
-- written in C by Henry Spencer. Apart from the translation to Ada, the
-- interface has been considerably changed to use the Ada String type
-- instead of C-style nul-terminated strings.
-- See file s-regpat.ads for full documentation of the interface
------------------------------------------------------------
-- Summary of Pattern Matching Packages in GNAT Hierarchy --
------------------------------------------------------------
-- There are three related packages that perform pattern matching functions.
-- the following is an outline of these packages, to help you determine
-- which is best for your needs.
-- GNAT.Regexp (files g-regexp.ads/s-regexp.ads/s-regexp.adb)
-- This is a simple package providing Unix-style regular expression
-- matching with the restriction that it matches entire strings. It
-- is particularly useful for file name matching, and in particular
-- it provides "globbing patterns" that are useful in implementing
-- unix or DOS style wild card matching for file names.
-- GNAT.Regpat (files g-regpat.ads/s-regpat.ads/s-regpat.adb)
-- This is a more complete implementation of Unix-style regular
-- expressions, copied from the Perl regular expression engine,
-- written originally in C by Henry Spencer. It is functionally the
-- same as that library.
-- GNAT.Spitbol.Patterns (files g-spipat.ads/g-spipat.adb)
-- This is a completely general pattern matching package based on the
-- pattern language of SNOBOL4, as implemented in SPITBOL. The pattern
-- language is modeled on context free grammars, with context sensitive
-- extensions that provide full (type 0) computational capabilities.
with System.Regpat;
package GNAT.Regpat renames System.Regpat;
|
-----------------------------------------------------------------------
-- awa-permissions-controllers -- Permission controllers
-- Copyright (C) 2011, 2012, 2013, 2014, 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 ADO.Sessions;
with ADO.Statements;
with Util.Log.Loggers;
with Util.Strings;
with AWA.Applications;
with AWA.Users.Principals;
with AWA.Permissions.Services;
with AWA.Services.Contexts;
package body AWA.Permissions.Controllers is
Log : constant Util.Log.Loggers.Logger
:= Util.Log.Loggers.Create ("AWA.Permissions.Controllers");
-- ------------------------------
-- Returns true if the user associated with the security context <b>Context</b> has
-- the permission to access a database entity. The security context contains some
-- information about the entity to check and the permission controller will use an
-- SQL statement to verify the permission.
-- ------------------------------
overriding
function Has_Permission (Handler : in Entity_Controller;
Context : in Security.Contexts.Security_Context'Class;
Permission : in Security.Permissions.Permission'Class)
return Boolean is
use AWA.Permissions.Services;
use AWA.Users.Principals;
use type ADO.Identifier;
use type ADO.Entity_Type;
Manager : constant Permission_Manager_Access := Get_Permission_Manager (Context);
User_Id : constant ADO.Identifier := Get_User_Identifier (Context.Get_User_Principal);
Entity_Id : ADO.Identifier;
begin
-- If there is no permission manager, permission is denied.
if Manager = null or else User_Id = ADO.NO_IDENTIFIER then
return False;
end if;
-- If the user is not logged, permission is denied.
if Manager = null or else User_Id = ADO.NO_IDENTIFIER then
Log.Info ("No user identifier in the security context. Permission is denied");
return False;
end if;
if not (Permission in Entity_Permission'Class) then
Log.Info ("Permission {0} denied because the entity is not given.",
Security.Permissions.Permission_Index'Image (Permission.Id));
return False;
end if;
Entity_Id := Entity_Permission'Class (Permission).Entity;
-- If the security context does not contain the entity identifier, permission is denied.
if Entity_Id = ADO.NO_IDENTIFIER then
Log.Info ("No entity identifier in the security context. Permission is denied");
return False;
end if;
declare
function Get_Session return ADO.Sessions.Session;
-- ------------------------------
-- Get a database session from the AWA application.
-- There is no guarantee that a AWA.Services.Contexts be available.
-- But if we are within a service context, we must use the current session so
-- that we are part of the current transaction.
-- ------------------------------
function Get_Session return ADO.Sessions.Session is
package ASC renames AWA.Services.Contexts;
use type ASC.Service_Context_Access;
Ctx : constant ASC.Service_Context_Access := ASC.Current;
begin
if Ctx /= null then
return AWA.Services.Contexts.Get_Session (Ctx);
else
return Manager.Get_Application.Get_Session;
end if;
end Get_Session;
Session : constant ADO.Sessions.Session := Get_Session;
Query : ADO.Statements.Query_Statement := Session.Create_Statement (Handler.SQL);
Result : Integer;
begin
-- Build the query
Query.Bind_Param (Name => "entity_id", Value => Entity_Id);
Query.Bind_Param (Name => "user_id", Value => User_Id);
if Handler.Entities (2) /= ADO.NO_ENTITY_TYPE then
for I in Handler.Entities'Range loop
exit when Handler.Entities (I) = ADO.NO_ENTITY_TYPE;
Query.Bind_Param (Name => "entity_type_" & Util.Strings.Image (I),
Value => Handler.Entities (I));
end loop;
else
Query.Bind_Param (Name => "entity_type", Value => Handler.Entities (1));
end if;
-- Run the query. We must get a single row result and the value must be > 0.
Query.Execute;
Result := Query.Get_Result_Integer;
if Result >= 0 and Query.Has_Elements then
Log.Info ("Permission granted to {0} on entity {1}",
ADO.Identifier'Image (User_Id),
ADO.Identifier'Image (Entity_Id));
return True;
else
Log.Info ("Permission denied to {0} on entity {1}",
ADO.Identifier'Image (User_Id),
ADO.Identifier'Image (Entity_Id));
return False;
end if;
end;
end Has_Permission;
end AWA.Permissions.Controllers;
|
-- This spec has been automatically generated from cm4f.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package Cortex_M_SVD.Debug is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Debug Fault Status Register
type DFSR_Register is record
HALTED : Boolean := False;
-- BKPT instruction executed or breakpoint match in FPB.
BKPT : Boolean := False;
-- Data Watchpoint and Trace trap. Indicates that the core halted due to
-- at least one DWT trap event.
DWTTRAP : Boolean := False;
-- Vector catch triggered. Corresponding FSR will contain the primary
-- cause of the exception.
VCATCH : Boolean := False;
-- An asynchronous exception generated due to the assertion of EDBGRQ.
EXTERNAL : Boolean := False;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DFSR_Register use record
HALTED at 0 range 0 .. 0;
BKPT at 0 range 1 .. 1;
DWTTRAP at 0 range 2 .. 2;
VCATCH at 0 range 3 .. 3;
EXTERNAL at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-------------------------------
-- DHCSR cluster's Registers --
-------------------------------
type Read_DHCSR_Register is record
-- Read-only.
C_DEBUGGEN : Boolean;
-- Read-only.
C_HALT : Boolean;
-- Read-only.
C_STEP : Boolean;
-- Read-only.
C_MASKINTS : Boolean;
-- unspecified
Reserved_4_4 : HAL.Bit;
-- Read-only.
C_SNAPSTALL : Boolean;
-- unspecified
Reserved_6_15 : HAL.UInt10;
-- Read-only.
S_REGRDY : Boolean;
-- Read-only.
S_HALT : Boolean;
-- Read-only.
S_SLEEP : Boolean;
-- Read-only.
S_LOCKUP : Boolean;
-- unspecified
Reserved_20_23 : HAL.UInt4;
-- Read-only.
S_RETIRE_ST : Boolean;
-- Read-only.
S_RESET_ST : Boolean;
-- unspecified
Reserved_26_31 : HAL.UInt6;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for Read_DHCSR_Register use record
C_DEBUGGEN at 0 range 0 .. 0;
C_HALT at 0 range 1 .. 1;
C_STEP at 0 range 2 .. 2;
C_MASKINTS at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
C_SNAPSTALL at 0 range 5 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
S_REGRDY at 0 range 16 .. 16;
S_HALT at 0 range 17 .. 17;
S_SLEEP at 0 range 18 .. 18;
S_LOCKUP at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
S_RETIRE_ST at 0 range 24 .. 24;
S_RESET_ST at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype Write_DHCSR_S_RESET_ST_Field is HAL.UInt16;
type Write_DHCSR_Register is record
-- Write-only.
C_DEBUGGEN : Boolean := False;
-- Write-only.
C_HALT : Boolean := False;
-- Write-only.
C_STEP : Boolean := False;
-- Write-only.
C_MASKINTS : Boolean := False;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- Write-only.
C_SNAPSTALL : Boolean := False;
-- unspecified
Reserved_6_15 : HAL.UInt10 := 16#0#;
-- Write-only. Debug Key. The value 0xA05F must be written to enable
-- write accesses to bits [15:0], otherwise the write access will be
-- ignored. Read behavior of bits [31:16] is as listed below.
S_RESET_ST : Write_DHCSR_S_RESET_ST_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for Write_DHCSR_Register use record
C_DEBUGGEN at 0 range 0 .. 0;
C_HALT at 0 range 1 .. 1;
C_STEP at 0 range 2 .. 2;
C_MASKINTS at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
C_SNAPSTALL at 0 range 5 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
S_RESET_ST at 0 range 16 .. 31;
end record;
type DHCSR_Disc is
(
Mode_1,
Mode_2);
-- Debug Halting Control and Status Register
type DHCSR_Cluster
(Discriminent : DHCSR_Disc := Mode_1)
is record
case Discriminent is
when Mode_1 =>
Read : aliased Read_DHCSR_Register;
when Mode_2 =>
Write : aliased Write_DHCSR_Register;
end case;
end record
with Unchecked_Union, Volatile, Size => 32;
for DHCSR_Cluster use record
Read at 0 range 0 .. 31;
Write at 0 range 0 .. 31;
end record;
type DCRSR_HALTED_Field is
(
Register_0,
Register_1,
Register_2,
Register_3,
Register_4,
Register_5,
Register_6,
Register_7,
Register_8,
Register_9,
Register_10,
Register_11,
Register_12,
Current_Sp,
Link_Rregister,
Debug_Return_Address,
XPsr,
Msp,
Psp,
Control_Faultmask_Basepri_Primask)
with Size => 5;
for DCRSR_HALTED_Field use
(Register_0 => 0,
Register_1 => 1,
Register_2 => 2,
Register_3 => 3,
Register_4 => 4,
Register_5 => 5,
Register_6 => 6,
Register_7 => 7,
Register_8 => 8,
Register_9 => 9,
Register_10 => 10,
Register_11 => 11,
Register_12 => 12,
Current_Sp => 13,
Link_Rregister => 14,
Debug_Return_Address => 15,
XPsr => 16,
Msp => 17,
Psp => 18,
Control_Faultmask_Basepri_Primask => 19);
type DCRSR_REGWnR_Field is
(
Read,
Write)
with Size => 1;
for DCRSR_REGWnR_Field use
(Read => 0,
Write => 1);
-- Debug Core Register Selector Register: The DCRSR write-only register
-- generates a handshake to the core to transfer the selected register
-- to/from the DCRDR. The DHCSR S_REGRDY bit is cleared when the DCRSR is
-- written, and remains clear until the core transaction completes. This
-- register is only accessible from Debug state.
type DCRSR_Register is record
-- Write-only.
HALTED : DCRSR_HALTED_Field := Cortex_M_SVD.Debug.Register_0;
-- unspecified
Reserved_5_15 : HAL.UInt11 := 16#0#;
-- Write-only.
REGWnR : DCRSR_REGWnR_Field := Cortex_M_SVD.Debug.Read;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCRSR_Register use record
HALTED at 0 range 0 .. 4;
Reserved_5_15 at 0 range 5 .. 15;
REGWnR at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- Debug Exception and Monitor Control Register
type DEMCR_Register is record
VC_CORERESET : Boolean := False;
-- unspecified
Reserved_1_3 : HAL.UInt3 := 16#0#;
VC_MMERR : Boolean := False;
VC_NOCPERR : Boolean := False;
VC_CHKERR : Boolean := False;
VC_STATERR : Boolean := False;
VC_BUSERR : Boolean := False;
VC_INTERR : Boolean := False;
VC_HARDERR : Boolean := False;
-- unspecified
Reserved_11_15 : HAL.UInt5 := 16#0#;
MON_EN : Boolean := False;
MON_PEND : Boolean := False;
MON_STEP : Boolean := False;
MON_REQ : Boolean := False;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
TRCENA : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DEMCR_Register use record
VC_CORERESET at 0 range 0 .. 0;
Reserved_1_3 at 0 range 1 .. 3;
VC_MMERR at 0 range 4 .. 4;
VC_NOCPERR at 0 range 5 .. 5;
VC_CHKERR at 0 range 6 .. 6;
VC_STATERR at 0 range 7 .. 7;
VC_BUSERR at 0 range 8 .. 8;
VC_INTERR at 0 range 9 .. 9;
VC_HARDERR at 0 range 10 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
MON_EN at 0 range 16 .. 16;
MON_PEND at 0 range 17 .. 17;
MON_STEP at 0 range 18 .. 18;
MON_REQ at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
TRCENA at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type Debug_Peripheral is record
-- Debug Fault Status Register
DFSR : aliased DFSR_Register;
-- Debug Halting Control and Status Register
DHCSR : aliased DHCSR_Cluster;
-- Debug Core Register Selector Register: The DCRSR write-only register
-- generates a handshake to the core to transfer the selected register
-- to/from the DCRDR. The DHCSR S_REGRDY bit is cleared when the DCRSR
-- is written, and remains clear until the core transaction completes.
-- This register is only accessible from Debug state.
DCRSR : aliased DCRSR_Register;
-- Debug Core Register Data Register
DCRDR : aliased HAL.UInt32;
-- Debug Exception and Monitor Control Register
DEMCR : aliased DEMCR_Register;
end record
with Volatile;
for Debug_Peripheral use record
DFSR at 16#30# range 0 .. 31;
DHCSR at 16#F0# range 0 .. 31;
DCRSR at 16#F4# range 0 .. 31;
DCRDR at 16#F8# range 0 .. 31;
DEMCR at 16#FC# range 0 .. 31;
end record;
Debug_Periph : aliased Debug_Peripheral
with Import, Address => Debug_Base;
end Cortex_M_SVD.Debug;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A . E X C E P T I O N S . E X C E P T I O N _ P R O P A G A T I O N --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the version using the GCC EH mechanism
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Storage_Elements; use System.Storage_Elements;
with System.Exceptions.Machine; use System.Exceptions.Machine;
separate (Ada.Exceptions)
package body Exception_Propagation is
use Exception_Traces;
Foreign_Exception : aliased System.Standard_Library.Exception_Data;
pragma Import (Ada, Foreign_Exception,
"system__exceptions__foreign_exception");
-- Id for foreign exceptions
--------------------------------------------------------------
-- GNAT Specific Entities To Deal With The GCC EH Circuitry --
--------------------------------------------------------------
procedure GNAT_GCC_Exception_Cleanup
(Reason : Unwind_Reason_Code;
Excep : not null GNAT_GCC_Exception_Access);
pragma Convention (C, GNAT_GCC_Exception_Cleanup);
-- Procedure called when a GNAT GCC exception is free.
procedure Propagate_GCC_Exception
(GCC_Exception : not null GCC_Exception_Access);
pragma No_Return (Propagate_GCC_Exception);
-- Propagate a GCC exception
procedure Reraise_GCC_Exception
(GCC_Exception : not null GCC_Exception_Access);
pragma No_Return (Reraise_GCC_Exception);
pragma Export (C, Reraise_GCC_Exception, "__gnat_reraise_zcx");
-- Called to implement raise without exception, ie reraise. Called
-- directly from gigi.
function Setup_Current_Excep
(GCC_Exception : not null GCC_Exception_Access) return EOA;
pragma Export (C, Setup_Current_Excep, "__gnat_setup_current_excep");
-- Write Get_Current_Excep.all from GCC_Exception. Called by the
-- personality routine.
procedure Unhandled_Except_Handler
(GCC_Exception : not null GCC_Exception_Access);
pragma No_Return (Unhandled_Except_Handler);
pragma Export (C, Unhandled_Except_Handler,
"__gnat_unhandled_except_handler");
-- Called for handle unhandled exceptions, ie the last chance handler
-- on platforms (such as SEH) that never returns after throwing an
-- exception. Called directly by gigi.
function CleanupUnwind_Handler
(UW_Version : Integer;
UW_Phases : Unwind_Action;
UW_Eclass : Exception_Class;
UW_Exception : not null GCC_Exception_Access;
UW_Context : System.Address;
UW_Argument : System.Address) return Unwind_Reason_Code;
pragma Import (C, CleanupUnwind_Handler,
"__gnat_cleanupunwind_handler");
-- Hook called at each step of the forced unwinding we perform to trigger
-- cleanups found during the propagation of an unhandled exception.
-- GCC runtime functions used. These are C non-void functions, actually,
-- but we ignore the return values. See raise.c as to why we are using
-- __gnat stubs for these.
procedure Unwind_RaiseException
(UW_Exception : not null GCC_Exception_Access);
pragma Import (C, Unwind_RaiseException, "__gnat_Unwind_RaiseException");
procedure Unwind_ForcedUnwind
(UW_Exception : not null GCC_Exception_Access;
UW_Handler : System.Address;
UW_Argument : System.Address);
pragma Import (C, Unwind_ForcedUnwind, "__gnat_Unwind_ForcedUnwind");
procedure Set_Exception_Parameter
(Excep : EOA;
GCC_Exception : not null GCC_Exception_Access);
pragma Export
(C, Set_Exception_Parameter, "__gnat_set_exception_parameter");
-- Called inserted by gigi to set the exception choice parameter from the
-- gcc occurrence.
procedure Set_Foreign_Occurrence (Excep : EOA; Mo : System.Address);
-- Utility routine to initialize occurrence Excep from a foreign exception
-- whose machine occurrence is Mo. The message is empty, the backtrace
-- is empty too and the exception identity is Foreign_Exception.
-- Hooks called when entering/leaving an exception handler for a given
-- occurrence, aimed at handling the stack of active occurrences. The
-- calls are generated by gigi in tree_transform/N_Exception_Handler.
procedure Begin_Handler (GCC_Exception : not null GCC_Exception_Access);
pragma Export (C, Begin_Handler, "__gnat_begin_handler");
procedure End_Handler (GCC_Exception : GCC_Exception_Access);
pragma Export (C, End_Handler, "__gnat_end_handler");
--------------------------------------------------------------------
-- Accessors to Basic Components of a GNAT Exception Data Pointer --
--------------------------------------------------------------------
-- As of today, these are only used by the C implementation of the GCC
-- propagation personality routine to avoid having to rely on a C
-- counterpart of the whole exception_data structure, which is both
-- painful and error prone. These subprograms could be moved to a more
-- widely visible location if need be.
function Is_Handled_By_Others (E : Exception_Data_Ptr) return Boolean;
pragma Export (C, Is_Handled_By_Others, "__gnat_is_handled_by_others");
pragma Warnings (Off, Is_Handled_By_Others);
function Language_For (E : Exception_Data_Ptr) return Character;
pragma Export (C, Language_For, "__gnat_language_for");
function Foreign_Data_For (E : Exception_Data_Ptr) return Address;
pragma Export (C, Foreign_Data_For, "__gnat_foreign_data_for");
function EID_For (GNAT_Exception : not null GNAT_GCC_Exception_Access)
return Exception_Id;
pragma Export (C, EID_For, "__gnat_eid_for");
---------------------------------------------------------------------------
-- Objects to materialize "others" and "all others" in the GCC EH tables --
---------------------------------------------------------------------------
-- Currently, these only have their address taken and compared so there is
-- no real point having whole exception data blocks allocated. Note that
-- there are corresponding declarations in gigi (trans.c) which must be
-- kept properly synchronized.
Others_Value : constant Character := 'O';
pragma Export (C, Others_Value, "__gnat_others_value");
All_Others_Value : constant Character := 'A';
pragma Export (C, All_Others_Value, "__gnat_all_others_value");
Unhandled_Others_Value : constant Character := 'U';
pragma Export (C, Unhandled_Others_Value, "__gnat_unhandled_others_value");
-- Special choice (emitted by gigi) to catch and notify unhandled
-- exceptions on targets which always handle exceptions (such as SEH).
-- The handler will simply call Unhandled_Except_Handler.
-------------------------
-- Allocate_Occurrence --
-------------------------
function Allocate_Occurrence return EOA is
Res : GNAT_GCC_Exception_Access;
begin
Res := New_Occurrence;
Res.Header.Cleanup := GNAT_GCC_Exception_Cleanup'Address;
Res.Occurrence.Machine_Occurrence := Res.all'Address;
return Res.Occurrence'Access;
end Allocate_Occurrence;
--------------------------------
-- GNAT_GCC_Exception_Cleanup --
--------------------------------
procedure GNAT_GCC_Exception_Cleanup
(Reason : Unwind_Reason_Code;
Excep : not null GNAT_GCC_Exception_Access)
is
pragma Unreferenced (Reason);
procedure Free is new Unchecked_Deallocation
(GNAT_GCC_Exception, GNAT_GCC_Exception_Access);
Copy : GNAT_GCC_Exception_Access := Excep;
begin
-- Simply free the memory
Free (Copy);
end GNAT_GCC_Exception_Cleanup;
----------------------------
-- Set_Foreign_Occurrence --
----------------------------
procedure Set_Foreign_Occurrence (Excep : EOA; Mo : System.Address) is
begin
Excep.all := (
Id => Foreign_Exception'Access,
Machine_Occurrence => Mo,
Msg => <>,
Msg_Length => 0,
Exception_Raised => True,
Pid => Local_Partition_ID,
Num_Tracebacks => 0,
Tracebacks => <>);
end Set_Foreign_Occurrence;
-------------------------
-- Setup_Current_Excep --
-------------------------
function Setup_Current_Excep
(GCC_Exception : not null GCC_Exception_Access) return EOA
is
Excep : constant EOA := Get_Current_Excep.all;
begin
-- Setup the exception occurrence
if GCC_Exception.Class = GNAT_Exception_Class then
-- From the GCC exception
declare
GNAT_Occurrence : constant GNAT_GCC_Exception_Access :=
To_GNAT_GCC_Exception (GCC_Exception);
begin
Excep.all := GNAT_Occurrence.Occurrence;
return GNAT_Occurrence.Occurrence'Access;
end;
else
-- A default one
Set_Foreign_Occurrence (Excep, GCC_Exception.all'Address);
return Excep;
end if;
end Setup_Current_Excep;
-------------------
-- Begin_Handler --
-------------------
procedure Begin_Handler (GCC_Exception : not null GCC_Exception_Access) is
pragma Unreferenced (GCC_Exception);
begin
null;
end Begin_Handler;
-----------------
-- End_Handler --
-----------------
procedure End_Handler (GCC_Exception : GCC_Exception_Access) is
begin
if GCC_Exception /= null then
-- The exception might have been reraised, in this case the cleanup
-- mustn't be called.
Unwind_DeleteException (GCC_Exception);
end if;
end End_Handler;
-----------------------------
-- Reraise_GCC_Exception --
-----------------------------
procedure Reraise_GCC_Exception
(GCC_Exception : not null GCC_Exception_Access)
is
begin
-- Simply propagate it
Propagate_GCC_Exception (GCC_Exception);
end Reraise_GCC_Exception;
-----------------------------
-- Propagate_GCC_Exception --
-----------------------------
-- Call Unwind_RaiseException to actually throw, taking care of handling
-- the two phase scheme it implements.
procedure Propagate_GCC_Exception
(GCC_Exception : not null GCC_Exception_Access)
is
Excep : EOA;
begin
-- Perform a standard raise first. If a regular handler is found, it
-- will be entered after all the intermediate cleanups have run. If
-- there is no regular handler, it will return.
Unwind_RaiseException (GCC_Exception);
-- If we get here we know the exception is not handled, as otherwise
-- Unwind_RaiseException arranges for the handler to be entered. Take
-- the necessary steps to enable the debugger to gain control while the
-- stack is still intact.
Excep := Setup_Current_Excep (GCC_Exception);
Notify_Unhandled_Exception (Excep);
-- Now, un a forced unwind to trigger cleanups. Control should not
-- resume there, if there are cleanups and in any cases as the
-- unwinding hook calls Unhandled_Exception_Terminate when end of
-- stack is reached.
Unwind_ForcedUnwind
(GCC_Exception,
CleanupUnwind_Handler'Address,
System.Null_Address);
-- We get here in case of error. The debugger has been notified before
-- the second step above.
Unhandled_Except_Handler (GCC_Exception);
end Propagate_GCC_Exception;
-------------------------
-- Propagate_Exception --
-------------------------
procedure Propagate_Exception (Excep : EOA) is
begin
Propagate_GCC_Exception (To_GCC_Exception (Excep.Machine_Occurrence));
end Propagate_Exception;
-----------------------------
-- Set_Exception_Parameter --
-----------------------------
procedure Set_Exception_Parameter
(Excep : EOA;
GCC_Exception : not null GCC_Exception_Access)
is
begin
-- Setup the exception occurrence
if GCC_Exception.Class = GNAT_Exception_Class then
-- From the GCC exception
declare
GNAT_Occurrence : constant GNAT_GCC_Exception_Access :=
To_GNAT_GCC_Exception (GCC_Exception);
begin
Save_Occurrence (Excep.all, GNAT_Occurrence.Occurrence);
end;
else
-- A default one
Set_Foreign_Occurrence (Excep, GCC_Exception.all'Address);
end if;
end Set_Exception_Parameter;
------------------------------
-- Unhandled_Except_Handler --
------------------------------
procedure Unhandled_Except_Handler
(GCC_Exception : not null GCC_Exception_Access)
is
Excep : EOA;
begin
Excep := Setup_Current_Excep (GCC_Exception);
Unhandled_Exception_Terminate (Excep);
end Unhandled_Except_Handler;
-------------
-- EID_For --
-------------
function EID_For
(GNAT_Exception : not null GNAT_GCC_Exception_Access) return Exception_Id
is
begin
return GNAT_Exception.Occurrence.Id;
end EID_For;
----------------------
-- Foreign_Data_For --
----------------------
function Foreign_Data_For
(E : SSL.Exception_Data_Ptr) return Address
is
begin
return E.Foreign_Data;
end Foreign_Data_For;
--------------------------
-- Is_Handled_By_Others --
--------------------------
function Is_Handled_By_Others (E : SSL.Exception_Data_Ptr) return Boolean is
begin
return not E.all.Not_Handled_By_Others;
end Is_Handled_By_Others;
------------------
-- Language_For --
------------------
function Language_For (E : SSL.Exception_Data_Ptr) return Character is
begin
return E.all.Lang;
end Language_For;
end Exception_Propagation;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.