6.5. Miscellaneous
6.5.1. Libadalang.Lexer
This package provides types and primitives to split text streams into lists of tokens.
- type Lexer_Input
- Discriminants:
Kind (
Langkit_Support.Types.Lexer_Input_Kind) –
- Components:
Charset (
Ada.Strings.Unbounded.Unbounded_String) – Name of the charset to use in order to decode the input sourceRead_BOM (
Standard.Boolean) – Whether the lexer should look for an optional Byte Order MarkFilename (
GNATCOLL.VFS.Virtual_File) – Name of the file to readBytes (
Ada.Strings.Unbounded.Unbounded_String) – Source buffer to readText (
Unbounded_Text_Type) – Source buffer to read
Source buffer to read
- procedure Extract_Tokens (Input : Lexer_Input; With_Trivia : Standard.Boolean; TDH : Langkit_Support.Token_Data_Handlers.Token_Data_Handler; Diagnostics : Langkit_Support.Diagnostics.Diagnostics_Vectors.Vector)
Extract tokens out of the given
Inputand store them intoTDH.Raise a
Name_Errorexception if this involves reading a file that can not be open. Raise anUnknown_Charsetexception if the requested charset is unknown. Raise anInvalid_Inputexception if the source cannot be decoded using the givenCharset.
- function Is_Keyword (TDH : Langkit_Support.Token_Data_Handlers.Token_Data_Handler; Index : Langkit_Support.Token_Data_Handlers.Token_Or_Trivia_Index; Version : Language_Version) Standard.Boolean
Given an Ada language version, return whether a token is an Ada keyword.
Due to the way Libadalang works, every token added after Ada 83 is lexed as a regular identifier, and then treated specially by the parser in some circumstances (being akin to the notion of reserved word).
This function returns True for regular lexer keywords, as well as for those identifiers.
6.5.2. Libadalang.Iterators
This package provides an interface to iterate on nodes in parse trees and to look for node patterns.
First, as an alternative to Libadalang.Analysis.Traverse, you can
do:
declare
It : Traverse_Iterator'Class := Traverse (My_Unit.Root);
Node : Ada_Node;
begin
while It.Next (Node) loop
-- Process Node
end loop;
end;
Now, if you are exclusively looking for nodes whose text is either foo
or bar, you can replace the call to Traverse with the following:
Find (My_Unit.Root, Text_Is ("foo") or Text_Is ("bar"));
The Find-like functions below take as a second argument a predicate,
which is an object that can decide if a node should be processed or not.
This package provides several built-in predicates (Kind_Is,
Text_Is, etc.), then you can either define your own, derivating the
Ada_Node_Predicate_Interface type, or compose them using Ada’s boolean operators.
- package Ada_Node_Iterators is new Support.Iterators
package Ada_Node_Iterators is new Support.Iterators (Element_Type => Ada_Node, Element_Array => Ada_Node_Array);
- Instantiated generic package:
- type Traverse_Iterator
Iterator that yields nodes from a tree
- function Traverse (Root : Ada_Node'Class) Traverse_Iterator'Class
Return an iterator that yields all nodes under
Root(included) in a prefix DFS (depth first search) fashion.
- type Ada_Node_Predicate_Interface
Predicate on nodes.
Useful predicates often rely on values from some context, so predicates that are mere accesses to a function are not powerful enough. Having a full interface for this makes it possible to package both the predicate code and some data it needs.
Note that predicates are not thread-safe: make sure you don’t use a predicate from multiple threads, as they can contain caches.
- function Evaluate (P : Ada_Node_Predicate_Interface; N : Ada_Node) Standard.Boolean
Return the value of the predicate for the
Nnode
- package Ada_Node_Predicate_References is new GNATCOLL.Refcount.Shared_Pointers
package Ada_Node_Predicate_References is new GNATCOLL.Refcount.Shared_Pointers (Ada_Node_Predicate_Interface'Class);
- Instantiated generic package:
- type Ada_Node_Predicate
Ref-counted reference to a predicate
- function "not" (Predicate : Ada_Node_Predicate) Ada_Node_Predicate
Return a predicate that accepts only nodes that are not accepted by
Predicate.
- function "and" (Left, Right : Ada_Node_Predicate) Ada_Node_Predicate
Return a predicate that accepts only nodes that are accepted by both
LeftandRight.
- function "or" (Left, Right : Ada_Node_Predicate) Ada_Node_Predicate
Return a predicate that accepts only nodes that are accepted by
LeftorRight.
- function For_All (Predicates : Ada_Node_Predicate_Array) Ada_Node_Predicate
Return a predicate that accepts only nodes that are accepted by all given
Predicates.
- function For_Some (Predicates : Ada_Node_Predicate_Array) Ada_Node_Predicate
Return a predicate that accepts only nodes that are accepted by at least one of the given
Predicates.
- function For_All_Children (Predicate : Ada_Node_Predicate; Skip_Null : Standard.Boolean) Ada_Node_Predicate
Return a predicate that accepts only nodes for which
Predicateaccepts all children. UnlessSkip_Nullis false, this does not evaluate the predicate on null children.
- function For_Some_Children (Predicate : Ada_Node_Predicate; Skip_Null : Standard.Boolean) Ada_Node_Predicate
Return a predicate that accepts only nodes for which
Predicateaccepts at least one child. UnlessSkip_Nullis false, this does not evaluate the predicate on null children.
- function Child_With (Field : Struct_Member_Ref; Predicate : Ada_Node_Predicate) Ada_Node_Predicate
Return a predicate that accepts only nodes which have a child corresponding to the given field reference and for which this child is accepted by the given predicate.
Raise a
Precondition_FailureifFieldis not a valid node field reference.
- function Kind_Is (Kind : Ada_Node_Kind_Type) Ada_Node_Predicate
Return a predicate that accepts only nodes of the given
Kind
- function Kind_In (First, Last : Ada_Node_Kind_Type) Ada_Node_Predicate
Return a predicate that accepts only nodes whose kind is in First .. Last.
- function Text_Is (Text : Text_Type) Ada_Node_Predicate
Return a predicate that accepts only nodes that match the given
Text
- function Node_Is_Null () Ada_Node_Predicate
Return a predicate that accepts only null nodes
- function Decl_Defines (Name : Text_Type) Ada_Node_Predicate
Return a predicate that accepts only
Basic_Declnodes that define the givenName.
- function Xref_Is (Name : Defining_Name; Imprecise_Fallback : Standard.Boolean) Ada_Node_Predicate
Return a predicate that accepts only nodes whose
P_Gnat_Xrefproperty returnsName.
- type Ada_Node_Predicate_Array
- function Find (Root : Ada_Node'Class; Predicate : access function (N : Ada_Node) return Boolean) Traverse_Iterator'Class
Return an iterator that yields all nodes under
Root(included) that satisfy thePredicatepredicate.
- function Find (Root : Ada_Node'Class; Predicate : Ada_Node_Predicate'Class) Traverse_Iterator'Class
Return an iterator that yields all nodes under
Root(included) that satisfy thePredicatepredicate.
- function Find_First (Root : Ada_Node'Class; Predicate : access function (N : Ada_Node) return Boolean) Ada_Node
Return the first node found under
Root(included) that satisfies the givenPredicate. Return a null node if there is no such node.
- function Find_First (Root : Ada_Node'Class; Predicate : Ada_Node_Predicate'Class) Ada_Node
Return the first node found under
Root(included) that satisfies the givenPredicate. Return a null node if there is no such node.
6.5.3. Libadalang.Config_Pragmas
This package provides helpers to deal with GNAT’s configurations pragmas files.
- package Unit_Maps is new Ada.Containers.Hashed_Maps
package Unit_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Analysis_Unit, Element_Type => Analysis_Unit, Hash => Hash, Equivalent_Keys => "=");
- Instantiated generic package:
Map analysis unit to the local configuration pragmas file that applies to it.
- type Config_Pragmas_Mapping
- Components:
Local_Pragmas (
Libadalang.Config_Pragmas.Unit_Maps.Map) – Mappings that associate a local configuration pragmas file (element) to each analysis unit (key) for which it applies.Global_Pragmas (
Analysis_Unit) – Configuration pragmas file that applies to all analysis units, orNo_Analysis_Unitif there is no such file.
Configuration pragmas file that applies to all analysis units, or
No_Analysis_Unitif there is no such file.- procedure Set_Mapping (Context : Analysis_Context; Mapping : Config_Pragmas_Mapping)
Assign in
Contextconfiguration pragmas files to analysis units as described inMapping.This raises a
Precondition_Failureexception if:Contextis null;any analysis unit in
Mappingdoes not belong toContext;Local_Pragmashas aNo_Analysiskey or element.
- function Import_From_Project (Context : Analysis_Context; Project : GNATCOLL.Projects.Project_Tree'Class; Subproject : GNATCOLL.Projects.Project_Type) Config_Pragmas_Mapping
Load configuration pragmas files referenced in
Projectand its sub-projects and return a mapping that describes for each analysis unit owned byProjectwhich configuration pragmas files applies to it.If
Subprojectis notNo_Project, restrict the exploration of local configuration pragmas files to that project (global ones are still found in the root project).
- function Import_From_Project (Context : Analysis_Context; Tree : GPR2.Project.Tree.Object; View : GPR2.Project.View.Object) Config_Pragmas_Mapping
Load configuration pragmas files referenced in
Treeand its sub-projects and return a mapping that describes for each analysis unit owned byTreewhich configuration pragmas files applies to it.If
Viewis notUndefined, restrict the exploration of local configuration pragmas files to that project (global ones are still found in the root project).
- procedure Dump (Mapping : Config_Pragmas_Mapping)
Dump the content of
Mappingon the standard output
- procedure Import_From_Project (Context : Analysis_Context; Project : GNATCOLL.Projects.Project_Tree'Class; Subproject : GNATCOLL.Projects.Project_Type)
Shortcut for
Import_From_Project/Set_Mappingcalls
- procedure Import_From_Project (Context : Analysis_Context; Tree : GPR2.Project.Tree.Object; View : GPR2.Project.View.Object)
Shortcut for
Import_From_Project/Set_Mappingcalls
6.5.4. Libadalang.Expr_Eval
This package implements an expression evaluator for Libadalang. The aim is to allow at least evaluation of expressions that fit the definitions of static expression in the Ada Reference Manual.
- type Big_Integer
- type Rational
- type Double
- type Expr_Kind
- type Eval_Result
- Discriminants:
Kind (
Expr_Kind) –
- Components:
Expr_Type (
Base_Type_Decl) –Enum_Result (
Enum_Literal_Decl) –Int_Result (
Big_Integer) –Real_Result (
Rational) –String_Result (
Unbounded_Text_Type) – First and Last are used to keep track of the String objects bounds (this information is required to evaluate slices).First (
Standard.Natural) –Last (
Standard.Natural) –
- function As_Int (Self : Eval_Result) Big_Integer
Return the given evaluation result as an Integer, if applicable. This will work for enum or int results, not for real results.
- function As_String (Self : Eval_Result) Unbounded_Text_Type
Return the given evaluation result as a string, if applicable. This will only work for string results.
- function Image (Self : Eval_Result) Standard.String
Return a string representation of Self. Used for testing/debugging purposes.
- function Expr_Eval (E : Expr) Eval_Result
Evaluate the expression passed as parameter
- function Expr_Eval_In_Env (E : Expr; Env : Substitution_Array) Eval_Result
Evaluate the given expression in the context of the given environment
6.5.5. Libadalang.Data_Decomposition
This package provides routines to decompose composite program data into elementary components, and more generally to query the representation of program data.
Attention
This is an experimental feature, so even if it is exposed to allow experiments, it is totally unsupported and the API is very likely to change in the future.
Here is a small example of usage for this package:
-- Code that the program below analyzes, to be compiled with the
-- ``-gnatR4js`` option (``gcc -c pkg.ads -gnatR4js``) to generate the
-- ``pkg.ads.json`` file.
package Pkg is
type R (N : Natural) is record
case N is
when 0 .. 9 =>
B : Boolean;
when 100 .. 199 | 900 .. 999 =>
I : Integer;
when others =>
null;
end case;
end record;
end Pkg;
-- Corresponding project file
project P is
end P;
-- Program using the ``Libadalang.Data_Decomposition`` API to analyze
-- representation information.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Tree;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Data_Decomposition;
with Libadalang.Iterators; use Libadalang.Iterators;
with Libadalang.Project_Provider; use Libadalang.Project_Provider;
procedure Main is
package DDA renames Libadalang.Data_Decomposition;
-- Load the "p.gpr" project file, then create the unit provider (to
-- make Libadalang's name resolution work) and the representation
-- information collection for it.
Tree : GPR2.Project.Tree.Object;
Provider : Unit_Provider_Reference;
Collection : DDA.Repinfo_Collection;
begin
Tree.Load_Autoconf
(Filename => GPR2.Path_Name.Create_File
(Name => "p.gpr",
Directory => GPR2.Path_Name.No_Resolution),
Context => GPR2.Context.Empty);
Provider := Create_Project_Unit_Provider (Tree);
Collection := DDA.Load_From_Project (Tree);
declare
-- Analyze the "pkg.ads" source file
Ctx : constant Analysis_Context := Create_Context;
U : constant Analysis_Unit := Ctx.Get_From_File ("pkg.ads");
-- Look for the first type declaration in "pkg.ads"
function Filter (Node : Ada_Node) return Boolean
is (Node.Kind in Ada_Base_Type_Decl);
Decl : constant Base_Type_Decl :=
Find_First (U.Root, Filter'Access).As_Base_Type_Decl;
-- Fetch type representation information
TR : constant DDA.Type_Representation :=
Collection.Lookup (Decl);
-- Resolve the layout for this record type for a specific
-- set of discriminants (N = 950).
Discs : constant DDA.Discriminant_Values :=
(1 => Make ("950"));
RR : constant DDA.Resolved_Record_Type :=
DDA.Resolved_Record (TR, Discs);
begin
-- Display the size of this record (in bits) as well as the name
-- and position (in bytes) for each component.
Put_Line ("Record size:" & RR.Value_Size'Image);
for C of RR.Components loop
Put_Line ("Component " & C.Declaration.Image
& " at position" & C.Position'Image);
end loop;
end;
end Main;
Expected output:
Record size: 64
Component <DefiningName "N" pkg.ads:2:12-2:13> at position 0
Component <DefiningName "I" pkg.ads:7:13-7:14> at position 4
- type Numerical_Expression
Expression that, when evaluated, returns an integer (arbitrary precision).
This data type is used to represent dynamic attributes, such as the size of a discriminated record type, which depends on the specific values for its discriminants.
Each numerical expression requires a specific number of integer parameters to be evaluated, each integer corresponding to a record discriminant. See the
Discriminant_CountandEvaluateprimitives below.Note that for record types, the
Resolved_Recordfunction below resolves all attributes/components at once for a given record type given values for its discriminants. This may be more convenient than going through the evaluation of numerical expressions manually.- No_Numerical_Expression : constant Numerical_Expression
- Object type:
- function Is_Null (Self : Numerical_Expression) Standard.Boolean
- function Discriminant_Count (Self : Numerical_Expression) Standard.Natural
Return the number of discriminants needed to evaluate this expression
- function Evaluate (Self : Numerical_Expression; Discriminants : Discriminant_Values) GNATCOLL.GMP.Integers.Big_Integer
Evaluate a numerical expression given specific values for all required discriminants.
Note that more discriminants than required are accepted: the evaluation of the attribute of a component for a record with 2 discriminants may need only the first discriminant that record has
- Unsupported_Expression: exception
Exception raised in a function that returns
Numerical_Expressionwhen the expression is unsupported. For now, this happens only when the expression depends on dynamic variables that are not discriminants.
- type Type_Kind
- type Elementary_Type
- type Scalar_Type
- type Discrete_Type
- type Integer_Type
- type Real_Type
- type Fixed_Type
- type Composite_Type
- type Type_Representation
Representation information for a given type
- No_Type_Representation : constant Type_Representation
- Object type:
- function Is_Null (Self : Type_Representation) Standard.Boolean
- function Kind (Self : Type_Representation) Type_Kind
Return the kind of type
Selfis
- function Alignment (Self : Type_Representation) Standard.Positive
Alignment for values of this type, in bytes
- function Object_Size (Self : Type_Representation) Numerical_Expression
Number of bits used to hold objects whose type is
Self(See GNAT RM 9.6. Value_Size and Object_Size Clauses).
- function Value_Size (Self : Type_Representation) Numerical_Expression
Number of bits required to represent a value whose type is
Self. This corresponds to the RM defined'Sizeattribute (See GNAT RM 9.6. Value_Size and Object_Size Clauses).
- function Scalar_Storage_Order (Self : Type_Representation) System.Bit_Order
Byte order for scalars stored in this compound type
- function Components (Self : Type_Representation) Component_Representation_Array
List of components for this record, excluding components from the variant part (if any).
- function Discriminants (Self : Type_Representation) Component_Representation_Array
Subset of components for this record that are discriminants
- function Has_Variant_Part (Self : Type_Representation) Standard.Boolean
Whether this record type has a variant part
- function Variants (Self : Type_Representation) Variant_Representation_Array
Assuming this record type has a variant part, return all variants for it
- function Bit_Order (Self : Type_Representation) System.Bit_Order
Order for bit numbering in this record type
- function Component_Size (Self : Type_Representation) Numerical_Expression
Expression that evaluates to the size (in bits) for each array component.
- function Small (Self : Type_Representation) GNATCOLL.GMP.Rational_Numbers.Rational
Return the “small” number for a fixed point type. This is a positive real number, and all values for this fixed point type are multiples of this “small” number.
- function Range_First (Self : Type_Representation) GNATCOLL.GMP.Rational_Numbers.Rational
Lower bound for the mandatory range of a fixed point type
- function Range_Last (Self : Type_Representation) GNATCOLL.GMP.Rational_Numbers.Rational
Upper bound for the mandatory range of a fixed point type
- function Resolved_Record (Self : Type_Representation; Discriminants : Discriminant_Values) Resolved_Record_Type
Resolve all components in record type
Selfaccording to the values of its discriminants.Raise a
Resolution_Errorwhen resolution for the given discriminants yields nonsensical sizes or positions (usually because the discriminants are invalid).
- type Component_Representation
Representation information for a given record component
- No_Component_Representation : constant Component_Representation
- Object type:
- function Is_Null (Self : Component_Representation) Standard.Boolean
- function Declaration (Self : Component_Representation) Defining_Name
Declaration for this component. This returns
No_Defining_Namefor artificial components, i.e. components not defined in the source, but introduced by the compiler (for instance the tag for tagged types).
- function Component_Name (Self : Component_Representation) Text_Type
Name for this component. The casing of the result is not specified. This is useful as a complement to the
Declarationfunction above for artificial components, which have no declaration.
- function Discriminant_Number (Self : Component_Representation) Standard.Natural
0 if this component is not a discriminant. Positive number that uniquely identifies this discriminant in the record type otherwise.
- function Position (Self : Component_Representation) Numerical_Expression
Expression that evaluates to the index of first byte in the record that is used to represent this component.
- function First_Bit (Self : Component_Representation) Standard.Natural
First bit in the byte at
Positionthat is used to represent this component.
- function Size (Self : Component_Representation) Numerical_Expression
Size (in bits) for this component
- type Variant_Representation
Representation information for a given record variant (or “variant part alternative”).
- No_Variant_Representation : constant Variant_Representation
- Object type:
- function Is_Null (Self : Variant_Representation) Standard.Boolean
- function Present (Self : Variant_Representation) Numerical_Expression
Expression that evaluates to non-zero when the compoments of the variant are contained in the record type, and to zero when they are not.
- function Components (Self : Variant_Representation) Component_Representation_Array
Components for this variant, excluding components from the sub-variant (if any).
- function Has_Subvariant_Part (Self : Variant_Representation) Standard.Boolean
Whether this variant has a sub-variant part
- function Subvariants (Self : Variant_Representation) Variant_Representation_Array
Assuming this variant has a sub-variant part, return all sub-variants for it.
- type Component_Representation_Array
- type Variant_Representation_Array
- Type_Mismatch_Error: exception
Exception raised when an inconsistency is detected between type representation information and type declarations as found in the sources.
- type Discriminant_Values
Actual values for all the discriminants in a record type.
For discriminants that are integers, the value must be the corresponding number. For discriminants that are enumerations, the value must be the code used to represent the enumeration literal (i.e. the equivalent of GNAT’s
Enum_Repattribute). TheDiscriminant_Valuefunction below can be used to turn a discriminant value into the expected integer value.- No_Discriminant_Value : constant Discriminant_Values
- Object type:
- Default value:
(1 .. 0 => <>)
- Invalid_Discriminant: exception
See the
Discriminant_Valuefunction
- function Discriminant_Value (Result : Eval_Result) GNATCOLL.GMP.Integers.Big_Integer
Return the discriminant value corresponding to the given evaluated static expression. Raise an
Invalid_Discriminantexception ifResultis not an enum literal nor an integer.
- type Size_Type
Number of bits or bytes to denote the size of an object in memory.
Note that the range for this type may change in the future, for instance if Ada ever gets ported to a 128-bit architecture.
- type Resolved_Component
- Components:
Declaration (
Defining_Name) – Declaration for this componentArtificial_Name (
Unbounded_Text_Type) – IfDeclarationis null (i.e. if this describes an artificial component), name for that component. The casing is not specified.Position (
Size_Type) – See the correspondingComponent_RepresentationprimitiveFirst_Bit (
Standard.Natural) – See the correspondingComponent_RepresentationprimitiveSize (
Size_Type) – See the correspondingComponent_Representationprimitive
See the corresponding
Component_Representationprimitive
- type Resolved_Component_Array
- type Resolved_Record_Type
- Discriminants:
Component_Count (
Standard.Natural) –
- Components:
Alignment (
Standard.Positive) – See the correspondingType_RepresentationprimitiveObject_Size (
Size_Type) – See the correspondingType_RepresentationprimitiveValue_Size (
Size_Type) – See the correspondingType_RepresentationprimitiveBit_Order (
System.Bit_Order) – See the correspondingType_RepresentationprimitiveScalar_Storage_Order (
System.Bit_Order) – See the correspondingType_RepresentationprimitiveComponents (
Resolved_Component_Array) – See the correspondingType_Representationprimitive
See the corresponding
Type_Representationprimitive
- Resolution_Error: exception
See the
Resolved_Recordfunction
- type Repinfo_Collection
Collection of compiler-generated representation information
- function Lookup (Self : Repinfo_Collection; Decl : Base_Type_Decl'Class) Type_Representation
Look for the type representation corresponding to the given type declaration. Return
No_Type_Representationif nothing inSelfmatchesType_Name, and raise aType_Mismatch_Errorif an inconsistency is found betweenDecland the type representation found for it.
- function Load_From_Directory (Name_Pattern : System.Regexp.Regexp; Directory : Standard.String) Repinfo_Collection
Like
Load, but using automatically loading all files whose name matchesName_Patternin the givenDirectory.
- function Load_From_Project (Tree : GPR2.Project.Tree.Object; View : GPR2.Project.View.Object; Subdirs : Standard.String; Force : Standard.Boolean) Repinfo_Collection
Run GPRbuild on the given project
Treeto compile all of its Ada units with the-gnatR4jscompiler switch, then load all generated JSON files for units under theViewsub-project.Unless left to empty strings, the following formals are passed to
gprbuild’s command line:Subdirsis passed as--subdirs.
If
ForceisTrue, pass-fto gprbuild to force the build of compilation units.Raise a
Gprbuild_Errorexception ifgprbuildexits with a non-zero status code. Raise aLoading_Errorexception if the loading of JSON files fails.
- Loading_Error: exception
Exception raised when an error occurs while loading a collection of representation information.
- type Filename_Array
- function Load (Filenames : Filename_Array) Repinfo_Collection
Load type representation information from all the given
Filenamesand return the corresponding collection.All files are supposed to be generated running GNAT on compilation units with the
-gnatR4jsswitch.Raise a
Loading_Errorexception if unsuccessful.
- function Load_From_Directories (Name_Pattern : System.Regexp.Regexp; Directories : Filename_Array) Repinfo_Collection
Like
Load, but using automatically loading all files in any of the givenDirectorieswhose file name matchesName_Pattern.
- Default_JSON_Filename_Regexp : constant GNAT.Regexp.Regexp
- Object type:
System.Regexp.Regexp- Default value:
GNAT.Regexp.Compile (".*\.(ad.|a|spc|bdy)\.json")
Default matcher for JSON files created by the -gnatR4js compiler switch. It matches the JSON files created for Ada sources using the most usual file extensions:
.ads,.adb,.ada,.spc,.bdy, etc.
- Gprbuild_Error: exception
See
Load_From_Project
6.5.6. Libadalang.Target_Info
This package provides support for GNAT’s target dependent information files
(see GNAT’s -gnatet and gnateT switches).
- type Float_Representation
- type Digits_Type
Number of digits supported in a floating point type
- type Floating_Point_Type_Information
- Discriminants:
Present (
Standard.Boolean) –
- Components:
Digs (
Digits_Type) – Number of digits for the floating-point typeRepresentation (
Float_Representation) – Machine representation for the floating-point typeSize (
Standard.Positive) – Size in bits for the floating-point typeAlignment (
Standard.Natural) – Alignment for the floating-point type
Alignment for the floating-point type
- Absent_Floating_Point_Type_Info : constant Floating_Point_Type_Information
- Object type:
- Default value:
(Present => False)
- function Ada_Type_Definition (Self : Present_Floating_Point_Type_Information) Text_Type
Return Ada code excerpt that can be used to define a floating point type with the given characteristics.
- type Present_Floating_Point_Type_Information
- Discriminants:
Present (
Standard.Boolean) –
- Components:
Digs (
Digits_Type) – Number of digits for the floating-point typeRepresentation (
Float_Representation) – Machine representation for the floating-point typeSize (
Standard.Positive) – Size in bits for the floating-point typeAlignment (
Standard.Natural) – Alignment for the floating-point type
Alignment for the floating-point type
- type Floating_Point_Type_Id
List of all the floating-point types that can be described in a Target_Information record.
- function C_Name (Self : Floating_Point_Type_Id) Standard.String
- type Mandatory_Floating_Point_Type_Id
Floating-point type that are required in a target information file
- type Floating_Point_Types_Information
- type Target_Information
- Components:
Bits_BE (
Standard.Boolean) – Bits stored big-endian?Bits_Per_Unit (
Standard.Positive) – Bits in a storage unitBits_Per_Word (
Standard.Positive) – Bits in a wordBytes_BE (
Standard.Boolean) – Bytes stored big-endian?Char_Size (
Standard.Positive) – Standard.Character’SizeDouble_Float_Alignment (
Standard.Natural) – Alignment of double floatDouble_Scalar_Alignment (
Standard.Natural) – Alignment of double length scalarDouble_Size (
Standard.Positive) – Standard.Long_Float’SizeFloat_Size (
Standard.Positive) – Standard.Float’SizeFloat_Words_BE (
Standard.Boolean) – Float words stored big-endian?Int_Size (
Standard.Positive) – Standard.Integer’SizeLong_Double_Size (
Standard.Positive) – Standard.Long_Long_Float’SizeLong_Long_Long_Size (
Standard.Positive) – Standard.Long_Long_Long_Integer’SizeLong_Long_Size (
Standard.Positive) – Standard.Long_Long_Integer’SizeLong_Size (
Standard.Positive) – Standard.Long_Integer’SizeMaximum_Alignment (
Standard.Positive) – Maximum permitted alignmentMax_Unaligned_Field (
Standard.Positive) – Maximum size for unaligned bit fieldPointer_Size (
Standard.Positive) – System.Address’SizeShort_Enums (
Standard.Boolean) – Foreign enums use short size?Short_Size (
Standard.Positive) – Standard.Short_Integer’SizeStrict_Alignment (
Standard.Boolean) – Strict alignment?System_Allocator_Alignment (
Standard.Natural) – Alignment for malloc callsWchar_T_Size (
Standard.Positive) – Interfaces.C.wchar_t’SizeWords_BE (
Standard.Boolean) – Words stored big-endian?Floating_Point_Types (
Floating_Point_Types_Information) – Information about floating-point types
Information about floating-point types
- Placeholder_Target_Info : constant Target_Information
- Object type:
- Default value:
(Bits_BE => False, Bits_Per_Unit => 8, Bits_Per_Word => 64, Bytes_BE => False, Char_Size => 8, Double_Float_Alignment => 0, Double_Scalar_Alignment => 0, Double_Size => 64, Float_Size => 32, Float_Words_BE => False, Int_Size => 32, Long_Double_Size => 128, Long_Long_Long_Size => 128, Long_Long_Size => 64, Long_Size => 64, Maximum_Alignment => 16, Max_Unaligned_Field => 1, Pointer_Size => 64, Short_Enums => False, Short_Size => 16, Strict_Alignment => False, System_Allocator_Alignment => 16, Wchar_T_Size => 32, Words_BE => False, Floating_Point_Types => (Float_Id => (Present => True, Digs => 6, Representation => IEEE_754_Binary, Size => 32, Alignment => 32), Double_Id => (Present => True, Digs => 15, Representation => IEEE_754_Binary, Size => 64, Alignment => 64), Long_Double_Id => (Present => True, Digs => 18, Representation => IEEE_754_Binary, Size => 80, Alignment => 128), BF_Id => Absent_Floating_Point_Type_Info, FPRX2_Id => Absent_Floating_Point_Type_Info, HF_Id => Absent_Floating_Point_Type_Info, IF_Id => Absent_Floating_Point_Type_Info, KF_Id => Absent_Floating_Point_Type_Info, RF_Id => Absent_Floating_Point_Type_Info, TF_Id => Absent_Floating_Point_Type_Info, XF_Id => Absent_Floating_Point_Type_Info))
Default target information to use when no specific values were provided. This is just a placeholder: actual values are not guaranteed to remain unchanged across versions.
- function Load (Filename : Standard.String) Target_Information
Read target information from
Filenameand return it. Raise anAda.IO_Exceptions.Name_ErrororAda.IO_Exceptions.Use_ErrorifFilenamecannot be read, and raise anLangkit_Support.Errors.Invalid_Inputexception if there is any trouble decoding it.
- procedure Dump (Self : Target_Information)
Debug helper: dump the infomation contained in
Selfto the standard output.