Debian Codegraph @

gcc/ada/libgnat/g-souinf.ads

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- G N A T . S O U R C E _ I N F O --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2000-2025, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This package provides some useful utility subprograms that provide access
33 -- to source code information known at compile time. These subprograms are
34 -- intrinsic operations that provide information known to the compiler in
35 -- a form that can be embedded into the source program for identification
36 -- and logging purposes. For example, an exception handler can print out
37 -- the name of the source file in which the exception is handled.
38
39 package GNAT.Source_Info with
40 SPARK_Mode,
41 Abstract_State =>
42 (Source_Code_Information with
43 External => (Async_Writers, Async_Readers)),
44 Always_Terminates
45 is
46 pragma Preelaborate;
47 -- Note that this unit is Preelaborate, but not Pure, that's because the
48 -- functions here such as Line are clearly not pure functions, and normally
49 -- we mark intrinsic functions in a Pure unit as Pure, even though they are
50 -- imported.
51 --
52 -- Historical note: this used to be Pure, but that was when we marked all
53 -- intrinsics as not Pure, even in Pure units, so no problems arose.
54
55 function File return String with
56 Volatile_Function,
57 Global => Source_Code_Information,
58 Import, Convention => Intrinsic;
59 -- Return the name of the current file, not including the path information.
60 -- The result is considered to be a static string constant.
61 --
62 -- This function is an intrinsic, implemented by the compiler.
63
64 function Line return Positive with
65 Import, Convention => Intrinsic;
66 -- Return the current input line number. The result is considered to be a
67 -- static expression.
68 --
69 -- This function is an intrinsic, implemented by the compiler.
70
71 function Source_Location return String with
72 Volatile_Function,
73 Global => Source_Code_Information,
74 Import, Convention => Intrinsic;
75 -- Return a string literal of the form "name:line", where name is the
76 -- current source file name without path information, and line is the
77 -- current line number. In the event that instantiations are involved,
78 -- additional suffixes of the same form are appended after the separating
79 -- string " instantiated at ". The result is considered to be a static
80 -- string constant.
81 --
82 -- This function is an intrinsic, implemented by the compiler.
83
84 function Enclosing_Entity return String with
85 Volatile_Function,
86 Global => Source_Code_Information,
87 Import, Convention => Intrinsic;
88 -- Return the name of the current subprogram, package, task, entry or
89 -- protected subprogram. The string is in exactly the form used for the
90 -- declaration of the entity (casing and encoding conventions), and is
91 -- considered to be a static string constant. The name is fully qualified
92 -- using periods where possible (this is not always possible, notably in
93 -- the case of entities appearing in unnamed block statements.)
94 --
95 -- Note: if this function is used at the outer level of a generic package,
96 -- the string returned will be the name of the instance, not the generic
97 -- package itself. This is useful in identifying and logging information
98 -- from within generic templates.
99 --
100 -- This function is an intrinsic, implemented by the compiler.
101
102 function Compilation_ISO_Date return String with
103 Volatile_Function,
104 Global => Source_Code_Information,
105 Import, Convention => Intrinsic;
106 -- Returns date of compilation as a static string "yyyy-mm-dd".
107 --
108 -- This function is an intrinsic, implemented by the compiler.
109
110 function Compilation_Date return String with
111 Volatile_Function,
112 Global => Source_Code_Information,
113 Import, Convention => Intrinsic;
114 -- Returns date of compilation as a static string "mmm dd yyyy". This is
115 -- in local time form, and is exactly compatible with C macro __DATE__.
116 --
117 -- This function is an intrinsic, implemented by the compiler.
118
119 function Compilation_Time return String with
120 Volatile_Function,
121 Global => Source_Code_Information,
122 Import, Convention => Intrinsic;
123 -- Returns GMT time of compilation as a static string "hh:mm:ss". This is
124 -- in local time form, and is exactly compatible with C macro __TIME__.
125 --
126 -- This function is an intrinsic, implemented by the compiler.
127
128 end GNAT.Source_Info;