1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2011, 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;
54 -- This needs a comment ???
56 -- Routines to support conversion between types Lines_Table_Ptr,
57 -- Logical_Lines_Table_Ptr and System.Address.
59 pragma Warnings (Off);
60 -- These unchecked conversions are aliasing safe, since they are never
61 -- used to construct improperly aliased pointer values.
63 function To_Address is
64 new Unchecked_Conversion (Lines_Table_Ptr, Address);
66 function To_Address is
67 new Unchecked_Conversion (Logical_Lines_Table_Ptr, Address);
69 function To_Pointer is
70 new Unchecked_Conversion (Address, Lines_Table_Ptr);
72 function To_Pointer is
73 new Unchecked_Conversion (Address, Logical_Lines_Table_Ptr);
77 ---------------------------
78 -- Add_Line_Tables_Entry --
79 ---------------------------
81 procedure Add_Line_Tables_Entry
82 (S : in out Source_File_Record;
85 LL : Physical_Line_Number;
88 -- Reallocate the lines tables if necessary
90 -- Note: the reason we do not use the normal Table package
91 -- mechanism is that we have several of these tables. We could
92 -- use the new GNAT.Dynamic_Tables package and that would probably
95 if S.Last_Source_Line = S.Lines_Table_Max then
98 Int (S.Last_Source_Line) *
99 ((100 + Alloc.Lines_Increment) / 100));
102 Write_Str ("--> Reallocating lines table, size = ");
103 Write_Int (Int (S.Lines_Table_Max));
108 S.Last_Source_Line := S.Last_Source_Line + 1;
109 LL := S.Last_Source_Line;
111 S.Lines_Table (LL) := P;
113 -- Deal with setting new entry in logical lines table if one is
114 -- present. Note that there is always space (because the call to
115 -- Alloc_Line_Tables makes sure both tables are the same length),
117 if S.Logical_Lines_Table /= null then
119 -- We can always set the entry from the previous one, because
120 -- the processing for a Source_Reference pragma ensures that
121 -- at least one entry following the pragma is set up correctly.
123 S.Logical_Lines_Table (LL) := S.Logical_Lines_Table (LL - 1) + 1;
125 end Add_Line_Tables_Entry;
127 -----------------------
128 -- Alloc_Line_Tables --
129 -----------------------
131 procedure Alloc_Line_Tables
132 (S : in out Source_File_Record;
135 subtype size_t is Memory.size_t;
137 New_Table : Lines_Table_Ptr;
139 New_Logical_Table : Logical_Lines_Table_Ptr;
141 New_Size : constant size_t :=
142 size_t (New_Max * Lines_Table_Type'Component_Size /
146 if S.Lines_Table = null then
147 New_Table := To_Pointer (Memory.Alloc (New_Size));
151 To_Pointer (Memory.Realloc (To_Address (S.Lines_Table), New_Size));
154 if New_Table = null then
157 S.Lines_Table := New_Table;
158 S.Lines_Table_Max := Physical_Line_Number (New_Max);
161 if S.Num_SRef_Pragmas /= 0 then
162 if S.Logical_Lines_Table = null then
163 New_Logical_Table := To_Pointer (Memory.Alloc (New_Size));
165 New_Logical_Table := To_Pointer
166 (Memory.Realloc (To_Address (S.Logical_Lines_Table), New_Size));
169 if New_Logical_Table = null then
172 S.Logical_Lines_Table := New_Logical_Table;
175 end Alloc_Line_Tables;
181 procedure Backup_Line (P : in out Source_Ptr) is
182 Sindex : constant Source_File_Index := Get_Source_File_Index (P);
183 Src : constant Source_Buffer_Ptr :=
184 Source_File.Table (Sindex).Source_Text;
185 Sfirst : constant Source_Ptr :=
186 Source_File.Table (Sindex).Source_First;
196 if Src (P - 1) = LF then
201 if Src (P - 1) = CR then
206 -- Now find first character of the previous line
209 and then Src (P - 1) /= LF
210 and then Src (P - 1) /= CR
216 ---------------------------
217 -- Build_Location_String --
218 ---------------------------
220 procedure Build_Location_String (Loc : Source_Ptr) is
224 -- Loop through instantiations
228 Get_Name_String_And_Append
229 (Reference_Name (Get_Source_File_Index (Ptr)));
230 Add_Char_To_Name_Buffer (':');
231 Add_Nat_To_Name_Buffer (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 function Build_Location_String (Loc : Source_Ptr) return String is
245 Build_Location_String (Loc);
246 return Name_Buffer (1 .. Name_Len);
247 end Build_Location_String;
249 -----------------------
250 -- Get_Column_Number --
251 -----------------------
253 function Get_Column_Number (P : Source_Ptr) return Column_Number is
256 Sindex : Source_File_Index;
257 Src : Source_Buffer_Ptr;
260 -- If the input source pointer is not a meaningful value then return
261 -- at once with column number 1. This can happen for a file not found
262 -- condition for a file loaded indirectly by RTE, and also perhaps on
263 -- some unknown internal error conditions. In either case we certainly
264 -- don't want to blow up.
270 Sindex := Get_Source_File_Index (P);
271 Src := Source_File.Table (Sindex).Source_Text;
277 C := (C - 1) / 8 * 8 + (8 + 1);
287 end Get_Column_Number;
289 -----------------------------
290 -- Get_Logical_Line_Number --
291 -----------------------------
293 function Get_Logical_Line_Number
294 (P : Source_Ptr) return Logical_Line_Number
296 SFR : Source_File_Record
297 renames Source_File.Table (Get_Source_File_Index (P));
299 L : constant Physical_Line_Number := Get_Physical_Line_Number (P);
302 if SFR.Num_SRef_Pragmas = 0 then
303 return Logical_Line_Number (L);
305 return SFR.Logical_Lines_Table (L);
307 end Get_Logical_Line_Number;
309 ---------------------------------
310 -- Get_Logical_Line_Number_Img --
311 ---------------------------------
313 function Get_Logical_Line_Number_Img
314 (P : Source_Ptr) return String
318 Add_Nat_To_Name_Buffer (Nat (Get_Logical_Line_Number (P)));
319 return Name_Buffer (1 .. Name_Len);
320 end Get_Logical_Line_Number_Img;
322 ------------------------------
323 -- Get_Physical_Line_Number --
324 ------------------------------
326 function Get_Physical_Line_Number
327 (P : Source_Ptr) return Physical_Line_Number
329 Sfile : Source_File_Index;
330 Table : Lines_Table_Ptr;
331 Lo : Physical_Line_Number;
332 Hi : Physical_Line_Number;
333 Mid : Physical_Line_Number;
337 -- If the input source pointer is not a meaningful value then return
338 -- at once with line number 1. This can happen for a file not found
339 -- condition for a file loaded indirectly by RTE, and also perhaps on
340 -- some unknown internal error conditions. In either case we certainly
341 -- don't want to blow up.
346 -- Otherwise we can do the binary search
349 Sfile := Get_Source_File_Index (P);
350 Loc := P + Source_File.Table (Sfile).Sloc_Adjust;
351 Table := Source_File.Table (Sfile).Lines_Table;
353 Hi := Source_File.Table (Sfile).Last_Source_Line;
356 Mid := (Lo + Hi) / 2;
358 if Loc < Table (Mid) then
361 else -- Loc >= Table (Mid)
364 Loc < Table (Mid + 1)
375 end Get_Physical_Line_Number;
377 ---------------------------
378 -- Get_Source_File_Index --
379 ---------------------------
381 Source_Cache_First : Source_Ptr := 1;
382 Source_Cache_Last : Source_Ptr := 0;
383 -- Records the First and Last subscript values for the most recently
384 -- referenced entry in the source table, to optimize the common case of
385 -- repeated references to the same entry. The initial values force an
386 -- initial search to set the cache value.
388 Source_Cache_Index : Source_File_Index := No_Source_File;
389 -- Contains the index of the entry corresponding to Source_Cache
391 function Get_Source_File_Index (S : Source_Ptr) return Source_File_Index is
393 if S in Source_Cache_First .. Source_Cache_Last then
394 return Source_Cache_Index;
397 pragma Assert (Source_File_Index_Table (Int (S) / Chunk_Size)
400 for J in Source_File_Index_Table (Int (S) / Chunk_Size)
403 if S in Source_File.Table (J).Source_First ..
404 Source_File.Table (J).Source_Last
406 Source_Cache_Index := J;
407 Source_Cache_First :=
408 Source_File.Table (Source_Cache_Index).Source_First;
410 Source_File.Table (Source_Cache_Index).Source_Last;
411 return Source_Cache_Index;
416 -- We must find a matching entry in the above loop!
419 end Get_Source_File_Index;
425 procedure Initialize is
427 Source_Cache_First := 1;
428 Source_Cache_Last := 0;
429 Source_Cache_Index := No_Source_File;
430 Source_gnat_adc := No_Source_File;
431 First_Time_Around := True;
436 -------------------------
437 -- Instantiation_Depth --
438 -------------------------
440 function Instantiation_Depth (S : Source_Ptr) return Nat is
441 Sind : Source_File_Index;
450 Sind := Get_Source_File_Index (Sval);
451 Sval := Instantiation (Sind);
452 exit when Sval = No_Location;
457 end Instantiation_Depth;
459 ----------------------------
460 -- Instantiation_Location --
461 ----------------------------
463 function Instantiation_Location (S : Source_Ptr) return Source_Ptr is
465 return Instantiation (Get_Source_File_Index (S));
466 end Instantiation_Location;
468 ----------------------
469 -- Last_Source_File --
470 ----------------------
472 function Last_Source_File return Source_File_Index is
474 return Source_File.Last;
475 end Last_Source_File;
481 function Line_Start (P : Source_Ptr) return Source_Ptr is
482 Sindex : constant Source_File_Index := Get_Source_File_Index (P);
483 Src : constant Source_Buffer_Ptr :=
484 Source_File.Table (Sindex).Source_Text;
485 Sfirst : constant Source_Ptr :=
486 Source_File.Table (Sindex).Source_First;
492 and then Src (S - 1) /= CR
493 and then Src (S - 1) /= LF
502 (L : Physical_Line_Number;
503 S : Source_File_Index) return Source_Ptr
506 return Source_File.Table (S).Lines_Table (L);
515 Source_File.Locked := True;
519 ----------------------
520 -- Num_Source_Files --
521 ----------------------
523 function Num_Source_Files return Nat is
525 return Int (Source_File.Last) - Int (Source_File.First) + 1;
526 end Num_Source_Files;
528 ----------------------
529 -- Num_Source_Lines --
530 ----------------------
532 function Num_Source_Lines (S : Source_File_Index) return Nat is
534 return Nat (Source_File.Table (S).Last_Source_Line);
535 end Num_Source_Lines;
537 -----------------------
538 -- Original_Location --
539 -----------------------
541 function Original_Location (S : Source_Ptr) return Source_Ptr is
542 Sindex : Source_File_Index;
543 Tindex : Source_File_Index;
546 if S <= No_Location then
550 Sindex := Get_Source_File_Index (S);
552 if Instantiation (Sindex) = No_Location then
556 Tindex := Template (Sindex);
557 while Instantiation (Tindex) /= No_Location loop
558 Tindex := Template (Tindex);
561 return S - Source_First (Sindex) + Source_First (Tindex);
564 end Original_Location;
566 -------------------------
567 -- Physical_To_Logical --
568 -------------------------
570 function Physical_To_Logical
571 (Line : Physical_Line_Number;
572 S : Source_File_Index) return Logical_Line_Number
574 SFR : Source_File_Record renames Source_File.Table (S);
577 if SFR.Num_SRef_Pragmas = 0 then
578 return Logical_Line_Number (Line);
580 return SFR.Logical_Lines_Table (Line);
582 end Physical_To_Logical;
584 --------------------------------
585 -- Register_Source_Ref_Pragma --
586 --------------------------------
588 procedure Register_Source_Ref_Pragma
589 (File_Name : File_Name_Type;
590 Stripped_File_Name : File_Name_Type;
592 Line_After_Pragma : Physical_Line_Number)
594 subtype size_t is Memory.size_t;
596 SFR : Source_File_Record renames Source_File.Table (Current_Source_File);
598 ML : Logical_Line_Number;
601 if File_Name /= No_File then
602 SFR.Reference_Name := Stripped_File_Name;
603 SFR.Full_Ref_Name := File_Name;
605 if not Debug_Generated_Code then
606 SFR.Debug_Source_Name := Stripped_File_Name;
607 SFR.Full_Debug_Name := File_Name;
610 SFR.Num_SRef_Pragmas := SFR.Num_SRef_Pragmas + 1;
613 if SFR.Num_SRef_Pragmas = 1 then
614 SFR.First_Mapped_Line := Logical_Line_Number (Mapped_Line);
617 if SFR.Logical_Lines_Table = null then
618 SFR.Logical_Lines_Table := To_Pointer
620 (size_t (SFR.Lines_Table_Max *
621 Logical_Lines_Table_Type'Component_Size /
625 SFR.Logical_Lines_Table (Line_After_Pragma - 1) := No_Line_Number;
627 ML := Logical_Line_Number (Mapped_Line);
628 for J in Line_After_Pragma .. SFR.Last_Source_Line loop
629 SFR.Logical_Lines_Table (J) := ML;
632 end Register_Source_Ref_Pragma;
634 ---------------------------------
635 -- Set_Source_File_Index_Table --
636 ---------------------------------
638 procedure Set_Source_File_Index_Table (Xnew : Source_File_Index) is
641 SL : constant Source_Ptr := Source_File.Table (Xnew).Source_Last;
644 SP := (Source_File.Table (Xnew).Source_First + Chunk_Size - 1)
645 / Chunk_Size * Chunk_Size;
646 Ind := Int (SP) / Chunk_Size;
649 Source_File_Index_Table (Ind) := Xnew;
650 SP := SP + Chunk_Size;
653 end Set_Source_File_Index_Table;
655 ---------------------------
656 -- Skip_Line_Terminators --
657 ---------------------------
659 procedure Skip_Line_Terminators
660 (P : in out Source_Ptr;
661 Physical : out Boolean)
663 Chr : constant Character := Source (P);
667 if Source (P + 1) = LF then
676 elsif Chr = FF or else Chr = VT then
681 -- Otherwise we have a wide character
684 Skip_Wide (Source, P);
687 -- Fall through in the physical line terminator case. First deal with
688 -- making a possible entry into the lines table if one is needed.
690 -- Note: we are dealing with a real source file here, this cannot be
691 -- the instantiation case, so we need not worry about Sloc adjustment.
694 S : Source_File_Record
695 renames Source_File.Table (Current_Source_File);
700 -- Make entry in lines table if not already made (in some scan backup
701 -- cases, we will be rescanning previously scanned source, so the
702 -- entry may have already been made on the previous forward scan).
705 and then P > S.Lines_Table (S.Last_Source_Line)
707 Add_Line_Tables_Entry (S, P);
710 end Skip_Line_Terminators;
716 procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is
718 function Process (N : Node_Id) return Traverse_Result;
719 -- Process function for traversing the node tree
721 procedure Traverse is new Traverse_Proc (Process);
727 function Process (N : Node_Id) return Traverse_Result is
729 if Sloc (N) < Min then
730 if Sloc (N) > No_Location then
733 elsif Sloc (N) > Max then
734 if Sloc (N) > No_Location then
742 -- Start of processing for Sloc_Range
754 function Source_Offset (S : Source_Ptr) return Nat is
755 Sindex : constant Source_File_Index := Get_Source_File_Index (S);
756 Sfirst : constant Source_Ptr :=
757 Source_File.Table (Sindex).Source_First;
759 return Nat (S - Sfirst);
762 ------------------------
763 -- Top_Level_Location --
764 ------------------------
766 function Top_Level_Location (S : Source_Ptr) return Source_Ptr is
774 Newloc := Instantiation_Location (Oldloc);
775 exit when Newloc = No_Location;
779 end Top_Level_Location;
785 procedure Tree_Read is
787 -- First we must free any old source buffer pointers
789 if not First_Time_Around then
790 for J in Source_File.First .. Source_File.Last loop
792 S : Source_File_Record renames Source_File.Table (J);
794 procedure Free_Ptr is new Unchecked_Deallocation
795 (Big_Source_Buffer, Source_Buffer_Ptr);
797 pragma Warnings (Off);
798 -- This unchecked conversion is aliasing safe, since it is not
799 -- used to create improperly aliased pointer values.
801 function To_Source_Buffer_Ptr is new
802 Unchecked_Conversion (Address, Source_Buffer_Ptr);
804 pragma Warnings (On);
806 Tmp1 : Source_Buffer_Ptr;
809 if S.Instantiation /= No_Location then
813 -- Free the buffer, we use Free here, because we used malloc
814 -- or realloc directly to allocate the tables. That is
815 -- because we were playing the big array trick.
817 -- We have to recreate a proper pointer to the actual array
818 -- from the zero origin pointer stored in the source table.
822 (S.Source_Text (S.Source_First)'Address);
825 if S.Lines_Table /= null then
826 Memory.Free (To_Address (S.Lines_Table));
827 S.Lines_Table := null;
830 if S.Logical_Lines_Table /= null then
831 Memory.Free (To_Address (S.Logical_Lines_Table));
832 S.Logical_Lines_Table := null;
839 -- Reset source cache pointers to force new read
841 Source_Cache_First := 1;
842 Source_Cache_Last := 0;
844 -- Read in source file table
846 Source_File.Tree_Read;
848 -- The pointers we read in there for the source buffer and lines
849 -- table pointers are junk. We now read in the actual data that
850 -- is referenced by these two fields.
852 for J in Source_File.First .. Source_File.Last loop
854 S : Source_File_Record renames Source_File.Table (J);
857 -- For the instantiation case, we do not read in any data. Instead
858 -- we share the data for the generic template entry. Since the
859 -- template always occurs first, we can safely refer to its data.
861 if S.Instantiation /= No_Location then
863 ST : Source_File_Record renames
864 Source_File.Table (S.Template);
867 -- The lines tables are copied from the template entry
870 Source_File.Table (S.Template).Lines_Table;
871 S.Logical_Lines_Table :=
872 Source_File.Table (S.Template).Logical_Lines_Table;
874 -- In the case of the source table pointer, we share the
875 -- same data as the generic template, but the virtual origin
876 -- is adjusted. For example, if the first subscript of the
877 -- template is 100, and that of the instantiation is 200,
878 -- then the instantiation pointer is obtained by subtracting
879 -- 100 from the template pointer.
882 pragma Suppress (All_Checks);
884 pragma Warnings (Off);
885 -- This unchecked conversion is aliasing safe since it
886 -- not used to create improperly aliased pointer values.
888 function To_Source_Buffer_Ptr is new
889 Unchecked_Conversion (Address, Source_Buffer_Ptr);
891 pragma Warnings (On);
897 (ST.Source_First - S.Source_First)'Address);
901 -- Normal case (non-instantiation)
904 First_Time_Around := False;
905 S.Lines_Table := null;
906 S.Logical_Lines_Table := null;
907 Alloc_Line_Tables (S, Int (S.Last_Source_Line));
909 for J in 1 .. S.Last_Source_Line loop
910 Tree_Read_Int (Int (S.Lines_Table (J)));
913 if S.Num_SRef_Pragmas /= 0 then
914 for J in 1 .. S.Last_Source_Line loop
915 Tree_Read_Int (Int (S.Logical_Lines_Table (J)));
919 -- Allocate source buffer and read in the data and then set the
920 -- virtual origin to point to the logical zero'th element. This
921 -- address must be computed with subscript checks turned off.
924 subtype B is Text_Buffer (S.Source_First .. S.Source_Last);
925 type Text_Buffer_Ptr is access B;
928 pragma Suppress (All_Checks);
930 pragma Warnings (Off);
931 -- This unchecked conversion is aliasing safe, since it is
932 -- never used to create improperly aliased pointer values.
934 function To_Source_Buffer_Ptr is new
935 Unchecked_Conversion (Address, Source_Buffer_Ptr);
937 pragma Warnings (On);
942 Tree_Read_Data (T (S.Source_First)'Address,
943 Int (S.Source_Last) - Int (S.Source_First) + 1);
945 S.Source_Text := To_Source_Buffer_Ptr (T (0)'Address);
950 Set_Source_File_Index_Table (J);
958 procedure Tree_Write is
960 Source_File.Tree_Write;
962 -- The pointers we wrote out there for the source buffer and lines
963 -- table pointers are junk, we now write out the actual data that
964 -- is referenced by these two fields.
966 for J in Source_File.First .. Source_File.Last loop
968 S : Source_File_Record renames Source_File.Table (J);
971 -- For instantiations, there is nothing to do, since the data is
972 -- shared with the generic template. When the tree is read, the
973 -- pointers must be set, but no extra data needs to be written.
975 if S.Instantiation /= No_Location then
978 -- For the normal case, write out the data of the tables
983 for J in 1 .. S.Last_Source_Line loop
984 Tree_Write_Int (Int (S.Lines_Table (J)));
987 -- Logical lines table if present
989 if S.Num_SRef_Pragmas /= 0 then
990 for J in 1 .. S.Last_Source_Line loop
991 Tree_Write_Int (Int (S.Logical_Lines_Table (J)));
998 (S.Source_Text (S.Source_First)'Address,
999 Int (S.Source_Last) - Int (S.Source_First) + 1);
1005 --------------------
1006 -- Write_Location --
1007 --------------------
1009 procedure Write_Location (P : Source_Ptr) is
1011 if P = No_Location then
1012 Write_Str ("<no location>");
1014 elsif P <= Standard_Location then
1015 Write_Str ("<standard location>");
1019 SI : constant Source_File_Index := Get_Source_File_Index (P);
1022 Write_Name (Debug_Source_Name (SI));
1024 Write_Int (Int (Get_Logical_Line_Number (P)));
1026 Write_Int (Int (Get_Column_Number (P)));
1028 if Instantiation (SI) /= No_Location then
1030 Write_Location (Instantiation (SI));
1037 ----------------------
1038 -- Write_Time_Stamp --
1039 ----------------------
1041 procedure Write_Time_Stamp (S : Source_File_Index) is
1042 T : constant Time_Stamp_Type := Time_Stamp (S);
1055 Write_Char (T (P + 1));
1056 Write_Char (T (P + 2));
1059 Write_Char (T (P + 3));
1060 Write_Char (T (P + 4));
1063 Write_Char (T (P + 5));
1064 Write_Char (T (P + 6));
1067 Write_Char (T (P + 7));
1068 Write_Char (T (P + 8));
1071 Write_Char (T (P + 9));
1072 Write_Char (T (P + 10));
1075 Write_Char (T (P + 11));
1076 Write_Char (T (P + 12));
1077 end Write_Time_Stamp;
1079 ----------------------------------------------
1080 -- Access Subprograms for Source File Table --
1081 ----------------------------------------------
1083 function Debug_Source_Name (S : SFI) return File_Name_Type is
1085 return Source_File.Table (S).Debug_Source_Name;
1086 end Debug_Source_Name;
1088 function File_Name (S : SFI) return File_Name_Type is
1090 return Source_File.Table (S).File_Name;
1093 function File_Type (S : SFI) return Type_Of_File is
1095 return Source_File.Table (S).File_Type;
1098 function First_Mapped_Line (S : SFI) return Logical_Line_Number is
1100 return Source_File.Table (S).First_Mapped_Line;
1101 end First_Mapped_Line;
1103 function Full_Debug_Name (S : SFI) return File_Name_Type is
1105 return Source_File.Table (S).Full_Debug_Name;
1106 end Full_Debug_Name;
1108 function Full_File_Name (S : SFI) return File_Name_Type is
1110 return Source_File.Table (S).Full_File_Name;
1113 function Full_Ref_Name (S : SFI) return File_Name_Type is
1115 return Source_File.Table (S).Full_Ref_Name;
1118 function Identifier_Casing (S : SFI) return Casing_Type is
1120 return Source_File.Table (S).Identifier_Casing;
1121 end Identifier_Casing;
1123 function Inlined_Body (S : SFI) return Boolean is
1125 return Source_File.Table (S).Inlined_Body;
1128 function Instantiation (S : SFI) return Source_Ptr is
1130 return Source_File.Table (S).Instantiation;
1133 function Keyword_Casing (S : SFI) return Casing_Type is
1135 return Source_File.Table (S).Keyword_Casing;
1138 function Last_Source_Line (S : SFI) return Physical_Line_Number is
1140 return Source_File.Table (S).Last_Source_Line;
1141 end Last_Source_Line;
1143 function License (S : SFI) return License_Type is
1145 return Source_File.Table (S).License;
1148 function Num_SRef_Pragmas (S : SFI) return Nat is
1150 return Source_File.Table (S).Num_SRef_Pragmas;
1151 end Num_SRef_Pragmas;
1153 function Reference_Name (S : SFI) return File_Name_Type is
1155 return Source_File.Table (S).Reference_Name;
1158 function Source_Checksum (S : SFI) return Word is
1160 return Source_File.Table (S).Source_Checksum;
1161 end Source_Checksum;
1163 function Source_First (S : SFI) return Source_Ptr is
1165 if S = Internal_Source_File then
1166 return Internal_Source'First;
1168 return Source_File.Table (S).Source_First;
1172 function Source_Last (S : SFI) return Source_Ptr is
1174 if S = Internal_Source_File then
1175 return Internal_Source'Last;
1177 return Source_File.Table (S).Source_Last;
1181 function Source_Text (S : SFI) return Source_Buffer_Ptr is
1183 if S = Internal_Source_File then
1184 return Internal_Source_Ptr;
1186 return Source_File.Table (S).Source_Text;
1190 function Template (S : SFI) return SFI is
1192 return Source_File.Table (S).Template;
1195 function Time_Stamp (S : SFI) return Time_Stamp_Type is
1197 return Source_File.Table (S).Time_Stamp;
1200 function Unit (S : SFI) return Unit_Number_Type is
1202 return Source_File.Table (S).Unit;
1205 ------------------------------------------
1206 -- Set Procedures for Source File Table --
1207 ------------------------------------------
1209 procedure Set_Identifier_Casing (S : SFI; C : Casing_Type) is
1211 Source_File.Table (S).Identifier_Casing := C;
1212 end Set_Identifier_Casing;
1214 procedure Set_Keyword_Casing (S : SFI; C : Casing_Type) is
1216 Source_File.Table (S).Keyword_Casing := C;
1217 end Set_Keyword_Casing;
1219 procedure Set_License (S : SFI; L : License_Type) is
1221 Source_File.Table (S).License := L;
1224 procedure Set_Unit (S : SFI; U : Unit_Number_Type) is
1226 Source_File.Table (S).Unit := U;
1229 ----------------------
1230 -- Trim_Lines_Table --
1231 ----------------------
1233 procedure Trim_Lines_Table (S : Source_File_Index) is
1234 Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line);
1237 -- Release allocated storage that is no longer needed
1239 Source_File.Table (S).Lines_Table := To_Pointer
1241 (To_Address (Source_File.Table (S).Lines_Table),
1243 (Max * (Lines_Table_Type'Component_Size / System.Storage_Unit))));
1244 Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max);
1245 end Trim_Lines_Table;
1253 Source_File.Locked := False;
1254 Source_File.Release;
1261 procedure wl (P : Source_Ptr) is