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.
797 -- We have to recreate a proper pointer to the actual array
798 -- from the zero origin pointer stored in the source table.
802 (S.Source_Text (S.Source_First)'Address);
805 if S.Lines_Table /= null then
806 Memory.Free (To_Address (S.Lines_Table));
807 S.Lines_Table := null;
810 if S.Logical_Lines_Table /= null then
811 Memory.Free (To_Address (S.Logical_Lines_Table));
812 S.Logical_Lines_Table := null;
819 -- Reset source cache pointers to force new read
821 Source_Cache_First := 1;
822 Source_Cache_Last := 0;
824 -- Read in source file table
826 Source_File.Tree_Read;
828 -- The pointers we read in there for the source buffer and lines
829 -- table pointers are junk. We now read in the actual data that
830 -- is referenced by these two fields.
832 for J in Source_File.First .. Source_File.Last loop
834 S : Source_File_Record renames Source_File.Table (J);
837 -- For the instantiation case, we do not read in any data. Instead
838 -- we share the data for the generic template entry. Since the
839 -- template always occurs first, we can safely refer to its data.
841 if S.Instantiation /= No_Location then
843 ST : Source_File_Record renames
844 Source_File.Table (S.Template);
847 -- The lines tables are copied from the template entry
850 Source_File.Table (S.Template).Lines_Table;
851 S.Logical_Lines_Table :=
852 Source_File.Table (S.Template).Logical_Lines_Table;
854 -- In the case of the source table pointer, we share the
855 -- same data as the generic template, but the virtual origin
856 -- is adjusted. For example, if the first subscript of the
857 -- template is 100, and that of the instantiation is 200,
858 -- then the instantiation pointer is obtained by subtracting
859 -- 100 from the template pointer.
862 pragma Suppress (All_Checks);
864 pragma Warnings (Off);
865 -- This unchecked conversion is aliasing safe since it
866 -- not used to create improperly aliased pointer values.
868 function To_Source_Buffer_Ptr is new
869 Unchecked_Conversion (Address, Source_Buffer_Ptr);
871 pragma Warnings (On);
877 (ST.Source_First - S.Source_First)'Address);
881 -- Normal case (non-instantiation)
884 First_Time_Around := False;
885 S.Lines_Table := null;
886 S.Logical_Lines_Table := null;
887 Alloc_Line_Tables (S, Int (S.Last_Source_Line));
889 for J in 1 .. S.Last_Source_Line loop
890 Tree_Read_Int (Int (S.Lines_Table (J)));
893 if S.Num_SRef_Pragmas /= 0 then
894 for J in 1 .. S.Last_Source_Line loop
895 Tree_Read_Int (Int (S.Logical_Lines_Table (J)));
899 -- Allocate source buffer and read in the data and then set the
900 -- virtual origin to point to the logical zero'th element. This
901 -- address must be computed with subscript checks turned off.
904 subtype B is Text_Buffer (S.Source_First .. S.Source_Last);
905 type Text_Buffer_Ptr is access B;
908 pragma Suppress (All_Checks);
910 pragma Warnings (Off);
911 -- This unchecked conversion is aliasing safe, since it is
912 -- never used to create improperly aliased pointer values.
914 function To_Source_Buffer_Ptr is new
915 Unchecked_Conversion (Address, Source_Buffer_Ptr);
917 pragma Warnings (On);
922 Tree_Read_Data (T (S.Source_First)'Address,
923 Int (S.Source_Last) - Int (S.Source_First) + 1);
925 S.Source_Text := To_Source_Buffer_Ptr (T (0)'Address);
930 Set_Source_File_Index_Table (J);
938 procedure Tree_Write is
940 Source_File.Tree_Write;
942 -- The pointers we wrote out there for the source buffer and lines
943 -- table pointers are junk, we now write out the actual data that
944 -- is referenced by these two fields.
946 for J in Source_File.First .. Source_File.Last loop
948 S : Source_File_Record renames Source_File.Table (J);
951 -- For instantiations, there is nothing to do, since the data is
952 -- shared with the generic template. When the tree is read, the
953 -- pointers must be set, but no extra data needs to be written.
955 if S.Instantiation /= No_Location then
958 -- For the normal case, write out the data of the tables
963 for J in 1 .. S.Last_Source_Line loop
964 Tree_Write_Int (Int (S.Lines_Table (J)));
967 -- Logical lines table if present
969 if S.Num_SRef_Pragmas /= 0 then
970 for J in 1 .. S.Last_Source_Line loop
971 Tree_Write_Int (Int (S.Logical_Lines_Table (J)));
978 (S.Source_Text (S.Source_First)'Address,
979 Int (S.Source_Last) - Int (S.Source_First) + 1);
989 procedure Write_Location (P : Source_Ptr) is
991 if P = No_Location then
992 Write_Str ("<no location>");
994 elsif P <= Standard_Location then
995 Write_Str ("<standard location>");
999 SI : constant Source_File_Index := Get_Source_File_Index (P);
1002 Write_Name (Debug_Source_Name (SI));
1004 Write_Int (Int (Get_Logical_Line_Number (P)));
1006 Write_Int (Int (Get_Column_Number (P)));
1008 if Instantiation (SI) /= No_Location then
1010 Write_Location (Instantiation (SI));
1017 ----------------------
1018 -- Write_Time_Stamp --
1019 ----------------------
1021 procedure Write_Time_Stamp (S : Source_File_Index) is
1022 T : constant Time_Stamp_Type := Time_Stamp (S);
1035 Write_Char (T (P + 1));
1036 Write_Char (T (P + 2));
1039 Write_Char (T (P + 3));
1040 Write_Char (T (P + 4));
1043 Write_Char (T (P + 5));
1044 Write_Char (T (P + 6));
1047 Write_Char (T (P + 7));
1048 Write_Char (T (P + 8));
1051 Write_Char (T (P + 9));
1052 Write_Char (T (P + 10));
1055 Write_Char (T (P + 11));
1056 Write_Char (T (P + 12));
1057 end Write_Time_Stamp;
1059 ----------------------------------------------
1060 -- Access Subprograms for Source File Table --
1061 ----------------------------------------------
1063 function Debug_Source_Name (S : SFI) return File_Name_Type is
1065 return Source_File.Table (S).Debug_Source_Name;
1066 end Debug_Source_Name;
1068 function File_Name (S : SFI) return File_Name_Type is
1070 return Source_File.Table (S).File_Name;
1073 function File_Type (S : SFI) return Type_Of_File is
1075 return Source_File.Table (S).File_Type;
1078 function First_Mapped_Line (S : SFI) return Logical_Line_Number is
1080 return Source_File.Table (S).First_Mapped_Line;
1081 end First_Mapped_Line;
1083 function Full_Debug_Name (S : SFI) return File_Name_Type is
1085 return Source_File.Table (S).Full_Debug_Name;
1086 end Full_Debug_Name;
1088 function Full_File_Name (S : SFI) return File_Name_Type is
1090 return Source_File.Table (S).Full_File_Name;
1093 function Full_Ref_Name (S : SFI) return File_Name_Type is
1095 return Source_File.Table (S).Full_Ref_Name;
1098 function Identifier_Casing (S : SFI) return Casing_Type is
1100 return Source_File.Table (S).Identifier_Casing;
1101 end Identifier_Casing;
1103 function Inlined_Body (S : SFI) return Boolean is
1105 return Source_File.Table (S).Inlined_Body;
1108 function Instantiation (S : SFI) return Source_Ptr is
1110 return Source_File.Table (S).Instantiation;
1113 function Keyword_Casing (S : SFI) return Casing_Type is
1115 return Source_File.Table (S).Keyword_Casing;
1118 function Last_Source_Line (S : SFI) return Physical_Line_Number is
1120 return Source_File.Table (S).Last_Source_Line;
1121 end Last_Source_Line;
1123 function License (S : SFI) return License_Type is
1125 return Source_File.Table (S).License;
1128 function Num_SRef_Pragmas (S : SFI) return Nat is
1130 return Source_File.Table (S).Num_SRef_Pragmas;
1131 end Num_SRef_Pragmas;
1133 function Reference_Name (S : SFI) return File_Name_Type is
1135 return Source_File.Table (S).Reference_Name;
1138 function Source_Checksum (S : SFI) return Word is
1140 return Source_File.Table (S).Source_Checksum;
1141 end Source_Checksum;
1143 function Source_First (S : SFI) return Source_Ptr is
1145 if S = Internal_Source_File then
1146 return Internal_Source'First;
1148 return Source_File.Table (S).Source_First;
1152 function Source_Last (S : SFI) return Source_Ptr is
1154 if S = Internal_Source_File then
1155 return Internal_Source'Last;
1157 return Source_File.Table (S).Source_Last;
1161 function Source_Text (S : SFI) return Source_Buffer_Ptr is
1163 if S = Internal_Source_File then
1164 return Internal_Source_Ptr;
1166 return Source_File.Table (S).Source_Text;
1170 function Template (S : SFI) return SFI is
1172 return Source_File.Table (S).Template;
1175 function Time_Stamp (S : SFI) return Time_Stamp_Type is
1177 return Source_File.Table (S).Time_Stamp;
1180 function Unit (S : SFI) return Unit_Number_Type is
1182 return Source_File.Table (S).Unit;
1185 ------------------------------------------
1186 -- Set Procedures for Source File Table --
1187 ------------------------------------------
1189 procedure Set_Identifier_Casing (S : SFI; C : Casing_Type) is
1191 Source_File.Table (S).Identifier_Casing := C;
1192 end Set_Identifier_Casing;
1194 procedure Set_Keyword_Casing (S : SFI; C : Casing_Type) is
1196 Source_File.Table (S).Keyword_Casing := C;
1197 end Set_Keyword_Casing;
1199 procedure Set_License (S : SFI; L : License_Type) is
1201 Source_File.Table (S).License := L;
1204 procedure Set_Unit (S : SFI; U : Unit_Number_Type) is
1206 Source_File.Table (S).Unit := U;
1209 ----------------------
1210 -- Trim_Lines_Table --
1211 ----------------------
1213 procedure Trim_Lines_Table (S : Source_File_Index) is
1214 Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line);
1217 -- Release allocated storage that is no longer needed
1219 Source_File.Table (S).Lines_Table := To_Pointer
1221 (To_Address (Source_File.Table (S).Lines_Table),
1223 (Max * (Lines_Table_Type'Component_Size / System.Storage_Unit))));
1224 Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max);
1225 end Trim_Lines_Table;
1233 Source_File.Locked := False;
1234 Source_File.Release;
1241 procedure wl (P : Source_Ptr) is