1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1999-2020, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Debug; use Debug;
30 with Einfo; use Einfo;
32 with Namet; use Namet;
33 with Nlists; use Nlists;
35 with Output; use Output;
36 with Sem_Aux; use Sem_Aux;
37 with Sem_Eval; use Sem_Eval;
38 with Sinfo; use Sinfo;
39 with Sinput; use Sinput;
40 with Snames; use Snames;
41 with Stringt; use Stringt;
44 with Uname; use Uname;
45 with Urealp; use Urealp;
47 with Ada.Unchecked_Conversion;
51 package body Repinfo is
53 SSU : Pos renames Ttypes.System_Storage_Unit;
54 -- Value for Storage_Unit
56 ---------------------------------------
57 -- Representation of GCC Expressions --
58 ---------------------------------------
60 -- A table internal to this unit is used to hold the values of back
61 -- annotated expressions.
63 -- Node values are stored as Uint values using the negative of the node
64 -- index in this table. Constants appear as non-negative Uint values.
66 type Exp_Node is record
68 Op1 : Node_Ref_Or_Val;
69 Op2 : Node_Ref_Or_Val;
70 Op3 : Node_Ref_Or_Val;
73 -- The following representation clause ensures that the above record
74 -- has no holes. We do this so that when instances of this record are
75 -- written, we do not write uninitialized values to the file.
77 for Exp_Node use record
78 Expr at 0 range 0 .. 31;
79 Op1 at 4 range 0 .. 31;
80 Op2 at 8 range 0 .. 31;
81 Op3 at 12 range 0 .. 31;
84 for Exp_Node'Size use 16 * 8;
85 -- This ensures that we did not leave out any fields
87 package Rep_Table is new Table.Table (
88 Table_Component_Type => Exp_Node,
89 Table_Index_Type => Nat,
91 Table_Initial => Alloc.Rep_Table_Initial,
92 Table_Increment => Alloc.Rep_Table_Increment,
93 Table_Name => "BE_Rep_Table");
95 Unit_Casing : Casing_Type;
96 -- Identifier casing for current unit. This is set by List_Rep_Info for
97 -- each unit, before calling subprograms which may read it.
99 Need_Separator : Boolean;
100 -- Set True if a separator is needed before outputting any information for
101 -- the current entity.
103 ------------------------------
104 -- Set of Relevant Entities --
105 ------------------------------
107 Relevant_Entities_Size : constant := 4093;
108 -- Number of headers in hash table
110 subtype Entity_Header_Num is Integer range 0 .. Relevant_Entities_Size - 1;
111 -- Range of headers in hash table
113 function Entity_Hash (Id : Entity_Id) return Entity_Header_Num;
114 -- Simple hash function for Entity_Ids
116 package Relevant_Entities is new GNAT.Htable.Simple_HTable
117 (Header_Num => Entity_Header_Num,
123 -- Hash table to record which compiler-generated entities are relevant
125 -----------------------
126 -- Local Subprograms --
127 -----------------------
129 procedure List_Entities
131 Bytes_Big_Endian : Boolean;
132 In_Subprogram : Boolean := False);
133 -- This procedure lists the entities associated with the entity E, starting
134 -- with the First_Entity and using the Next_Entity link. If a nested
135 -- package is found, entities within the package are recursively processed.
136 -- When recursing within a subprogram body, Is_Subprogram suppresses
137 -- duplicate information about signature.
139 procedure List_Name (Ent : Entity_Id);
140 -- List name of entity Ent in appropriate case. The name is listed with
141 -- full qualification up to but not including the compilation unit name.
143 procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
144 -- List representation info for array type Ent
146 procedure List_Common_Type_Info (Ent : Entity_Id);
147 -- List common type info (name, size, alignment) for type Ent
149 procedure List_Linker_Section (Ent : Entity_Id);
150 -- List linker section for Ent (caller has checked that Ent is an entity
151 -- for which the Linker_Section_Pragma field is defined).
153 procedure List_Location (Ent : Entity_Id);
154 -- List location information for Ent
156 procedure List_Object_Info (Ent : Entity_Id);
157 -- List representation info for object Ent
159 procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
160 -- List representation info for record type Ent
162 procedure List_Scalar_Storage_Order
164 Bytes_Big_Endian : Boolean);
165 -- List scalar storage order information for record or array type Ent.
166 -- Also includes bit order information for record types, if necessary.
168 procedure List_Subprogram_Info (Ent : Entity_Id);
169 -- List subprogram info for subprogram Ent
171 procedure List_Type_Info (Ent : Entity_Id);
172 -- List type info for type Ent
174 function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean;
175 -- Returns True if Val represents a variable value, and False if it
176 -- represents a value that is fixed at compile time.
178 procedure Spaces (N : Natural);
179 -- Output given number of spaces
181 procedure Write_Info_Line (S : String);
182 -- Routine to write a line to Repinfo output file. This routine is passed
183 -- as a special output procedure to Output.Set_Special_Output. Note that
184 -- Write_Info_Line is called with an EOL character at the end of each line,
185 -- as per the Output spec, but the internal call to the appropriate routine
186 -- in Osint requires that the end of line sequence be stripped off.
188 procedure Write_Mechanism (M : Mechanism_Type);
189 -- Writes symbolic string for mechanism represented by M
191 procedure Write_Separator;
192 -- Called before outputting anything for an entity. Ensures that
193 -- a separator precedes the output for a particular entity.
195 procedure Write_Unknown_Val;
196 -- Writes symbolic string for an unknown or non-representable value
198 procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False);
199 -- Given a representation value, write it out. No_Uint values or values
200 -- dependent on discriminants are written as two question marks. If the
201 -- flag Paren is set, then the output is surrounded in parentheses if it is
202 -- other than a simple value.
204 ------------------------
205 -- Create_Discrim_Ref --
206 ------------------------
208 function Create_Discrim_Ref (Discr : Entity_Id) return Node_Ref is
211 (Expr => Discrim_Val,
212 Op1 => Discriminant_Number (Discr));
213 end Create_Discrim_Ref;
221 Op1 : Node_Ref_Or_Val;
222 Op2 : Node_Ref_Or_Val := No_Uint;
223 Op3 : Node_Ref_Or_Val := No_Uint) return Node_Ref
231 return UI_From_Int (-Rep_Table.Last);
238 function Entity_Hash (Id : Entity_Id) return Entity_Header_Num is
240 return Entity_Header_Num (Id mod Relevant_Entities_Size);
247 procedure lgx (U : Node_Ref_Or_Val) is
249 List_GCC_Expression (U);
253 ----------------------
254 -- List_Array_Info --
255 ----------------------
257 procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
261 if List_Representation_Info_To_JSON then
265 List_Common_Type_Info (Ent);
267 if List_Representation_Info_To_JSON then
269 Write_Str (" ""Component_Size"": ");
270 Write_Val (Component_Size (Ent));
274 Write_Str ("'Component_Size use ");
275 Write_Val (Component_Size (Ent));
279 List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
281 List_Linker_Section (Ent);
283 if List_Representation_Info_To_JSON then
288 -- The component type is relevant for an array
290 if List_Representation_Info = 4
291 and then Is_Itype (Component_Type (Base_Type (Ent)))
293 Relevant_Entities.Set (Component_Type (Base_Type (Ent)), True);
297 ---------------------------
298 -- List_Common_Type_Info --
299 ---------------------------
301 procedure List_Common_Type_Info (Ent : Entity_Id) is
303 if List_Representation_Info_To_JSON then
304 Write_Str (" ""name"": """);
310 -- Do not list size info for unconstrained arrays, not meaningful
312 if Is_Array_Type (Ent) and then not Is_Constrained (Ent) then
316 -- If Esize and RM_Size are the same, list as Size. This is a common
317 -- case, which we may as well list in simple form.
319 if Esize (Ent) = RM_Size (Ent) then
320 if List_Representation_Info_To_JSON then
321 Write_Str (" ""Size"": ");
322 Write_Val (Esize (Ent));
327 Write_Str ("'Size use ");
328 Write_Val (Esize (Ent));
332 -- Otherwise list size values separately
335 if List_Representation_Info_To_JSON then
336 Write_Str (" ""Object_Size"": ");
337 Write_Val (Esize (Ent));
340 Write_Str (" ""Value_Size"": ");
341 Write_Val (RM_Size (Ent));
347 Write_Str ("'Object_Size use ");
348 Write_Val (Esize (Ent));
353 Write_Str ("'Value_Size use ");
354 Write_Val (RM_Size (Ent));
360 if List_Representation_Info_To_JSON then
361 Write_Str (" ""Alignment"": ");
362 Write_Val (Alignment (Ent));
366 Write_Str ("'Alignment use ");
367 Write_Val (Alignment (Ent));
370 end List_Common_Type_Info;
376 procedure List_Entities
378 Bytes_Big_Endian : Boolean;
379 In_Subprogram : Boolean := False)
384 function Find_Declaration (E : Entity_Id) return Node_Id;
385 -- Utility to retrieve declaration node for entity in the
386 -- case of package bodies and subprograms.
388 ----------------------
389 -- Find_Declaration --
390 ----------------------
392 function Find_Declaration (E : Entity_Id) return Node_Id is
398 and then Nkind (Decl) /= N_Package_Body
399 and then Nkind (Decl) /= N_Subprogram_Declaration
400 and then Nkind (Decl) /= N_Subprogram_Body
402 Decl := Parent (Decl);
406 end Find_Declaration;
408 -- Start of processing for List_Entities
411 -- List entity if we have one, and it is not a renaming declaration.
412 -- For renamings, we don't get proper information, and really it makes
413 -- sense to restrict the output to the renamed entity.
416 and then Nkind (Declaration_Node (Ent)) not in N_Renaming_Declaration
417 and then not Is_Ignored_Ghost_Entity (Ent)
419 -- If entity is a subprogram and we are listing mechanisms,
420 -- then we need to list mechanisms for this entity. We skip this
421 -- if it is a nested subprogram, as the information has already
422 -- been produced when listing the enclosing scope.
424 if List_Representation_Info_Mechanisms
425 and then (Is_Subprogram (Ent)
426 or else Ekind (Ent) = E_Entry
427 or else Ekind (Ent) = E_Entry_Family)
428 and then not In_Subprogram
430 List_Subprogram_Info (Ent);
433 E := First_Entity (Ent);
434 while Present (E) loop
435 -- We list entities that come from source (excluding private or
436 -- incomplete types or deferred constants, for which we will list
437 -- the information for the full view). If requested, we also list
438 -- relevant entities that have been generated when processing the
439 -- original entities coming from source. But if debug flag A is
440 -- set, then all entities are listed.
442 if ((Comes_From_Source (E)
443 or else (Ekind (E) = E_Block
445 Nkind (Parent (E)) = N_Implicit_Label_Declaration
447 Comes_From_Source (Label_Construct (Parent (E)))))
448 and then not Is_Incomplete_Or_Private_Type (E)
449 and then not (Ekind (E) = E_Constant
450 and then Present (Full_View (E))))
451 or else (List_Representation_Info = 4
452 and then Relevant_Entities.Get (E))
453 or else Debug_Flag_AA
455 if Is_Subprogram (E) then
456 if List_Representation_Info_Mechanisms then
457 List_Subprogram_Info (E);
460 -- Recurse into entities local to subprogram
462 List_Entities (E, Bytes_Big_Endian, True);
464 elsif Ekind (E) in E_Entry
468 if List_Representation_Info_Mechanisms then
469 List_Subprogram_Info (E);
472 elsif Is_Record_Type (E) then
473 if List_Representation_Info >= 1 then
474 List_Record_Info (E, Bytes_Big_Endian);
477 -- Recurse into entities local to a record type
479 if List_Representation_Info = 4 then
480 List_Entities (E, Bytes_Big_Endian, False);
483 elsif Is_Array_Type (E) then
484 if List_Representation_Info >= 1 then
485 List_Array_Info (E, Bytes_Big_Endian);
488 elsif Is_Type (E) then
489 if List_Representation_Info >= 2 then
493 -- Note that formals are not annotated so we skip them here
495 elsif Ekind (E) in E_Constant
499 if List_Representation_Info >= 2 then
500 List_Object_Info (E);
504 -- Recurse into nested package, but not if they are package
505 -- renamings (in particular renamings of the enclosing package,
506 -- as for some Java bindings and for generic instances).
508 if Ekind (E) = E_Package then
509 if No (Renamed_Object (E)) then
510 List_Entities (E, Bytes_Big_Endian);
513 -- Recurse into bodies
515 elsif Ekind (E) in E_Package_Body
522 List_Entities (E, Bytes_Big_Endian);
524 -- Recurse into blocks
526 elsif Ekind (E) = E_Block then
527 List_Entities (E, Bytes_Big_Endian);
534 -- For a package body, the entities of the visible subprograms are
535 -- declared in the corresponding spec. Iterate over its entities in
536 -- order to handle properly the subprogram bodies. Skip bodies in
537 -- subunits, which are listed independently.
539 if Ekind (Ent) = E_Package_Body
540 and then Present (Corresponding_Spec (Find_Declaration (Ent)))
542 E := First_Entity (Corresponding_Spec (Find_Declaration (Ent)));
543 while Present (E) loop
546 Nkind (Find_Declaration (E)) = N_Subprogram_Declaration
548 Body_E := Corresponding_Body (Find_Declaration (E));
552 Nkind (Parent (Find_Declaration (Body_E))) /= N_Subunit
554 List_Entities (Body_E, Bytes_Big_Endian);
564 -------------------------
565 -- List_GCC_Expression --
566 -------------------------
568 procedure List_GCC_Expression (U : Node_Ref_Or_Val) is
570 procedure Print_Expr (Val : Node_Ref_Or_Val);
571 -- Internal recursive procedure to print expression
577 procedure Print_Expr (Val : Node_Ref_Or_Val) is
580 UI_Write (Val, Decimal);
584 Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
586 procedure Unop (S : String);
587 -- Output text for unary operator with S being operator name
589 procedure Binop (S : String);
590 -- Output text for binary operator with S being operator name
596 procedure Unop (S : String) is
598 if List_Representation_Info_To_JSON then
599 Write_Str ("{ ""code"": """);
600 if S (S'Last) = ' ' then
601 Write_Str (S (S'First .. S'Last - 1));
605 Write_Str (""", ""operands"": [ ");
606 Print_Expr (Node.Op1);
610 Print_Expr (Node.Op1);
618 procedure Binop (S : String) is
620 if List_Representation_Info_To_JSON then
621 Write_Str ("{ ""code"": """);
622 Write_Str (S (S'First + 1 .. S'Last - 1));
623 Write_Str (""", ""operands"": [ ");
624 Print_Expr (Node.Op1);
626 Print_Expr (Node.Op2);
630 Print_Expr (Node.Op1);
632 Print_Expr (Node.Op2);
637 -- Start of processing for Print_Expr
642 if List_Representation_Info_To_JSON then
643 Write_Str ("{ ""code"": ""?<>""");
644 Write_Str (", ""operands"": [ ");
645 Print_Expr (Node.Op1);
647 Print_Expr (Node.Op2);
649 Print_Expr (Node.Op3);
653 Print_Expr (Node.Op1);
654 Write_Str (" then ");
655 Print_Expr (Node.Op2);
656 Write_Str (" else ");
657 Print_Expr (Node.Op3);
670 when Trunc_Div_Expr =>
673 when Ceil_Div_Expr =>
676 when Floor_Div_Expr =>
679 when Trunc_Mod_Expr =>
682 when Ceil_Mod_Expr =>
685 when Floor_Mod_Expr =>
688 when Exact_Div_Expr =>
703 when Truth_And_Expr =>
706 when Truth_Or_Expr =>
709 when Truth_Xor_Expr =>
712 when Truth_Not_Expr =>
746 -- Start of processing for List_GCC_Expression
754 end List_GCC_Expression;
756 -------------------------
757 -- List_Linker_Section --
758 -------------------------
760 procedure List_Linker_Section (Ent : Entity_Id) is
765 if Present (Linker_Section_Pragma (Ent)) then
766 Args := Pragma_Argument_Associations (Linker_Section_Pragma (Ent));
767 Sect := Expr_Value_S (Get_Pragma_Arg (Last (Args)));
769 if List_Representation_Info_To_JSON then
771 Write_Str (" ""Linker_Section"": """);
773 Write_Str ("pragma Linker_Section (");
778 pragma Assert (Nkind (Sect) = N_String_Literal);
779 String_To_Name_Buffer (Strval (Sect));
780 Write_Str (Name_Buffer (1 .. Name_Len));
782 if not List_Representation_Info_To_JSON then
786 end List_Linker_Section;
792 procedure List_Location (Ent : Entity_Id) is
794 pragma Assert (List_Representation_Info_To_JSON);
795 Write_Str (" ""location"": """);
796 Write_Location (Sloc (Ent));
804 procedure List_Name (Ent : Entity_Id) is
808 -- List the qualified name recursively, except
809 -- at compilation unit level in default mode.
811 if Is_Compilation_Unit (Ent) then
813 elsif not Is_Compilation_Unit (Scope (Ent))
814 or else List_Representation_Info_To_JSON
816 List_Name (Scope (Ent));
820 Get_Unqualified_Decoded_Name_String (Chars (Ent));
821 Set_Casing (Unit_Casing);
823 -- The name of operators needs to be properly escaped for JSON
825 for J in 1 .. Name_Len loop
826 C := Name_Buffer (J);
827 if C = '"' and then List_Representation_Info_To_JSON then
834 ---------------------
835 -- List_Object_Info --
836 ---------------------
838 procedure List_Object_Info (Ent : Entity_Id) is
842 if List_Representation_Info_To_JSON then
845 Write_Str (" ""name"": """);
850 Write_Str (" ""Size"": ");
851 Write_Val (Esize (Ent));
854 Write_Str (" ""Alignment"": ");
855 Write_Val (Alignment (Ent));
857 List_Linker_Section (Ent);
864 Write_Str ("'Size use ");
865 Write_Val (Esize (Ent));
870 Write_Str ("'Alignment use ");
871 Write_Val (Alignment (Ent));
874 List_Linker_Section (Ent);
877 -- The type is relevant for an object
879 if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
880 Relevant_Entities.Set (Etype (Ent), True);
882 end List_Object_Info;
884 ----------------------
885 -- List_Record_Info --
886 ----------------------
888 procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
889 procedure Compute_Max_Length
891 Starting_Position : Uint := Uint_0;
892 Starting_First_Bit : Uint := Uint_0;
893 Prefix_Length : Natural := 0);
894 -- Internal recursive procedure to compute the max length
896 procedure List_Component_Layout
898 Starting_Position : Uint := Uint_0;
899 Starting_First_Bit : Uint := Uint_0;
900 Prefix : String := "";
901 Indent : Natural := 0);
902 -- Procedure to display the layout of a single component
904 procedure List_Record_Layout
906 Starting_Position : Uint := Uint_0;
907 Starting_First_Bit : Uint := Uint_0;
908 Prefix : String := "");
909 -- Internal recursive procedure to display the layout
911 procedure List_Structural_Record_Layout
913 Outer_Ent : Entity_Id;
914 Variant : Node_Id := Empty;
915 Indent : Natural := 0);
916 -- Internal recursive procedure to display the structural layout
918 Incomplete_Layout : exception;
919 -- Exception raised if the layout is incomplete in -gnatc mode
921 Not_In_Extended_Main : exception;
922 -- Exception raised when an ancestor is not declared in the main unit
924 Max_Name_Length : Natural := 0;
925 Max_Spos_Length : Natural := 0;
927 ------------------------
928 -- Compute_Max_Length --
929 ------------------------
931 procedure Compute_Max_Length
933 Starting_Position : Uint := Uint_0;
934 Starting_First_Bit : Uint := Uint_0;
935 Prefix_Length : Natural := 0)
940 Comp := First_Component_Or_Discriminant (Ent);
941 while Present (Comp) loop
943 -- Skip a completely hidden discriminant or a discriminant in an
944 -- unchecked union (since it is not there).
946 if Ekind (Comp) = E_Discriminant
947 and then (Is_Completely_Hidden (Comp)
948 or else Is_Unchecked_Union (Ent))
953 -- Skip _Parent component in extension (to avoid overlap)
955 if Chars (Comp) = Name_uParent then
962 Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
963 Bofs : constant Uint := Component_Bit_Offset (Comp);
969 Name_Length : Natural;
972 Get_Decoded_Name_String (Chars (Comp));
973 Name_Length := Prefix_Length + Name_Len;
975 if Rep_Not_Constant (Bofs) then
977 -- If the record is not packed, then we know that all fields
978 -- whose position is not specified have starting normalized
979 -- bit position of zero.
981 if Unknown_Normalized_First_Bit (Comp)
982 and then not Is_Packed (Ent)
984 Set_Normalized_First_Bit (Comp, Uint_0);
987 UI_Image_Length := 2; -- For "??" marker
990 Fbit := Bofs mod SSU;
992 -- Complete annotation in case not done
994 if Unknown_Normalized_First_Bit (Comp) then
995 Set_Normalized_Position (Comp, Npos);
996 Set_Normalized_First_Bit (Comp, Fbit);
999 Spos := Starting_Position + Npos;
1000 Sbit := Starting_First_Bit + Fbit;
1007 -- If extended information is requested, recurse fully into
1008 -- record components, i.e. skip the outer level.
1010 if List_Representation_Info_Extended
1011 and then Is_Record_Type (Ctyp)
1013 Compute_Max_Length (Ctyp, Spos, Sbit, Name_Length + 1);
1020 Max_Name_Length := Natural'Max (Max_Name_Length, Name_Length);
1022 Natural'Max (Max_Spos_Length, UI_Image_Length);
1026 Next_Component_Or_Discriminant (Comp);
1028 end Compute_Max_Length;
1030 ---------------------------
1031 -- List_Component_Layout --
1032 ---------------------------
1034 procedure List_Component_Layout
1036 Starting_Position : Uint := Uint_0;
1037 Starting_First_Bit : Uint := Uint_0;
1038 Prefix : String := "";
1039 Indent : Natural := 0)
1041 Esiz : constant Uint := Esize (Ent);
1042 Npos : constant Uint := Normalized_Position (Ent);
1043 Fbit : constant Uint := Normalized_First_Bit (Ent);
1049 if List_Representation_Info_To_JSON then
1053 Write_Str (" ""name"": """);
1055 Write_Str (Name_Buffer (1 .. Name_Len));
1057 if Ekind (Ent) = E_Discriminant then
1059 Write_Str (" ""discriminant"": ");
1060 UI_Write (Discriminant_Number (Ent), Decimal);
1064 Write_Str (" ""Position"": ");
1068 Write_Str (Name_Buffer (1 .. Name_Len));
1069 Spaces (Max_Name_Length - Prefix'Length - Name_Len);
1073 if Known_Static_Normalized_Position (Ent) then
1074 Spos := Starting_Position + Npos;
1075 Sbit := Starting_First_Bit + Fbit;
1082 Spaces (Max_Spos_Length - UI_Image_Length);
1083 Write_Str (UI_Image_Buffer (1 .. UI_Image_Length));
1085 elsif Known_Normalized_Position (Ent)
1086 and then List_Representation_Info >= 3
1088 Spaces (Max_Spos_Length - 2);
1090 if Starting_Position /= Uint_0 then
1091 UI_Write (Starting_Position, Decimal);
1101 if List_Representation_Info_To_JSON then
1104 Write_Str (" ""First_Bit"": ");
1106 Write_Str (" range ");
1109 Sbit := Starting_First_Bit + Fbit;
1115 UI_Write (Sbit, Decimal);
1117 if List_Representation_Info_To_JSON then
1120 Write_Str (" ""Size"": ");
1125 -- Allowing Uint_0 here is an annoying special case. Really this
1126 -- should be a fine Esize value but currently it means unknown,
1127 -- except that we know after gigi has back annotated that a size
1128 -- of zero is real, since otherwise gigi back annotates using
1129 -- No_Uint as the value to indicate unknown.
1131 if (Esize (Ent) = Uint_0 or else Known_Static_Esize (Ent))
1132 and then Known_Static_Normalized_First_Bit (Ent)
1134 Lbit := Sbit + Esiz - 1;
1136 if List_Representation_Info_To_JSON then
1137 UI_Write (Esiz, Decimal);
1139 if Lbit >= 0 and then Lbit < 10 then
1143 UI_Write (Lbit, Decimal);
1146 -- The test for Esize (Ent) not Uint_0 here is an annoying special
1147 -- case. Officially a value of zero for Esize means unknown, but
1148 -- here we use the fact that we know that gigi annotates Esize with
1149 -- No_Uint, not Uint_0. Really everyone should use No_Uint???
1151 elsif List_Representation_Info < 3
1152 or else (Esize (Ent) /= Uint_0 and then Unknown_Esize (Ent))
1156 -- List_Representation >= 3 and Known_Esize (Ent)
1159 Write_Val (Esiz, Paren => not List_Representation_Info_To_JSON);
1161 -- Add appropriate first bit offset
1163 if not List_Representation_Info_To_JSON then
1172 Write_Int (UI_To_Int (Sbit) - 1);
1177 if List_Representation_Info_To_JSON then
1185 -- The type is relevant for a component
1187 if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
1188 Relevant_Entities.Set (Etype (Ent), True);
1190 end List_Component_Layout;
1192 ------------------------
1193 -- List_Record_Layout --
1194 ------------------------
1196 procedure List_Record_Layout
1198 Starting_Position : Uint := Uint_0;
1199 Starting_First_Bit : Uint := Uint_0;
1200 Prefix : String := "")
1203 First : Boolean := True;
1206 Comp := First_Component_Or_Discriminant (Ent);
1207 while Present (Comp) loop
1209 -- Skip a completely hidden discriminant or a discriminant in an
1210 -- unchecked union (since it is not there).
1212 if Ekind (Comp) = E_Discriminant
1213 and then (Is_Completely_Hidden (Comp)
1214 or else Is_Unchecked_Union (Ent))
1219 -- Skip _Parent component in extension (to avoid overlap)
1221 if Chars (Comp) = Name_uParent then
1228 Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
1229 Npos : constant Uint := Normalized_Position (Comp);
1230 Fbit : constant Uint := Normalized_First_Bit (Comp);
1235 Get_Decoded_Name_String (Chars (Comp));
1236 Set_Casing (Unit_Casing);
1238 -- If extended information is requested, recurse fully into
1239 -- record components, i.e. skip the outer level.
1241 if List_Representation_Info_Extended
1242 and then Is_Record_Type (Ctyp)
1243 and then Known_Static_Normalized_Position (Comp)
1244 and then Known_Static_Normalized_First_Bit (Comp)
1246 Spos := Starting_Position + Npos;
1247 Sbit := Starting_First_Bit + Fbit;
1254 List_Record_Layout (Ctyp,
1255 Spos, Sbit, Prefix & Name_Buffer (1 .. Name_Len) & ".");
1260 if List_Representation_Info_To_JSON then
1269 List_Component_Layout (Comp,
1270 Starting_Position, Starting_First_Bit, Prefix);
1274 Next_Component_Or_Discriminant (Comp);
1276 end List_Record_Layout;
1278 -----------------------------------
1279 -- List_Structural_Record_Layout --
1280 -----------------------------------
1282 procedure List_Structural_Record_Layout
1284 Outer_Ent : Entity_Id;
1285 Variant : Node_Id := Empty;
1286 Indent : Natural := 0)
1288 function Derived_Discriminant (Disc : Entity_Id) return Entity_Id;
1289 -- This function assumes that Outer_Ent is an extension of Ent.
1290 -- Disc is a discriminant of Ent that does not itself constrain a
1291 -- discriminant of the parent type of Ent. Return the discriminant
1292 -- of Outer_Ent that ultimately constrains Disc, if any.
1294 ----------------------------
1295 -- Derived_Discriminant --
1296 ----------------------------
1298 function Derived_Discriminant (Disc : Entity_Id) return Entity_Id is
1299 Corr_Disc : Entity_Id;
1300 Derived_Disc : Entity_Id;
1303 Derived_Disc := First_Discriminant (Outer_Ent);
1305 -- Loop over the discriminants of the extension
1307 while Present (Derived_Disc) loop
1309 -- Check if this discriminant constrains another discriminant.
1310 -- If so, find the ultimately constrained discriminant and
1311 -- compare with the original components in the base type.
1313 if Present (Corresponding_Discriminant (Derived_Disc)) then
1314 Corr_Disc := Corresponding_Discriminant (Derived_Disc);
1316 while Present (Corresponding_Discriminant (Corr_Disc)) loop
1317 Corr_Disc := Corresponding_Discriminant (Corr_Disc);
1320 if Original_Record_Component (Corr_Disc) =
1321 Original_Record_Component (Disc)
1323 return Derived_Disc;
1327 Next_Discriminant (Derived_Disc);
1330 -- Disc is not constrained by a discriminant of Outer_Ent
1333 end Derived_Discriminant;
1335 -- Local declarations
1338 Comp_List : Node_Id;
1339 First : Boolean := True;
1342 -- Start of processing for List_Structural_Record_Layout
1345 -- If we are dealing with a variant, just process the components
1347 if Present (Variant) then
1348 Comp_List := Component_List (Variant);
1350 -- Otherwise, we are dealing with the full record and need to get
1351 -- to its definition in order to retrieve its structural layout.
1355 Definition : Node_Id :=
1356 Type_Definition (Declaration_Node (Ent));
1358 Is_Extension : constant Boolean :=
1359 Is_Tagged_Type (Ent)
1360 and then Nkind (Definition) =
1361 N_Derived_Type_Definition;
1364 Listed_Disc : Entity_Id;
1365 Parent_Type : Entity_Id;
1368 -- If this is an extension, first list the layout of the parent
1369 -- and then proceed to the extension part, if any.
1371 if Is_Extension then
1372 Parent_Type := Parent_Subtype (Ent);
1373 if No (Parent_Type) then
1374 raise Incomplete_Layout;
1377 if Is_Private_Type (Parent_Type) then
1378 Parent_Type := Full_View (Parent_Type);
1379 pragma Assert (Present (Parent_Type));
1382 Parent_Type := Base_Type (Parent_Type);
1383 if not In_Extended_Main_Source_Unit (Parent_Type) then
1384 raise Not_In_Extended_Main;
1387 List_Structural_Record_Layout (Parent_Type, Outer_Ent);
1390 if Present (Record_Extension_Part (Definition)) then
1391 Definition := Record_Extension_Part (Definition);
1395 -- If the record has discriminants and is not an unchecked
1396 -- union, then display them now. Note that, even if this is
1397 -- a structural layout, we list the visible discriminants.
1399 if Has_Discriminants (Ent)
1400 and then not Is_Unchecked_Union (Ent)
1402 Disc := First_Discriminant (Ent);
1403 while Present (Disc) loop
1405 -- If this is a record extension and the discriminant is
1406 -- the renaming of another discriminant, skip it.
1409 and then Present (Corresponding_Discriminant (Disc))
1414 -- If this is the parent type of an extension, retrieve
1415 -- the derived discriminant from the extension, if any.
1417 if Ent /= Outer_Ent then
1418 Listed_Disc := Derived_Discriminant (Disc);
1420 if No (Listed_Disc) then
1424 Listed_Disc := Disc;
1427 Get_Decoded_Name_String (Chars (Listed_Disc));
1428 Set_Casing (Unit_Casing);
1437 List_Component_Layout (Listed_Disc, Indent => Indent);
1440 Next_Discriminant (Disc);
1444 Comp_List := Component_List (Definition);
1448 -- Bail out for the null record
1450 if No (Comp_List) then
1454 -- Now deal with the regular components, if any
1456 if Present (Component_Items (Comp_List)) then
1457 Comp := First_Non_Pragma (Component_Items (Comp_List));
1458 while Present (Comp) loop
1460 -- Skip _Parent component in extension (to avoid overlap)
1462 if Chars (Defining_Identifier (Comp)) = Name_uParent then
1466 Get_Decoded_Name_String (Chars (Defining_Identifier (Comp)));
1467 Set_Casing (Unit_Casing);
1476 List_Component_Layout
1477 (Defining_Identifier (Comp), Indent => Indent);
1480 Next_Non_Pragma (Comp);
1484 -- We are done if there is no variant part
1486 if No (Variant_Part (Comp_List)) then
1494 Write_Str (" ""variant"" : [");
1496 -- Otherwise we recurse on each variant
1498 Var := First_Non_Pragma (Variants (Variant_Part (Comp_List)));
1500 while Present (Var) loop
1511 Write_Str (" ""present"": ");
1512 Write_Val (Present_Expr (Var));
1515 Write_Str (" ""record"": [");
1517 List_Structural_Record_Layout (Ent, Outer_Ent, Var, Indent + 4);
1524 Next_Non_Pragma (Var);
1526 end List_Structural_Record_Layout;
1528 -- Start of processing for List_Record_Info
1533 if List_Representation_Info_To_JSON then
1537 List_Common_Type_Info (Ent);
1539 -- First find out max line length and max starting position
1540 -- length, for the purpose of lining things up nicely.
1542 Compute_Max_Length (Ent);
1544 -- Then do actual output based on those values
1546 if List_Representation_Info_To_JSON then
1548 Write_Str (" ""record"": [");
1550 -- ??? We can output structural layout only for base types fully
1551 -- declared in the extended main source unit for the time being,
1552 -- because otherwise declarations might not be processed at all.
1554 if Is_Base_Type (Ent) then
1556 List_Structural_Record_Layout (Ent, Ent);
1559 when Incomplete_Layout
1560 | Not_In_Extended_Main
1562 List_Record_Layout (Ent);
1565 raise Program_Error;
1568 List_Record_Layout (Ent);
1576 Write_Line (" use record");
1578 List_Record_Layout (Ent);
1580 Write_Line ("end record;");
1583 List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
1585 List_Linker_Section (Ent);
1587 if List_Representation_Info_To_JSON then
1592 -- The type is relevant for a record subtype
1594 if List_Representation_Info = 4
1595 and then not Is_Base_Type (Ent)
1596 and then Is_Itype (Etype (Ent))
1598 Relevant_Entities.Set (Etype (Ent), True);
1600 end List_Record_Info;
1606 procedure List_Rep_Info (Bytes_Big_Endian : Boolean) is
1610 if List_Representation_Info /= 0
1611 or else List_Representation_Info_Mechanisms
1613 -- For the normal case, we output a single JSON stream
1615 if not List_Representation_Info_To_File
1616 and then List_Representation_Info_To_JSON
1619 Need_Separator := False;
1622 for U in Main_Unit .. Last_Unit loop
1623 if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then
1624 Unit_Casing := Identifier_Casing (Source_Index (U));
1626 if List_Representation_Info = 4 then
1627 Relevant_Entities.Reset;
1630 -- Normal case, list to standard output
1632 if not List_Representation_Info_To_File then
1633 if not List_Representation_Info_To_JSON then
1635 Write_Str ("Representation information for unit ");
1636 Write_Unit_Name (Unit_Name (U));
1640 for J in 1 .. Col - 1 loop
1645 Need_Separator := True;
1648 List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
1650 -- List representation information to file
1653 Create_Repinfo_File_Access.all
1654 (Get_Name_String (File_Name (Source_Index (U))));
1655 Set_Special_Output (Write_Info_Line'Access);
1656 if List_Representation_Info_To_JSON then
1659 Need_Separator := False;
1660 List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
1661 if List_Representation_Info_To_JSON then
1664 Cancel_Special_Output;
1665 Close_Repinfo_File_Access.all;
1670 if not List_Representation_Info_To_File
1671 and then List_Representation_Info_To_JSON
1678 -------------------------------
1679 -- List_Scalar_Storage_Order --
1680 -------------------------------
1682 procedure List_Scalar_Storage_Order
1684 Bytes_Big_Endian : Boolean)
1686 procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean);
1687 -- Show attribute definition clause for Attr_Name (an endianness
1688 -- attribute), depending on whether or not the endianness is reversed
1689 -- compared to native endianness.
1695 procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean) is
1697 if List_Representation_Info_To_JSON then
1700 Write_Str (Attr_Name);
1701 Write_Str (""": ""System.");
1706 Write_Str (Attr_Name);
1707 Write_Str (" use System.");
1710 if Bytes_Big_Endian xor Is_Reversed then
1716 Write_Str ("_Order_First");
1717 if List_Representation_Info_To_JSON then
1724 List_SSO : constant Boolean :=
1725 Has_Rep_Item (Ent, Name_Scalar_Storage_Order)
1726 or else SSO_Set_Low_By_Default (Ent)
1727 or else SSO_Set_High_By_Default (Ent);
1728 -- Scalar_Storage_Order is displayed if specified explicitly or set by
1729 -- Default_Scalar_Storage_Order.
1731 -- Start of processing for List_Scalar_Storage_Order
1734 -- For record types, list Bit_Order if not default, or if SSO is shown
1736 -- Also, when -gnatR4 is in effect always list bit order and scalar
1737 -- storage order explicitly, so that you don't need to know the native
1738 -- endianness of the target for which the output was produced in order
1741 if Is_Record_Type (Ent)
1743 or else Reverse_Bit_Order (Ent)
1744 or else List_Representation_Info = 4)
1746 List_Attr ("Bit_Order", Reverse_Bit_Order (Ent));
1749 -- List SSO if required. If not, then storage is supposed to be in
1752 if List_SSO or else List_Representation_Info = 4 then
1753 List_Attr ("Scalar_Storage_Order", Reverse_Storage_Order (Ent));
1755 pragma Assert (not Reverse_Storage_Order (Ent));
1758 end List_Scalar_Storage_Order;
1760 --------------------------
1761 -- List_Subprogram_Info --
1762 --------------------------
1764 procedure List_Subprogram_Info (Ent : Entity_Id) is
1765 First : Boolean := True;
1772 if List_Representation_Info_To_JSON then
1774 Write_Str (" ""name"": """);
1777 List_Location (Ent);
1779 Write_Str (" ""Convention"": """);
1783 Write_Str ("function ");
1786 Write_Str ("operator ");
1789 Write_Str ("procedure ");
1791 when E_Subprogram_Type =>
1792 Write_Str ("type ");
1797 Write_Str ("entry ");
1800 raise Program_Error;
1804 Write_Str (" declared at ");
1805 Write_Location (Sloc (Ent));
1808 Write_Str ("convention : ");
1811 case Convention (Ent) is
1812 when Convention_Ada =>
1815 when Convention_Ada_Pass_By_Copy =>
1816 Write_Str ("Ada_Pass_By_Copy");
1818 when Convention_Ada_Pass_By_Reference =>
1819 Write_Str ("Ada_Pass_By_Reference");
1821 when Convention_Intrinsic =>
1822 Write_Str ("Intrinsic");
1824 when Convention_Entry =>
1825 Write_Str ("Entry");
1827 when Convention_Protected =>
1828 Write_Str ("Protected");
1830 when Convention_Assembler =>
1831 Write_Str ("Assembler");
1833 when Convention_C =>
1836 when Convention_C_Variadic =>
1839 Convention_Id'Pos (Convention (Ent)) -
1840 Convention_Id'Pos (Convention_C_Variadic_0);
1842 Write_Str ("C_Variadic_");
1847 pragma Assert (N < 10);
1848 Write_Char (Character'Val (Character'Pos ('0') + N));
1851 when Convention_COBOL =>
1852 Write_Str ("COBOL");
1854 when Convention_CPP =>
1857 when Convention_Fortran =>
1858 Write_Str ("Fortran");
1860 when Convention_Stdcall =>
1861 Write_Str ("Stdcall");
1863 when Convention_Stubbed =>
1864 Write_Str ("Stubbed");
1867 if List_Representation_Info_To_JSON then
1869 Write_Str (" ""formal"": [");
1874 -- Find max length of formal name
1877 Form := First_Formal (Ent);
1878 while Present (Form) loop
1879 Get_Unqualified_Decoded_Name_String (Chars (Form));
1881 if Name_Len > Plen then
1888 -- Output formals and mechanisms
1890 Form := First_Formal (Ent);
1891 while Present (Form) loop
1892 Get_Unqualified_Decoded_Name_String (Chars (Form));
1893 Set_Casing (Unit_Casing);
1895 if List_Representation_Info_To_JSON then
1904 Write_Str (" ""name"": """);
1905 Write_Str (Name_Buffer (1 .. Name_Len));
1908 Write_Str (" ""mechanism"": """);
1909 Write_Mechanism (Mechanism (Form));
1913 while Name_Len <= Plen loop
1914 Name_Len := Name_Len + 1;
1915 Name_Buffer (Name_Len) := ' ';
1919 Write_Str (Name_Buffer (1 .. Plen + 1));
1920 Write_Str (": passed by ");
1922 Write_Mechanism (Mechanism (Form));
1929 if List_Representation_Info_To_JSON then
1934 if Ekind (Ent) = E_Function then
1935 if List_Representation_Info_To_JSON then
1937 Write_Str (" ""mechanism"": """);
1938 Write_Mechanism (Mechanism (Ent));
1941 Write_Str ("returns by ");
1942 Write_Mechanism (Mechanism (Ent));
1947 if not Is_Entry (Ent) then
1948 List_Linker_Section (Ent);
1951 if List_Representation_Info_To_JSON then
1955 end List_Subprogram_Info;
1957 --------------------
1958 -- List_Type_Info --
1959 --------------------
1961 procedure List_Type_Info (Ent : Entity_Id) is
1965 if List_Representation_Info_To_JSON then
1969 List_Common_Type_Info (Ent);
1971 -- Special stuff for fixed-point
1973 if Is_Fixed_Point_Type (Ent) then
1975 -- Write small (always a static constant)
1977 if List_Representation_Info_To_JSON then
1979 Write_Str (" ""Small"": ");
1980 UR_Write (Small_Value (Ent));
1984 Write_Str ("'Small use ");
1985 UR_Write (Small_Value (Ent));
1989 -- Write range if static
1992 R : constant Node_Id := Scalar_Range (Ent);
1995 if Nkind (Low_Bound (R)) = N_Real_Literal
1997 Nkind (High_Bound (R)) = N_Real_Literal
1999 if List_Representation_Info_To_JSON then
2001 Write_Str (" ""Range"": [ ");
2002 UR_Write (Realval (Low_Bound (R)));
2004 UR_Write (Realval (High_Bound (R)));
2009 Write_Str ("'Range use ");
2010 UR_Write (Realval (Low_Bound (R)));
2012 UR_Write (Realval (High_Bound (R)));
2019 List_Linker_Section (Ent);
2021 if List_Representation_Info_To_JSON then
2027 ----------------------
2028 -- Rep_Not_Constant --
2029 ----------------------
2031 function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean is
2033 if Val = No_Uint or else Val < 0 then
2038 end Rep_Not_Constant;
2044 function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint is
2046 function B (Val : Boolean) return Uint;
2047 -- Returns Uint_0 for False, Uint_1 for True
2049 function T (Val : Node_Ref_Or_Val) return Boolean;
2050 -- Returns True for 0, False for any non-zero (i.e. True)
2052 function V (Val : Node_Ref_Or_Val) return Uint;
2053 -- Internal recursive routine to evaluate tree
2055 function W (Val : Uint) return Word;
2056 -- Convert Val to Word, assuming Val is always in the Int range. This
2057 -- is a helper function for the evaluation of bitwise expressions like
2058 -- Bit_And_Expr, for which there is no direct support in uintp. Uint
2059 -- values out of the Int range are expected to be seen in such
2060 -- expressions only with overflowing byte sizes around, introducing
2061 -- inherent unreliabilities in computations anyway.
2067 function B (Val : Boolean) return Uint is
2080 function T (Val : Node_Ref_Or_Val) return Boolean is
2093 function V (Val : Node_Ref_Or_Val) return Uint is
2102 Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
2107 if T (Node.Op1) then
2108 return V (Node.Op2);
2110 return V (Node.Op3);
2114 return V (Node.Op1) + V (Node.Op2);
2117 return V (Node.Op1) - V (Node.Op2);
2120 return V (Node.Op1) * V (Node.Op2);
2122 when Trunc_Div_Expr =>
2123 return V (Node.Op1) / V (Node.Op2);
2125 when Ceil_Div_Expr =>
2128 (V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
2130 when Floor_Div_Expr =>
2133 (V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
2135 when Trunc_Mod_Expr =>
2136 return V (Node.Op1) rem V (Node.Op2);
2138 when Floor_Mod_Expr =>
2139 return V (Node.Op1) mod V (Node.Op2);
2141 when Ceil_Mod_Expr =>
2144 Q := UR_Ceiling (L / UR_From_Uint (R));
2147 when Exact_Div_Expr =>
2148 return V (Node.Op1) / V (Node.Op2);
2151 return -V (Node.Op1);
2154 return UI_Min (V (Node.Op1), V (Node.Op2));
2157 return UI_Max (V (Node.Op1), V (Node.Op2));
2160 return UI_Abs (V (Node.Op1));
2162 when Truth_And_Expr =>
2163 return B (T (Node.Op1) and then T (Node.Op2));
2165 when Truth_Or_Expr =>
2166 return B (T (Node.Op1) or else T (Node.Op2));
2168 when Truth_Xor_Expr =>
2169 return B (T (Node.Op1) xor T (Node.Op2));
2171 when Truth_Not_Expr =>
2172 return B (not T (Node.Op1));
2174 when Bit_And_Expr =>
2177 return UI_From_Int (Int (W (L) and W (R)));
2180 return B (V (Node.Op1) < V (Node.Op2));
2183 return B (V (Node.Op1) <= V (Node.Op2));
2186 return B (V (Node.Op1) > V (Node.Op2));
2189 return B (V (Node.Op1) >= V (Node.Op2));
2192 return B (V (Node.Op1) = V (Node.Op2));
2195 return B (V (Node.Op1) /= V (Node.Op2));
2199 Sub : constant Int := UI_To_Int (Node.Op1);
2201 pragma Assert (Sub in D'Range);
2216 -- We use an unchecked conversion to map Int values to their Word
2217 -- bitwise equivalent, which we could not achieve with a normal type
2218 -- conversion for negative Ints. We want bitwise equivalents because W
2219 -- is used as a helper for bit operators like Bit_And_Expr, and can be
2220 -- called for negative Ints in the context of aligning expressions like
2221 -- X+Align & -Align.
2223 function W (Val : Uint) return Word is
2224 function To_Word is new Ada.Unchecked_Conversion (Int, Word);
2226 return To_Word (UI_To_Int (Val));
2229 -- Start of processing for Rep_Value
2232 if Val = No_Uint then
2244 procedure Spaces (N : Natural) is
2246 for J in 1 .. N loop
2251 ---------------------
2252 -- Write_Info_Line --
2253 ---------------------
2255 procedure Write_Info_Line (S : String) is
2257 Write_Repinfo_Line_Access.all (S (S'First .. S'Last - 1));
2258 end Write_Info_Line;
2260 ---------------------
2261 -- Write_Mechanism --
2262 ---------------------
2264 procedure Write_Mechanism (M : Mechanism_Type) is
2268 Write_Str ("default");
2274 Write_Str ("reference");
2277 raise Program_Error;
2279 end Write_Mechanism;
2281 ---------------------
2282 -- Write_Separator --
2283 ---------------------
2285 procedure Write_Separator is
2287 if Need_Separator then
2288 if List_Representation_Info_To_JSON then
2294 Need_Separator := True;
2296 end Write_Separator;
2298 -----------------------
2299 -- Write_Unknown_Val --
2300 -----------------------
2302 procedure Write_Unknown_Val is
2304 if List_Representation_Info_To_JSON then
2305 Write_Str ("""??""");
2309 end Write_Unknown_Val;
2315 procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is
2317 if Rep_Not_Constant (Val) then
2318 if List_Representation_Info < 3 or else Val = No_Uint then
2326 List_GCC_Expression (Val);
2334 UI_Write (Val, Decimal);