@@ -40,34 +40,97 @@ pub use formal_region::{
4040 RecordRegion ,
4141} ;
4242
43+ /// The kind of [AnyEnt].
44+ /// This contains relevant information obtained during analysis.
4345pub enum AnyEntKind < ' a > {
46+ /// An alias that references an external name.
4447 ExternalAlias {
48+ /// The class of the external object (can be constant, signal or variable)
49+ /// The type of the referenced external name.
4550 class : ExternalObjectClass ,
4651 type_mark : TypeEnt < ' a > ,
4752 } ,
53+ /// An alias that references an object.
4854 ObjectAlias {
55+ /// The named entity that this alias references
4956 base_object : ObjectEnt < ' a > ,
57+ /// The type of the base object
5058 type_mark : TypeEnt < ' a > ,
5159 } ,
60+ /// A file declared in a declarative region (i.e., an architecture body).
61+ /// The associated [Subtype] refers to the type of the file.
5262 File ( Subtype < ' a > ) ,
63+ /// A file declaration made in an interface (i.e., as part of subprogram arguments)
64+ /// The associated [TypeEnt] refers to the type of the file (as it was declared)
5365 InterfaceFile ( TypeEnt < ' a > ) ,
66+ /// A component declaration.
67+ /// The associated [Region] contains generics and ports
68+ /// declared in the component.
5469 Component ( Region < ' a > ) ,
70+ /// A custom attribute.
71+ /// The associated [TypeEnt] refers to the return type of the attribute.
5572 Attribute ( TypeEnt < ' a > ) ,
73+ /// An overloaded entity, i.e., an entity with potentially
74+ /// further entities that share the same name but other features to distinguish.
75+ /// A good example is a function. Two VHDL functions may exist that share
76+ /// the same name, but have a different signature and are hence different.
77+ /// The associated [Overloaded] enum contains more information about the
78+ /// actual entity.
79+ /// Overloaded entities are
80+ /// * Subprograms (both functions and procedures),
81+ /// * Enum literals
82+ /// * Aliases
5683 Overloaded ( Overloaded < ' a > ) ,
84+ /// A custom type. The associated [Type] references the
85+ /// actual type that was declared.
5786 Type ( Type < ' a > ) ,
87+ /// A record element.
88+ /// The associated [Subtype] references the actual type of the record.
5889 ElementDeclaration ( Subtype < ' a > ) ,
90+ /// A concurrent statement. The associated [Concurrent] data is a reference
91+ /// to the exact statement (i.e., block process or generate).
92+ /// Not all statements are handled at the moment, therefore the associated
93+ /// data is optional.
5994 Concurrent ( Option < Concurrent > ) ,
95+ /// A sequential statement. The associated [Sequential] data is a reference
96+ /// to the exact statement (i.e., loop, if or else statement).
97+ /// Not all statements are handled at the moment, therefore the associated
98+ /// data is optional.
6099 Sequential ( Option < Sequential > ) ,
100+ /// An object is a signal, constant, variable or shared variable.
101+ /// The `File` object is handled in the [AnyEntKind::File] kind.
102+ /// The associated object contains more information and data about the
103+ /// actual entity.
61104 Object ( Object < ' a > ) ,
105+ /// A loop parameter from a 'for generate' statement.
106+ /// loop, or a simple for loop.
107+ /// The type refers to the (inferred) type of the range of the loop.
108+ /// If it is `None`, the range expression is erroneous.
62109 LoopParameter ( Option < BaseType < ' a > > ) ,
110+ /// A literal of some physical type (e.g., time).
111+ /// The associated [TypeEnt] refers to the type of the literal.
63112 PhysicalLiteral ( TypeEnt < ' a > ) ,
113+ /// A constant, declared in a package, where the actual value is not given immediately.
114+ /// The actual value is defined in the associated package region.
115+ /// The associated [Subtype] data refers to the type of the constant.
64116 DeferredConstant ( Subtype < ' a > ) ,
117+ /// A VHDL library
65118 Library ,
119+ /// A design entity, such as a VHDL entity, an architecture
120+ /// or a package.
121+ /// The associated [Design] data contains more information about
122+ /// the individual named entity.
66123 Design ( Design < ' a > ) ,
124+ /// A VHDL 2019 View.
125+ /// The [Subtype] data is the type of the associated record.
67126 View ( Subtype < ' a > ) ,
68127}
69128
70129impl < ' a > AnyEntKind < ' a > {
130+ /// Creates an [AnyEntKind] that denotes a function declaration.
131+ /// # Arguments
132+ /// * `formals` - The formal arguments of the function
133+ /// * `return_type` - The return type of the function
71134 pub ( crate ) fn new_function_decl (
72135 formals : FormalRegion < ' a > ,
73136 return_type : TypeEnt < ' a > ,
@@ -78,14 +141,21 @@ impl<'a> AnyEntKind<'a> {
78141 ) ) )
79142 }
80143
144+ /// Creates an [AnyEntKind] that denotes a procedure declaration.
145+ /// In contrast to [Self::new_function_decl], procedures do not have a return type.
146+ ///
147+ /// # Arguments
148+ /// * `formals` - The formal arguments of the procedure
81149 pub ( crate ) fn new_procedure_decl ( formals : FormalRegion < ' a > ) -> AnyEntKind < ' a > {
82150 AnyEntKind :: Overloaded ( Overloaded :: SubprogramDecl ( Signature :: new ( formals, None ) ) )
83151 }
84152
153+ /// Returns whether this kind is a deferred constant.
85154 pub fn is_deferred_constant ( & self ) -> bool {
86155 matches ! ( self , AnyEntKind :: DeferredConstant ( ..) )
87156 }
88157
158+ /// Returns whether this kind is a constant that is not deferred.
89159 pub fn is_non_deferred_constant ( & self ) -> bool {
90160 matches ! (
91161 self ,
@@ -97,10 +167,12 @@ impl<'a> AnyEntKind<'a> {
97167 )
98168 }
99169
170+ /// Returns whether this kind refers to a protected type.
100171 pub fn is_protected_type ( & self ) -> bool {
101172 matches ! ( self , AnyEntKind :: Type ( Type :: Protected ( ..) ) )
102173 }
103174
175+ /// Returns whether this kind refers to any type declaration.
104176 pub fn is_type ( & self ) -> bool {
105177 matches ! ( self , AnyEntKind :: Type ( ..) )
106178 }
@@ -189,12 +261,20 @@ pub struct AnyEnt<'a> {
189261 pub parent : Option < EntRef < ' a > > ,
190262 pub related : Related < ' a > ,
191263 pub implicits : Vec < EntRef < ' a > > ,
192- /// The location where the declaration was made.
193- /// Builtin and implicit declaration will not have a source position.
264+ /// The name of the entity.
265+ /// This will be a [Designator::Identifier](Identifier) for 'common'
266+ /// named entities (such as functions, architectures, e.t.c.)
194267 pub designator : Designator ,
268+ /// contains more information about this named entity
195269 pub kind : AnyEntKind < ' a > ,
270+ /// The location where the declaration was made.
271+ /// Builtin and implicit declaration will not have a source position.
196272 pub decl_pos : Option < SrcPos > ,
273+ /// The whole textual span that this entity encompasses.
197274 pub src_span : TokenSpan ,
275+ /// Where this declaration was made.
276+ /// Builtin and implicit declaration will not have a source position.
277+ // This is here so that replacing `decl_pos` with a simple Token(span) is feasible later.
198278 pub source : Option < Source > ,
199279
200280 /// Custom attributes on this entity
0 commit comments