1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 pragma Style_Checks
(All_Checks
);
33 -- Subprograms not all in alpha order
35 with Atree
; use Atree
;
36 with Debug
; use Debug
;
38 with Output
; use Output
;
39 with Tree_IO
; use Tree_IO
;
40 with System
; use System
;
41 with Widechar
; use Widechar
;
45 with Unchecked_Conversion
;
46 with Unchecked_Deallocation
;
48 package body Sinput
is
51 -- Make control characters visible
53 First_Time_Around
: Boolean := True;
55 -- Routines to support conversion between types Lines_Table_Ptr,
56 -- Logical_Lines_Table_Ptr and System.Address.
58 pragma Warnings
(Off
);
59 -- These unchecked conversions are aliasing safe, since they are never
60 -- used to construct improperly aliased pointer values.
62 function To_Address
is
63 new Unchecked_Conversion
(Lines_Table_Ptr
, Address
);
65 function To_Address
is
66 new Unchecked_Conversion
(Logical_Lines_Table_Ptr
, Address
);
68 function To_Pointer
is
69 new Unchecked_Conversion
(Address
, Lines_Table_Ptr
);
71 function To_Pointer
is
72 new Unchecked_Conversion
(Address
, Logical_Lines_Table_Ptr
);
76 ---------------------------
77 -- Add_Line_Tables_Entry --
78 ---------------------------
80 procedure Add_Line_Tables_Entry
81 (S
: in out Source_File_Record
;
84 LL
: Physical_Line_Number
;
87 -- Reallocate the lines tables if necessary
89 -- Note: the reason we do not use the normal Table package
90 -- mechanism is that we have several of these tables. We could
91 -- use the new GNAT.Dynamic_Tables package and that would probably
94 if S
.Last_Source_Line
= S
.Lines_Table_Max
then
97 Int
(S
.Last_Source_Line
) *
98 ((100 + Alloc
.Lines_Increment
) / 100));
101 Write_Str
("--> Reallocating lines table, size = ");
102 Write_Int
(Int
(S
.Lines_Table_Max
));
107 S
.Last_Source_Line
:= S
.Last_Source_Line
+ 1;
108 LL
:= S
.Last_Source_Line
;
110 S
.Lines_Table
(LL
) := P
;
112 -- Deal with setting new entry in logical lines table if one is
113 -- present. Note that there is always space (because the call to
114 -- Alloc_Line_Tables makes sure both tables are the same length),
116 if S
.Logical_Lines_Table
/= null then
118 -- We can always set the entry from the previous one, because
119 -- the processing for a Source_Reference pragma ensures that
120 -- at least one entry following the pragma is set up correctly.
122 S
.Logical_Lines_Table
(LL
) := S
.Logical_Lines_Table
(LL
- 1) + 1;
124 end Add_Line_Tables_Entry
;
126 -----------------------
127 -- Alloc_Line_Tables --
128 -----------------------
130 procedure Alloc_Line_Tables
131 (S
: in out Source_File_Record
;
134 subtype size_t
is Memory
.size_t
;
136 New_Table
: Lines_Table_Ptr
;
138 New_Logical_Table
: Logical_Lines_Table_Ptr
;
140 New_Size
: constant size_t
:=
141 size_t
(New_Max
* Lines_Table_Type
'Component_Size /
145 if S
.Lines_Table
= null then
146 New_Table
:= To_Pointer
(Memory
.Alloc
(New_Size
));
150 To_Pointer
(Memory
.Realloc
(To_Address
(S
.Lines_Table
), New_Size
));
153 if New_Table
= null then
156 S
.Lines_Table
:= New_Table
;
157 S
.Lines_Table_Max
:= Physical_Line_Number
(New_Max
);
160 if S
.Num_SRef_Pragmas
/= 0 then
161 if S
.Logical_Lines_Table
= null then
162 New_Logical_Table
:= To_Pointer
(Memory
.Alloc
(New_Size
));
164 New_Logical_Table
:= To_Pointer
165 (Memory
.Realloc
(To_Address
(S
.Logical_Lines_Table
), New_Size
));
168 if New_Logical_Table
= null then
171 S
.Logical_Lines_Table
:= New_Logical_Table
;
174 end Alloc_Line_Tables
;
180 procedure Backup_Line
(P
: in out Source_Ptr
) is
181 Sindex
: constant Source_File_Index
:= Get_Source_File_Index
(P
);
182 Src
: constant Source_Buffer_Ptr
:=
183 Source_File
.Table
(Sindex
).Source_Text
;
184 Sfirst
: constant Source_Ptr
:=
185 Source_File
.Table
(Sindex
).Source_First
;
195 if Src
(P
- 1) = LF
then
200 if Src
(P
- 1) = CR
then
205 -- Now find first character of the previous line
208 and then Src
(P
- 1) /= LF
209 and then Src
(P
- 1) /= CR
215 ---------------------------
216 -- Build_Location_String --
217 ---------------------------
219 procedure Build_Location_String
(Loc
: Source_Ptr
) is
223 -- Loop through instantiations
227 Get_Name_String_And_Append
228 (Reference_Name
(Get_Source_File_Index
(Ptr
)));
229 Add_Char_To_Name_Buffer
(':');
230 Add_Nat_To_Name_Buffer
231 (Nat
(Get_Logical_Line_Number
(Ptr
)));
233 Ptr
:= Instantiation_Location
(Ptr
);
234 exit when Ptr
= No_Location
;
235 Add_Str_To_Name_Buffer
(" instantiated at ");
238 Name_Buffer
(Name_Len
+ 1) := NUL
;
240 end Build_Location_String
;
242 -----------------------
243 -- Get_Column_Number --
244 -----------------------
246 function Get_Column_Number
(P
: Source_Ptr
) return Column_Number
is
249 Sindex
: Source_File_Index
;
250 Src
: Source_Buffer_Ptr
;
253 -- If the input source pointer is not a meaningful value then return
254 -- at once with column number 1. This can happen for a file not found
255 -- condition for a file loaded indirectly by RTE, and also perhaps on
256 -- some unknown internal error conditions. In either case we certainly
257 -- don't want to blow up.
263 Sindex
:= Get_Source_File_Index
(P
);
264 Src
:= Source_File
.Table
(Sindex
).Source_Text
;
270 C
:= (C
- 1) / 8 * 8 + (8 + 1);
280 end Get_Column_Number
;
282 -----------------------------
283 -- Get_Logical_Line_Number --
284 -----------------------------
286 function Get_Logical_Line_Number
287 (P
: Source_Ptr
) return Logical_Line_Number
289 SFR
: Source_File_Record
290 renames Source_File
.Table
(Get_Source_File_Index
(P
));
292 L
: constant Physical_Line_Number
:= Get_Physical_Line_Number
(P
);
295 if SFR
.Num_SRef_Pragmas
= 0 then
296 return Logical_Line_Number
(L
);
298 return SFR
.Logical_Lines_Table
(L
);
300 end Get_Logical_Line_Number
;
302 ------------------------------
303 -- Get_Physical_Line_Number --
304 ------------------------------
306 function Get_Physical_Line_Number
307 (P
: Source_Ptr
) return Physical_Line_Number
309 Sfile
: Source_File_Index
;
310 Table
: Lines_Table_Ptr
;
311 Lo
: Physical_Line_Number
;
312 Hi
: Physical_Line_Number
;
313 Mid
: Physical_Line_Number
;
317 -- If the input source pointer is not a meaningful value then return
318 -- at once with line number 1. This can happen for a file not found
319 -- condition for a file loaded indirectly by RTE, and also perhaps on
320 -- some unknown internal error conditions. In either case we certainly
321 -- don't want to blow up.
326 -- Otherwise we can do the binary search
329 Sfile
:= Get_Source_File_Index
(P
);
330 Loc
:= P
+ Source_File
.Table
(Sfile
).Sloc_Adjust
;
331 Table
:= Source_File
.Table
(Sfile
).Lines_Table
;
333 Hi
:= Source_File
.Table
(Sfile
).Last_Source_Line
;
336 Mid
:= (Lo
+ Hi
) / 2;
338 if Loc
< Table
(Mid
) then
341 else -- Loc >= Table (Mid)
344 Loc
< Table
(Mid
+ 1)
355 end Get_Physical_Line_Number
;
357 ---------------------------
358 -- Get_Source_File_Index --
359 ---------------------------
361 Source_Cache_First
: Source_Ptr
:= 1;
362 Source_Cache_Last
: Source_Ptr
:= 0;
363 -- Records the First and Last subscript values for the most recently
364 -- referenced entry in the source table, to optimize the common case of
365 -- repeated references to the same entry. The initial values force an
366 -- initial search to set the cache value.
368 Source_Cache_Index
: Source_File_Index
:= No_Source_File
;
369 -- Contains the index of the entry corresponding to Source_Cache
371 function Get_Source_File_Index
(S
: Source_Ptr
) return Source_File_Index
is
373 if S
in Source_Cache_First
.. Source_Cache_Last
then
374 return Source_Cache_Index
;
377 pragma Assert
(Source_File_Index_Table
(Int
(S
) / Chunk_Size
)
380 for J
in Source_File_Index_Table
(Int
(S
) / Chunk_Size
)
383 if S
in Source_File
.Table
(J
).Source_First
..
384 Source_File
.Table
(J
).Source_Last
386 Source_Cache_Index
:= J
;
387 Source_Cache_First
:=
388 Source_File
.Table
(Source_Cache_Index
).Source_First
;
390 Source_File
.Table
(Source_Cache_Index
).Source_Last
;
391 return Source_Cache_Index
;
396 -- We must find a matching entry in the above loop!
399 end Get_Source_File_Index
;
405 procedure Initialize
is
407 Source_Cache_First
:= 1;
408 Source_Cache_Last
:= 0;
409 Source_Cache_Index
:= No_Source_File
;
410 Source_gnat_adc
:= No_Source_File
;
411 First_Time_Around
:= True;
416 -------------------------
417 -- Instantiation_Depth --
418 -------------------------
420 function Instantiation_Depth
(S
: Source_Ptr
) return Nat
is
421 Sind
: Source_File_Index
;
430 Sind
:= Get_Source_File_Index
(Sval
);
431 Sval
:= Instantiation
(Sind
);
432 exit when Sval
= No_Location
;
437 end Instantiation_Depth
;
439 ----------------------------
440 -- Instantiation_Location --
441 ----------------------------
443 function Instantiation_Location
(S
: Source_Ptr
) return Source_Ptr
is
445 return Instantiation
(Get_Source_File_Index
(S
));
446 end Instantiation_Location
;
448 ----------------------
449 -- Last_Source_File --
450 ----------------------
452 function Last_Source_File
return Source_File_Index
is
454 return Source_File
.Last
;
455 end Last_Source_File
;
461 function Line_Start
(P
: Source_Ptr
) return Source_Ptr
is
462 Sindex
: constant Source_File_Index
:= Get_Source_File_Index
(P
);
463 Src
: constant Source_Buffer_Ptr
:=
464 Source_File
.Table
(Sindex
).Source_Text
;
465 Sfirst
: constant Source_Ptr
:=
466 Source_File
.Table
(Sindex
).Source_First
;
472 and then Src
(S
- 1) /= CR
473 and then Src
(S
- 1) /= LF
482 (L
: Physical_Line_Number
;
483 S
: Source_File_Index
) return Source_Ptr
486 return Source_File
.Table
(S
).Lines_Table
(L
);
495 Source_File
.Locked
:= True;
499 ----------------------
500 -- Num_Source_Files --
501 ----------------------
503 function Num_Source_Files
return Nat
is
505 return Int
(Source_File
.Last
) - Int
(Source_File
.First
) + 1;
506 end Num_Source_Files
;
508 ----------------------
509 -- Num_Source_Lines --
510 ----------------------
512 function Num_Source_Lines
(S
: Source_File_Index
) return Nat
is
514 return Nat
(Source_File
.Table
(S
).Last_Source_Line
);
515 end Num_Source_Lines
;
517 -----------------------
518 -- Original_Location --
519 -----------------------
521 function Original_Location
(S
: Source_Ptr
) return Source_Ptr
is
522 Sindex
: Source_File_Index
;
523 Tindex
: Source_File_Index
;
526 if S
<= No_Location
then
530 Sindex
:= Get_Source_File_Index
(S
);
532 if Instantiation
(Sindex
) = No_Location
then
536 Tindex
:= Template
(Sindex
);
537 while Instantiation
(Tindex
) /= No_Location
loop
538 Tindex
:= Template
(Tindex
);
541 return S
- Source_First
(Sindex
) + Source_First
(Tindex
);
544 end Original_Location
;
546 -------------------------
547 -- Physical_To_Logical --
548 -------------------------
550 function Physical_To_Logical
551 (Line
: Physical_Line_Number
;
552 S
: Source_File_Index
) return Logical_Line_Number
554 SFR
: Source_File_Record
renames Source_File
.Table
(S
);
557 if SFR
.Num_SRef_Pragmas
= 0 then
558 return Logical_Line_Number
(Line
);
560 return SFR
.Logical_Lines_Table
(Line
);
562 end Physical_To_Logical
;
564 --------------------------------
565 -- Register_Source_Ref_Pragma --
566 --------------------------------
568 procedure Register_Source_Ref_Pragma
569 (File_Name
: File_Name_Type
;
570 Stripped_File_Name
: File_Name_Type
;
572 Line_After_Pragma
: Physical_Line_Number
)
574 subtype size_t
is Memory
.size_t
;
576 SFR
: Source_File_Record
renames Source_File
.Table
(Current_Source_File
);
578 ML
: Logical_Line_Number
;
581 if File_Name
/= No_File
then
582 SFR
.Reference_Name
:= Stripped_File_Name
;
583 SFR
.Full_Ref_Name
:= File_Name
;
585 if not Debug_Generated_Code
then
586 SFR
.Debug_Source_Name
:= Stripped_File_Name
;
587 SFR
.Full_Debug_Name
:= File_Name
;
590 SFR
.Num_SRef_Pragmas
:= SFR
.Num_SRef_Pragmas
+ 1;
593 if SFR
.Num_SRef_Pragmas
= 1 then
594 SFR
.First_Mapped_Line
:= Logical_Line_Number
(Mapped_Line
);
597 if SFR
.Logical_Lines_Table
= null then
598 SFR
.Logical_Lines_Table
:= To_Pointer
600 (size_t
(SFR
.Lines_Table_Max
*
601 Logical_Lines_Table_Type
'Component_Size /
605 SFR
.Logical_Lines_Table
(Line_After_Pragma
- 1) := No_Line_Number
;
607 ML
:= Logical_Line_Number
(Mapped_Line
);
608 for J
in Line_After_Pragma
.. SFR
.Last_Source_Line
loop
609 SFR
.Logical_Lines_Table
(J
) := ML
;
612 end Register_Source_Ref_Pragma
;
614 ---------------------------------
615 -- Set_Source_File_Index_Table --
616 ---------------------------------
618 procedure Set_Source_File_Index_Table
(Xnew
: Source_File_Index
) is
621 SL
: constant Source_Ptr
:= Source_File
.Table
(Xnew
).Source_Last
;
624 SP
:= (Source_File
.Table
(Xnew
).Source_First
+ Chunk_Size
- 1)
625 / Chunk_Size
* Chunk_Size
;
626 Ind
:= Int
(SP
) / Chunk_Size
;
629 Source_File_Index_Table
(Ind
) := Xnew
;
630 SP
:= SP
+ Chunk_Size
;
633 end Set_Source_File_Index_Table
;
635 ---------------------------
636 -- Skip_Line_Terminators --
637 ---------------------------
639 procedure Skip_Line_Terminators
640 (P
: in out Source_Ptr
;
641 Physical
: out Boolean)
643 Chr
: constant Character := Source
(P
);
647 if Source
(P
+ 1) = LF
then
656 elsif Chr
= FF
or else Chr
= VT
then
661 -- Otherwise we have a wide character
664 Skip_Wide
(Source
, P
);
667 -- Fall through in the physical line terminator case. First deal with
668 -- making a possible entry into the lines table if one is needed.
670 -- Note: we are dealing with a real source file here, this cannot be
671 -- the instantiation case, so we need not worry about Sloc adjustment.
674 S
: Source_File_Record
675 renames Source_File
.Table
(Current_Source_File
);
680 -- Make entry in lines table if not already made (in some scan backup
681 -- cases, we will be rescanning previously scanned source, so the
682 -- entry may have already been made on the previous forward scan).
685 and then P
> S
.Lines_Table
(S
.Last_Source_Line
)
687 Add_Line_Tables_Entry
(S
, P
);
690 end Skip_Line_Terminators
;
696 procedure Sloc_Range
(N
: Node_Id
; Min
, Max
: out Source_Ptr
) is
698 function Process
(N
: Node_Id
) return Traverse_Result
;
699 -- Process function for traversing the node tree
701 procedure Traverse
is new Traverse_Proc
(Process
);
707 function Process
(N
: Node_Id
) return Traverse_Result
is
709 if Sloc
(N
) < Min
then
710 if Sloc
(N
) > No_Location
then
713 elsif Sloc
(N
) > Max
then
714 if Sloc
(N
) > No_Location
then
722 -- Start of processing for Sloc_Range
734 function Source_Offset
(S
: Source_Ptr
) return Nat
is
735 Sindex
: constant Source_File_Index
:= Get_Source_File_Index
(S
);
736 Sfirst
: constant Source_Ptr
:=
737 Source_File
.Table
(Sindex
).Source_First
;
739 return Nat
(S
- Sfirst
);
742 ------------------------
743 -- Top_Level_Location --
744 ------------------------
746 function Top_Level_Location
(S
: Source_Ptr
) return Source_Ptr
is
754 Newloc
:= Instantiation_Location
(Oldloc
);
755 exit when Newloc
= No_Location
;
759 end Top_Level_Location
;
765 procedure Tree_Read
is
767 -- First we must free any old source buffer pointers
769 if not First_Time_Around
then
770 for J
in Source_File
.First
.. Source_File
.Last
loop
772 S
: Source_File_Record
renames Source_File
.Table
(J
);
774 procedure Free_Ptr
is new Unchecked_Deallocation
775 (Big_Source_Buffer
, Source_Buffer_Ptr
);
777 pragma Warnings
(Off
);
778 -- This unchecked conversion is aliasing safe, since it is not
779 -- used to create improperly aliased pointer values.
781 function To_Source_Buffer_Ptr
is new
782 Unchecked_Conversion
(Address
, Source_Buffer_Ptr
);
784 pragma Warnings
(On
);
786 Tmp1
: Source_Buffer_Ptr
;
789 if S
.Instantiation
/= No_Location
then
793 -- Free the buffer, we use Free here, because we used malloc
794 -- or realloc directly to allocate the tables. That is
795 -- because we were playing the big array trick. We need to
796 -- suppress the warning for freeing from an empty pool!
798 -- We have to recreate a proper pointer to the actual array
799 -- from the zero origin pointer stored in the source table.
803 (S
.Source_Text
(S
.Source_First
)'Address);
804 pragma Warnings
(Off
);
806 pragma Warnings
(On
);
808 if S
.Lines_Table
/= null then
809 Memory
.Free
(To_Address
(S
.Lines_Table
));
810 S
.Lines_Table
:= null;
813 if S
.Logical_Lines_Table
/= null then
814 Memory
.Free
(To_Address
(S
.Logical_Lines_Table
));
815 S
.Logical_Lines_Table
:= null;
822 -- Reset source cache pointers to force new read
824 Source_Cache_First
:= 1;
825 Source_Cache_Last
:= 0;
827 -- Read in source file table
829 Source_File
.Tree_Read
;
831 -- The pointers we read in there for the source buffer and lines
832 -- table pointers are junk. We now read in the actual data that
833 -- is referenced by these two fields.
835 for J
in Source_File
.First
.. Source_File
.Last
loop
837 S
: Source_File_Record
renames Source_File
.Table
(J
);
840 -- For the instantiation case, we do not read in any data. Instead
841 -- we share the data for the generic template entry. Since the
842 -- template always occurs first, we can safely refer to its data.
844 if S
.Instantiation
/= No_Location
then
846 ST
: Source_File_Record
renames
847 Source_File
.Table
(S
.Template
);
850 -- The lines tables are copied from the template entry
853 Source_File
.Table
(S
.Template
).Lines_Table
;
854 S
.Logical_Lines_Table
:=
855 Source_File
.Table
(S
.Template
).Logical_Lines_Table
;
857 -- In the case of the source table pointer, we share the
858 -- same data as the generic template, but the virtual origin
859 -- is adjusted. For example, if the first subscript of the
860 -- template is 100, and that of the instantiation is 200,
861 -- then the instantiation pointer is obtained by subtracting
862 -- 100 from the template pointer.
865 pragma Suppress
(All_Checks
);
867 pragma Warnings
(Off
);
868 -- This unchecked conversion is aliasing safe since it
869 -- not used to create improperly aliased pointer values.
871 function To_Source_Buffer_Ptr
is new
872 Unchecked_Conversion
(Address
, Source_Buffer_Ptr
);
874 pragma Warnings
(On
);
880 (ST
.Source_First
- S
.Source_First
)'Address);
884 -- Normal case (non-instantiation)
887 First_Time_Around
:= False;
888 S
.Lines_Table
:= null;
889 S
.Logical_Lines_Table
:= null;
890 Alloc_Line_Tables
(S
, Int
(S
.Last_Source_Line
));
892 for J
in 1 .. S
.Last_Source_Line
loop
893 Tree_Read_Int
(Int
(S
.Lines_Table
(J
)));
896 if S
.Num_SRef_Pragmas
/= 0 then
897 for J
in 1 .. S
.Last_Source_Line
loop
898 Tree_Read_Int
(Int
(S
.Logical_Lines_Table
(J
)));
902 -- Allocate source buffer and read in the data and then set the
903 -- virtual origin to point to the logical zero'th element. This
904 -- address must be computed with subscript checks turned off.
907 subtype B
is Text_Buffer
(S
.Source_First
.. S
.Source_Last
);
908 type Text_Buffer_Ptr
is access B
;
911 pragma Suppress
(All_Checks
);
913 pragma Warnings
(Off
);
914 -- This unchecked conversion is aliasing safe, since it is
915 -- never used to create improperly aliased pointer values.
917 function To_Source_Buffer_Ptr
is new
918 Unchecked_Conversion
(Address
, Source_Buffer_Ptr
);
920 pragma Warnings
(On
);
925 Tree_Read_Data
(T
(S
.Source_First
)'Address,
926 Int
(S
.Source_Last
) - Int
(S
.Source_First
) + 1);
928 S
.Source_Text
:= To_Source_Buffer_Ptr
(T
(0)'Address);
933 Set_Source_File_Index_Table
(J
);
941 procedure Tree_Write
is
943 Source_File
.Tree_Write
;
945 -- The pointers we wrote out there for the source buffer and lines
946 -- table pointers are junk, we now write out the actual data that
947 -- is referenced by these two fields.
949 for J
in Source_File
.First
.. Source_File
.Last
loop
951 S
: Source_File_Record
renames Source_File
.Table
(J
);
954 -- For instantiations, there is nothing to do, since the data is
955 -- shared with the generic template. When the tree is read, the
956 -- pointers must be set, but no extra data needs to be written.
958 if S
.Instantiation
/= No_Location
then
961 -- For the normal case, write out the data of the tables
966 for J
in 1 .. S
.Last_Source_Line
loop
967 Tree_Write_Int
(Int
(S
.Lines_Table
(J
)));
970 -- Logical lines table if present
972 if S
.Num_SRef_Pragmas
/= 0 then
973 for J
in 1 .. S
.Last_Source_Line
loop
974 Tree_Write_Int
(Int
(S
.Logical_Lines_Table
(J
)));
981 (S
.Source_Text
(S
.Source_First
)'Address,
982 Int
(S
.Source_Last
) - Int
(S
.Source_First
) + 1);
992 procedure Write_Location
(P
: Source_Ptr
) is
994 if P
= No_Location
then
995 Write_Str
("<no location>");
997 elsif P
<= Standard_Location
then
998 Write_Str
("<standard location>");
1002 SI
: constant Source_File_Index
:= Get_Source_File_Index
(P
);
1005 Write_Name
(Debug_Source_Name
(SI
));
1007 Write_Int
(Int
(Get_Logical_Line_Number
(P
)));
1009 Write_Int
(Int
(Get_Column_Number
(P
)));
1011 if Instantiation
(SI
) /= No_Location
then
1013 Write_Location
(Instantiation
(SI
));
1020 ----------------------
1021 -- Write_Time_Stamp --
1022 ----------------------
1024 procedure Write_Time_Stamp
(S
: Source_File_Index
) is
1025 T
: constant Time_Stamp_Type
:= Time_Stamp
(S
);
1038 Write_Char
(T
(P
+ 1));
1039 Write_Char
(T
(P
+ 2));
1042 Write_Char
(T
(P
+ 3));
1043 Write_Char
(T
(P
+ 4));
1046 Write_Char
(T
(P
+ 5));
1047 Write_Char
(T
(P
+ 6));
1050 Write_Char
(T
(P
+ 7));
1051 Write_Char
(T
(P
+ 8));
1054 Write_Char
(T
(P
+ 9));
1055 Write_Char
(T
(P
+ 10));
1058 Write_Char
(T
(P
+ 11));
1059 Write_Char
(T
(P
+ 12));
1060 end Write_Time_Stamp
;
1062 ----------------------------------------------
1063 -- Access Subprograms for Source File Table --
1064 ----------------------------------------------
1066 function Debug_Source_Name
(S
: SFI
) return File_Name_Type
is
1068 return Source_File
.Table
(S
).Debug_Source_Name
;
1069 end Debug_Source_Name
;
1071 function File_Name
(S
: SFI
) return File_Name_Type
is
1073 return Source_File
.Table
(S
).File_Name
;
1076 function File_Type
(S
: SFI
) return Type_Of_File
is
1078 return Source_File
.Table
(S
).File_Type
;
1081 function First_Mapped_Line
(S
: SFI
) return Logical_Line_Number
is
1083 return Source_File
.Table
(S
).First_Mapped_Line
;
1084 end First_Mapped_Line
;
1086 function Full_Debug_Name
(S
: SFI
) return File_Name_Type
is
1088 return Source_File
.Table
(S
).Full_Debug_Name
;
1089 end Full_Debug_Name
;
1091 function Full_File_Name
(S
: SFI
) return File_Name_Type
is
1093 return Source_File
.Table
(S
).Full_File_Name
;
1096 function Full_Ref_Name
(S
: SFI
) return File_Name_Type
is
1098 return Source_File
.Table
(S
).Full_Ref_Name
;
1101 function Identifier_Casing
(S
: SFI
) return Casing_Type
is
1103 return Source_File
.Table
(S
).Identifier_Casing
;
1104 end Identifier_Casing
;
1106 function Inlined_Body
(S
: SFI
) return Boolean is
1108 return Source_File
.Table
(S
).Inlined_Body
;
1111 function Instantiation
(S
: SFI
) return Source_Ptr
is
1113 return Source_File
.Table
(S
).Instantiation
;
1116 function Keyword_Casing
(S
: SFI
) return Casing_Type
is
1118 return Source_File
.Table
(S
).Keyword_Casing
;
1121 function Last_Source_Line
(S
: SFI
) return Physical_Line_Number
is
1123 return Source_File
.Table
(S
).Last_Source_Line
;
1124 end Last_Source_Line
;
1126 function License
(S
: SFI
) return License_Type
is
1128 return Source_File
.Table
(S
).License
;
1131 function Num_SRef_Pragmas
(S
: SFI
) return Nat
is
1133 return Source_File
.Table
(S
).Num_SRef_Pragmas
;
1134 end Num_SRef_Pragmas
;
1136 function Reference_Name
(S
: SFI
) return File_Name_Type
is
1138 return Source_File
.Table
(S
).Reference_Name
;
1141 function Source_Checksum
(S
: SFI
) return Word
is
1143 return Source_File
.Table
(S
).Source_Checksum
;
1144 end Source_Checksum
;
1146 function Source_First
(S
: SFI
) return Source_Ptr
is
1148 if S
= Internal_Source_File
then
1149 return Internal_Source
'First;
1151 return Source_File
.Table
(S
).Source_First
;
1155 function Source_Last
(S
: SFI
) return Source_Ptr
is
1157 if S
= Internal_Source_File
then
1158 return Internal_Source
'Last;
1160 return Source_File
.Table
(S
).Source_Last
;
1164 function Source_Text
(S
: SFI
) return Source_Buffer_Ptr
is
1166 if S
= Internal_Source_File
then
1167 return Internal_Source_Ptr
;
1169 return Source_File
.Table
(S
).Source_Text
;
1173 function Template
(S
: SFI
) return SFI
is
1175 return Source_File
.Table
(S
).Template
;
1178 function Time_Stamp
(S
: SFI
) return Time_Stamp_Type
is
1180 return Source_File
.Table
(S
).Time_Stamp
;
1183 function Unit
(S
: SFI
) return Unit_Number_Type
is
1185 return Source_File
.Table
(S
).Unit
;
1188 ------------------------------------------
1189 -- Set Procedures for Source File Table --
1190 ------------------------------------------
1192 procedure Set_Identifier_Casing
(S
: SFI
; C
: Casing_Type
) is
1194 Source_File
.Table
(S
).Identifier_Casing
:= C
;
1195 end Set_Identifier_Casing
;
1197 procedure Set_Keyword_Casing
(S
: SFI
; C
: Casing_Type
) is
1199 Source_File
.Table
(S
).Keyword_Casing
:= C
;
1200 end Set_Keyword_Casing
;
1202 procedure Set_License
(S
: SFI
; L
: License_Type
) is
1204 Source_File
.Table
(S
).License
:= L
;
1207 procedure Set_Unit
(S
: SFI
; U
: Unit_Number_Type
) is
1209 Source_File
.Table
(S
).Unit
:= U
;
1212 ----------------------
1213 -- Trim_Lines_Table --
1214 ----------------------
1216 procedure Trim_Lines_Table
(S
: Source_File_Index
) is
1217 Max
: constant Nat
:= Nat
(Source_File
.Table
(S
).Last_Source_Line
);
1220 -- Release allocated storage that is no longer needed
1222 Source_File
.Table
(S
).Lines_Table
:= To_Pointer
1224 (To_Address
(Source_File
.Table
(S
).Lines_Table
),
1226 (Max
* (Lines_Table_Type
'Component_Size / System
.Storage_Unit
))));
1227 Source_File
.Table
(S
).Lines_Table_Max
:= Physical_Line_Number
(Max
);
1228 end Trim_Lines_Table
;
1236 Source_File
.Locked
:= False;
1237 Source_File
.Release
;
1244 procedure wl
(P
: Source_Ptr
) is