1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, 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 (Nat (Get_Logical_Line_Number (Ptr)));
232 Ptr := Instantiation_Location (Ptr);
233 exit when Ptr = No_Location;
234 Add_Str_To_Name_Buffer (" instantiated at ");
237 Name_Buffer (Name_Len + 1) := NUL;
239 end Build_Location_String;
241 function Build_Location_String (Loc : Source_Ptr) return String is
244 Build_Location_String (Loc);
245 return Name_Buffer (1 .. Name_Len);
246 end Build_Location_String;
248 -----------------------
249 -- Get_Column_Number --
250 -----------------------
252 function Get_Column_Number (P : Source_Ptr) return Column_Number is
255 Sindex : Source_File_Index;
256 Src : Source_Buffer_Ptr;
259 -- If the input source pointer is not a meaningful value then return
260 -- at once with column number 1. This can happen for a file not found
261 -- condition for a file loaded indirectly by RTE, and also perhaps on
262 -- some unknown internal error conditions. In either case we certainly
263 -- don't want to blow up.
269 Sindex := Get_Source_File_Index (P);
270 Src := Source_File.Table (Sindex).Source_Text;
276 C := (C - 1) / 8 * 8 + (8 + 1);
286 end Get_Column_Number;
288 -----------------------------
289 -- Get_Logical_Line_Number --
290 -----------------------------
292 function Get_Logical_Line_Number
293 (P : Source_Ptr) return Logical_Line_Number
295 SFR : Source_File_Record
296 renames Source_File.Table (Get_Source_File_Index (P));
298 L : constant Physical_Line_Number := Get_Physical_Line_Number (P);
301 if SFR.Num_SRef_Pragmas = 0 then
302 return Logical_Line_Number (L);
304 return SFR.Logical_Lines_Table (L);
306 end Get_Logical_Line_Number;
308 ---------------------------------
309 -- Get_Logical_Line_Number_Img --
310 ---------------------------------
312 function Get_Logical_Line_Number_Img
313 (P : Source_Ptr) return String
317 Add_Nat_To_Name_Buffer (Nat (Get_Logical_Line_Number (P)));
318 return Name_Buffer (1 .. Name_Len);
319 end Get_Logical_Line_Number_Img;
321 ------------------------------
322 -- Get_Physical_Line_Number --
323 ------------------------------
325 function Get_Physical_Line_Number
326 (P : Source_Ptr) return Physical_Line_Number
328 Sfile : Source_File_Index;
329 Table : Lines_Table_Ptr;
330 Lo : Physical_Line_Number;
331 Hi : Physical_Line_Number;
332 Mid : Physical_Line_Number;
336 -- If the input source pointer is not a meaningful value then return
337 -- at once with line number 1. This can happen for a file not found
338 -- condition for a file loaded indirectly by RTE, and also perhaps on
339 -- some unknown internal error conditions. In either case we certainly
340 -- don't want to blow up.
345 -- Otherwise we can do the binary search
348 Sfile := Get_Source_File_Index (P);
349 Loc := P + Source_File.Table (Sfile).Sloc_Adjust;
350 Table := Source_File.Table (Sfile).Lines_Table;
352 Hi := Source_File.Table (Sfile).Last_Source_Line;
355 Mid := (Lo + Hi) / 2;
357 if Loc < Table (Mid) then
360 else -- Loc >= Table (Mid)
363 Loc < Table (Mid + 1)
374 end Get_Physical_Line_Number;
376 ---------------------------
377 -- Get_Source_File_Index --
378 ---------------------------
380 Source_Cache_First : Source_Ptr := 1;
381 Source_Cache_Last : Source_Ptr := 0;
382 -- Records the First and Last subscript values for the most recently
383 -- referenced entry in the source table, to optimize the common case of
384 -- repeated references to the same entry. The initial values force an
385 -- initial search to set the cache value.
387 Source_Cache_Index : Source_File_Index := No_Source_File;
388 -- Contains the index of the entry corresponding to Source_Cache
390 function Get_Source_File_Index (S : Source_Ptr) return Source_File_Index is
392 if S in Source_Cache_First .. Source_Cache_Last then
393 return Source_Cache_Index;
396 pragma Assert (Source_File_Index_Table (Int (S) / Chunk_Size)
399 for J in Source_File_Index_Table (Int (S) / Chunk_Size)
402 if S in Source_File.Table (J).Source_First ..
403 Source_File.Table (J).Source_Last
405 Source_Cache_Index := J;
406 Source_Cache_First :=
407 Source_File.Table (Source_Cache_Index).Source_First;
409 Source_File.Table (Source_Cache_Index).Source_Last;
410 return Source_Cache_Index;
415 -- We must find a matching entry in the above loop!
418 end Get_Source_File_Index;
424 procedure Initialize is
426 Source_Cache_First := 1;
427 Source_Cache_Last := 0;
428 Source_Cache_Index := No_Source_File;
429 Source_gnat_adc := No_Source_File;
430 First_Time_Around := True;
435 -------------------------
436 -- Instantiation_Depth --
437 -------------------------
439 function Instantiation_Depth (S : Source_Ptr) return Nat is
440 Sind : Source_File_Index;
449 Sind := Get_Source_File_Index (Sval);
450 Sval := Instantiation (Sind);
451 exit when Sval = No_Location;
456 end Instantiation_Depth;
458 ----------------------------
459 -- Instantiation_Location --
460 ----------------------------
462 function Instantiation_Location (S : Source_Ptr) return Source_Ptr is
464 return Instantiation (Get_Source_File_Index (S));
465 end Instantiation_Location;
467 ----------------------
468 -- Last_Source_File --
469 ----------------------
471 function Last_Source_File return Source_File_Index is
473 return Source_File.Last;
474 end Last_Source_File;
480 function Line_Start (P : Source_Ptr) return Source_Ptr is
481 Sindex : constant Source_File_Index := Get_Source_File_Index (P);
482 Src : constant Source_Buffer_Ptr :=
483 Source_File.Table (Sindex).Source_Text;
484 Sfirst : constant Source_Ptr :=
485 Source_File.Table (Sindex).Source_First;
491 and then Src (S - 1) /= CR
492 and then Src (S - 1) /= LF
501 (L : Physical_Line_Number;
502 S : Source_File_Index) return Source_Ptr
505 return Source_File.Table (S).Lines_Table (L);
514 Source_File.Locked := True;
518 ----------------------
519 -- Num_Source_Files --
520 ----------------------
522 function Num_Source_Files return Nat is
524 return Int (Source_File.Last) - Int (Source_File.First) + 1;
525 end Num_Source_Files;
527 ----------------------
528 -- Num_Source_Lines --
529 ----------------------
531 function Num_Source_Lines (S : Source_File_Index) return Nat is
533 return Nat (Source_File.Table (S).Last_Source_Line);
534 end Num_Source_Lines;
536 -----------------------
537 -- Original_Location --
538 -----------------------
540 function Original_Location (S : Source_Ptr) return Source_Ptr is
541 Sindex : Source_File_Index;
542 Tindex : Source_File_Index;
545 if S <= No_Location then
549 Sindex := Get_Source_File_Index (S);
551 if Instantiation (Sindex) = No_Location then
555 Tindex := Template (Sindex);
556 while Instantiation (Tindex) /= No_Location loop
557 Tindex := Template (Tindex);
560 return S - Source_First (Sindex) + Source_First (Tindex);
563 end Original_Location;
565 -------------------------
566 -- Physical_To_Logical --
567 -------------------------
569 function Physical_To_Logical
570 (Line : Physical_Line_Number;
571 S : Source_File_Index) return Logical_Line_Number
573 SFR : Source_File_Record renames Source_File.Table (S);
576 if SFR.Num_SRef_Pragmas = 0 then
577 return Logical_Line_Number (Line);
579 return SFR.Logical_Lines_Table (Line);
581 end Physical_To_Logical;
583 --------------------------------
584 -- Register_Source_Ref_Pragma --
585 --------------------------------
587 procedure Register_Source_Ref_Pragma
588 (File_Name : File_Name_Type;
589 Stripped_File_Name : File_Name_Type;
591 Line_After_Pragma : Physical_Line_Number)
593 subtype size_t is Memory.size_t;
595 SFR : Source_File_Record renames Source_File.Table (Current_Source_File);
597 ML : Logical_Line_Number;
600 if File_Name /= No_File then
601 SFR.Reference_Name := Stripped_File_Name;
602 SFR.Full_Ref_Name := File_Name;
604 if not Debug_Generated_Code then
605 SFR.Debug_Source_Name := Stripped_File_Name;
606 SFR.Full_Debug_Name := File_Name;
609 SFR.Num_SRef_Pragmas := SFR.Num_SRef_Pragmas + 1;
612 if SFR.Num_SRef_Pragmas = 1 then
613 SFR.First_Mapped_Line := Logical_Line_Number (Mapped_Line);
616 if SFR.Logical_Lines_Table = null then
617 SFR.Logical_Lines_Table := To_Pointer
619 (size_t (SFR.Lines_Table_Max *
620 Logical_Lines_Table_Type'Component_Size /
624 SFR.Logical_Lines_Table (Line_After_Pragma - 1) := No_Line_Number;
626 ML := Logical_Line_Number (Mapped_Line);
627 for J in Line_After_Pragma .. SFR.Last_Source_Line loop
628 SFR.Logical_Lines_Table (J) := ML;
631 end Register_Source_Ref_Pragma;
633 ---------------------------------
634 -- Set_Source_File_Index_Table --
635 ---------------------------------
637 procedure Set_Source_File_Index_Table (Xnew : Source_File_Index) is
640 SL : constant Source_Ptr := Source_File.Table (Xnew).Source_Last;
643 SP := (Source_File.Table (Xnew).Source_First + Chunk_Size - 1)
644 / Chunk_Size * Chunk_Size;
645 Ind := Int (SP) / Chunk_Size;
648 Source_File_Index_Table (Ind) := Xnew;
649 SP := SP + Chunk_Size;
652 end Set_Source_File_Index_Table;
654 ---------------------------
655 -- Skip_Line_Terminators --
656 ---------------------------
658 procedure Skip_Line_Terminators
659 (P : in out Source_Ptr;
660 Physical : out Boolean)
662 Chr : constant Character := Source (P);
666 if Source (P + 1) = LF then
675 elsif Chr = FF or else Chr = VT then
680 -- Otherwise we have a wide character
683 Skip_Wide (Source, P);
686 -- Fall through in the physical line terminator case. First deal with
687 -- making a possible entry into the lines table if one is needed.
689 -- Note: we are dealing with a real source file here, this cannot be
690 -- the instantiation case, so we need not worry about Sloc adjustment.
693 S : Source_File_Record
694 renames Source_File.Table (Current_Source_File);
699 -- Make entry in lines table if not already made (in some scan backup
700 -- cases, we will be rescanning previously scanned source, so the
701 -- entry may have already been made on the previous forward scan).
704 and then P > S.Lines_Table (S.Last_Source_Line)
706 Add_Line_Tables_Entry (S, P);
709 end Skip_Line_Terminators;
715 procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is
717 function Process (N : Node_Id) return Traverse_Result;
718 -- Process function for traversing the node tree
720 procedure Traverse is new Traverse_Proc (Process);
726 function Process (N : Node_Id) return Traverse_Result is
728 if Sloc (N) < Min then
729 if Sloc (N) > No_Location then
732 elsif Sloc (N) > Max then
733 if Sloc (N) > No_Location then
741 -- Start of processing for Sloc_Range
753 function Source_Offset (S : Source_Ptr) return Nat is
754 Sindex : constant Source_File_Index := Get_Source_File_Index (S);
755 Sfirst : constant Source_Ptr :=
756 Source_File.Table (Sindex).Source_First;
758 return Nat (S - Sfirst);
761 ------------------------
762 -- Top_Level_Location --
763 ------------------------
765 function Top_Level_Location (S : Source_Ptr) return Source_Ptr is
773 Newloc := Instantiation_Location (Oldloc);
774 exit when Newloc = No_Location;
778 end Top_Level_Location;
784 procedure Tree_Read is
786 -- First we must free any old source buffer pointers
788 if not First_Time_Around then
789 for J in Source_File.First .. Source_File.Last loop
791 S : Source_File_Record renames Source_File.Table (J);
793 procedure Free_Ptr is new Unchecked_Deallocation
794 (Big_Source_Buffer, Source_Buffer_Ptr);
796 pragma Warnings (Off);
797 -- This unchecked conversion is aliasing safe, since it is not
798 -- used to create improperly aliased pointer values.
800 function To_Source_Buffer_Ptr is new
801 Unchecked_Conversion (Address, Source_Buffer_Ptr);
803 pragma Warnings (On);
805 Tmp1 : Source_Buffer_Ptr;
808 if S.Instantiation /= No_Location then
812 -- Free the buffer, we use Free here, because we used malloc
813 -- or realloc directly to allocate the tables. That is
814 -- because we were playing the big array trick.
816 -- We have to recreate a proper pointer to the actual array
817 -- from the zero origin pointer stored in the source table.
821 (S.Source_Text (S.Source_First)'Address);
824 if S.Lines_Table /= null then
825 Memory.Free (To_Address (S.Lines_Table));
826 S.Lines_Table := null;
829 if S.Logical_Lines_Table /= null then
830 Memory.Free (To_Address (S.Logical_Lines_Table));
831 S.Logical_Lines_Table := null;
838 -- Reset source cache pointers to force new read
840 Source_Cache_First := 1;
841 Source_Cache_Last := 0;
843 -- Read in source file table
845 Source_File.Tree_Read;
847 -- The pointers we read in there for the source buffer and lines
848 -- table pointers are junk. We now read in the actual data that
849 -- is referenced by these two fields.
851 for J in Source_File.First .. Source_File.Last loop
853 S : Source_File_Record renames Source_File.Table (J);
856 -- For the instantiation case, we do not read in any data. Instead
857 -- we share the data for the generic template entry. Since the
858 -- template always occurs first, we can safely refer to its data.
860 if S.Instantiation /= No_Location then
862 ST : Source_File_Record renames
863 Source_File.Table (S.Template);
866 -- The lines tables are copied from the template entry
869 Source_File.Table (S.Template).Lines_Table;
870 S.Logical_Lines_Table :=
871 Source_File.Table (S.Template).Logical_Lines_Table;
873 -- In the case of the source table pointer, we share the
874 -- same data as the generic template, but the virtual origin
875 -- is adjusted. For example, if the first subscript of the
876 -- template is 100, and that of the instantiation is 200,
877 -- then the instantiation pointer is obtained by subtracting
878 -- 100 from the template pointer.
881 pragma Suppress (All_Checks);
883 pragma Warnings (Off);
884 -- This unchecked conversion is aliasing safe since it
885 -- not used to create improperly aliased pointer values.
887 function To_Source_Buffer_Ptr is new
888 Unchecked_Conversion (Address, Source_Buffer_Ptr);
890 pragma Warnings (On);
896 (ST.Source_First - S.Source_First)'Address);
900 -- Normal case (non-instantiation)
903 First_Time_Around := False;
904 S.Lines_Table := null;
905 S.Logical_Lines_Table := null;
906 Alloc_Line_Tables (S, Int (S.Last_Source_Line));
908 for J in 1 .. S.Last_Source_Line loop
909 Tree_Read_Int (Int (S.Lines_Table (J)));
912 if S.Num_SRef_Pragmas /= 0 then
913 for J in 1 .. S.Last_Source_Line loop
914 Tree_Read_Int (Int (S.Logical_Lines_Table (J)));
918 -- Allocate source buffer and read in the data and then set the
919 -- virtual origin to point to the logical zero'th element. This
920 -- address must be computed with subscript checks turned off.
923 subtype B is Text_Buffer (S.Source_First .. S.Source_Last);
924 type Text_Buffer_Ptr is access B;
927 pragma Suppress (All_Checks);
929 pragma Warnings (Off);
930 -- This unchecked conversion is aliasing safe, since it is
931 -- never used to create improperly aliased pointer values.
933 function To_Source_Buffer_Ptr is new
934 Unchecked_Conversion (Address, Source_Buffer_Ptr);
936 pragma Warnings (On);
941 Tree_Read_Data (T (S.Source_First)'Address,
942 Int (S.Source_Last) - Int (S.Source_First) + 1);
944 S.Source_Text := To_Source_Buffer_Ptr (T (0)'Address);
949 Set_Source_File_Index_Table (J);
957 procedure Tree_Write is
959 Source_File.Tree_Write;
961 -- The pointers we wrote out there for the source buffer and lines
962 -- table pointers are junk, we now write out the actual data that
963 -- is referenced by these two fields.
965 for J in Source_File.First .. Source_File.Last loop
967 S : Source_File_Record renames Source_File.Table (J);
970 -- For instantiations, there is nothing to do, since the data is
971 -- shared with the generic template. When the tree is read, the
972 -- pointers must be set, but no extra data needs to be written.
974 if S.Instantiation /= No_Location then
977 -- For the normal case, write out the data of the tables
982 for J in 1 .. S.Last_Source_Line loop
983 Tree_Write_Int (Int (S.Lines_Table (J)));
986 -- Logical lines table if present
988 if S.Num_SRef_Pragmas /= 0 then
989 for J in 1 .. S.Last_Source_Line loop
990 Tree_Write_Int (Int (S.Logical_Lines_Table (J)));
997 (S.Source_Text (S.Source_First)'Address,
998 Int (S.Source_Last) - Int (S.Source_First) + 1);
1004 --------------------
1005 -- Write_Location --
1006 --------------------
1008 procedure Write_Location (P : Source_Ptr) is
1010 if P = No_Location then
1011 Write_Str ("<no location>");
1013 elsif P <= Standard_Location then
1014 Write_Str ("<standard location>");
1018 SI : constant Source_File_Index := Get_Source_File_Index (P);
1021 Write_Name (Debug_Source_Name (SI));
1023 Write_Int (Int (Get_Logical_Line_Number (P)));
1025 Write_Int (Int (Get_Column_Number (P)));
1027 if Instantiation (SI) /= No_Location then
1029 Write_Location (Instantiation (SI));
1036 ----------------------
1037 -- Write_Time_Stamp --
1038 ----------------------
1040 procedure Write_Time_Stamp (S : Source_File_Index) is
1041 T : constant Time_Stamp_Type := Time_Stamp (S);
1054 Write_Char (T (P + 1));
1055 Write_Char (T (P + 2));
1058 Write_Char (T (P + 3));
1059 Write_Char (T (P + 4));
1062 Write_Char (T (P + 5));
1063 Write_Char (T (P + 6));
1066 Write_Char (T (P + 7));
1067 Write_Char (T (P + 8));
1070 Write_Char (T (P + 9));
1071 Write_Char (T (P + 10));
1074 Write_Char (T (P + 11));
1075 Write_Char (T (P + 12));
1076 end Write_Time_Stamp;
1078 ----------------------------------------------
1079 -- Access Subprograms for Source File Table --
1080 ----------------------------------------------
1082 function Debug_Source_Name (S : SFI) return File_Name_Type is
1084 return Source_File.Table (S).Debug_Source_Name;
1085 end Debug_Source_Name;
1087 function File_Name (S : SFI) return File_Name_Type is
1089 return Source_File.Table (S).File_Name;
1092 function File_Type (S : SFI) return Type_Of_File is
1094 return Source_File.Table (S).File_Type;
1097 function First_Mapped_Line (S : SFI) return Logical_Line_Number is
1099 return Source_File.Table (S).First_Mapped_Line;
1100 end First_Mapped_Line;
1102 function Full_Debug_Name (S : SFI) return File_Name_Type is
1104 return Source_File.Table (S).Full_Debug_Name;
1105 end Full_Debug_Name;
1107 function Full_File_Name (S : SFI) return File_Name_Type is
1109 return Source_File.Table (S).Full_File_Name;
1112 function Full_Ref_Name (S : SFI) return File_Name_Type is
1114 return Source_File.Table (S).Full_Ref_Name;
1117 function Identifier_Casing (S : SFI) return Casing_Type is
1119 return Source_File.Table (S).Identifier_Casing;
1120 end Identifier_Casing;
1122 function Inlined_Body (S : SFI) return Boolean is
1124 return Source_File.Table (S).Inlined_Body;
1127 function Instantiation (S : SFI) return Source_Ptr is
1129 return Source_File.Table (S).Instantiation;
1132 function Keyword_Casing (S : SFI) return Casing_Type is
1134 return Source_File.Table (S).Keyword_Casing;
1137 function Last_Source_Line (S : SFI) return Physical_Line_Number is
1139 return Source_File.Table (S).Last_Source_Line;
1140 end Last_Source_Line;
1142 function License (S : SFI) return License_Type is
1144 return Source_File.Table (S).License;
1147 function Num_SRef_Pragmas (S : SFI) return Nat is
1149 return Source_File.Table (S).Num_SRef_Pragmas;
1150 end Num_SRef_Pragmas;
1152 function Reference_Name (S : SFI) return File_Name_Type is
1154 return Source_File.Table (S).Reference_Name;
1157 function Source_Checksum (S : SFI) return Word is
1159 return Source_File.Table (S).Source_Checksum;
1160 end Source_Checksum;
1162 function Source_First (S : SFI) return Source_Ptr is
1164 if S = Internal_Source_File then
1165 return Internal_Source'First;
1167 return Source_File.Table (S).Source_First;
1171 function Source_Last (S : SFI) return Source_Ptr is
1173 if S = Internal_Source_File then
1174 return Internal_Source'Last;
1176 return Source_File.Table (S).Source_Last;
1180 function Source_Text (S : SFI) return Source_Buffer_Ptr is
1182 if S = Internal_Source_File then
1183 return Internal_Source_Ptr;
1185 return Source_File.Table (S).Source_Text;
1189 function Template (S : SFI) return SFI is
1191 return Source_File.Table (S).Template;
1194 function Time_Stamp (S : SFI) return Time_Stamp_Type is
1196 return Source_File.Table (S).Time_Stamp;
1199 function Unit (S : SFI) return Unit_Number_Type is
1201 return Source_File.Table (S).Unit;
1204 ------------------------------------------
1205 -- Set Procedures for Source File Table --
1206 ------------------------------------------
1208 procedure Set_Identifier_Casing (S : SFI; C : Casing_Type) is
1210 Source_File.Table (S).Identifier_Casing := C;
1211 end Set_Identifier_Casing;
1213 procedure Set_Keyword_Casing (S : SFI; C : Casing_Type) is
1215 Source_File.Table (S).Keyword_Casing := C;
1216 end Set_Keyword_Casing;
1218 procedure Set_License (S : SFI; L : License_Type) is
1220 Source_File.Table (S).License := L;
1223 procedure Set_Unit (S : SFI; U : Unit_Number_Type) is
1225 Source_File.Table (S).Unit := U;
1228 ----------------------
1229 -- Trim_Lines_Table --
1230 ----------------------
1232 procedure Trim_Lines_Table (S : Source_File_Index) is
1233 Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line);
1236 -- Release allocated storage that is no longer needed
1238 Source_File.Table (S).Lines_Table := To_Pointer
1240 (To_Address (Source_File.Table (S).Lines_Table),
1242 (Max * (Lines_Table_Type'Component_Size / System.Storage_Unit))));
1243 Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max);
1244 end Trim_Lines_Table;
1252 Source_File.Locked := False;
1253 Source_File.Release;
1260 procedure wl (P : Source_Ptr) is