Skip to content

Commit 8b19b79

Browse files
committed
Add InterfaceObject data
1 parent c832a69 commit 8b19b79

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

vhdl_lang/src/analysis.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Copyright (c) 2019, Olof Kraigher olof.kraigher@gmail.com
66

7+
#[macro_use]
78
mod analyze;
89
mod concurrent;
910
mod declarative;

vhdl_lang/src/analysis/analyze.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ impl AnalysisError {
7272
}
7373
}
7474

75+
/// Converts an AnalysisResult to FatalNullResult
76+
macro_rules! ok_or_return {
77+
($result:ident, $diagnostics:ident) => {
78+
match $result {
79+
Ok(value) => value,
80+
Err(err) => {
81+
err.add_to($diagnostics)?;
82+
return Ok(());
83+
}
84+
}
85+
};
86+
}
87+
7588
pub(super) struct AnalyzeContext<'a> {
7689
root: &'a DesignRoot,
7790

vhdl_lang/src/analysis/declarative.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,26 @@ impl<'a> AnalyzeContext<'a> {
533533
);
534534
}
535535
InterfaceDeclaration::Object(ref mut object_decl) => {
536-
self.analyze_subtype_indication(
536+
let subtype = self.resolve_subtype_indication(
537537
region,
538538
&mut object_decl.subtype_indication,
539539
diagnostics,
540-
)?;
540+
);
541+
541542
if let Some(ref mut expression) = object_decl.expression {
542543
self.analyze_expression(region, expression, diagnostics)?
543544
}
545+
546+
let subtype = ok_or_return!(subtype, diagnostics);
547+
544548
region.add(
545549
&object_decl.ident,
546-
NamedEntityKind::InterfaceObject(object_decl.class),
550+
NamedEntityKind::InterfaceObject(InterfaceObject {
551+
class: object_decl.class,
552+
mode: object_decl.mode,
553+
subtype,
554+
has_default: object_decl.expression.is_some(),
555+
}),
547556
diagnostics,
548557
);
549558
}

vhdl_lang/src/analysis/named_entity.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum NamedEntityKind {
2626
InterfaceType,
2727
Label,
2828
Object(ObjectClass),
29-
InterfaceObject(ObjectClass),
29+
InterfaceObject(InterfaceObject),
3030
PhysicalLiteral,
3131
DeferredConstant,
3232
// The region of the protected type which needs to be extendend by the body
@@ -91,7 +91,7 @@ impl NamedEntityKind {
9191
InterfaceType => "type",
9292
Label => "label",
9393
Object(class) => class.describe(),
94-
InterfaceObject(class) => class.describe(),
94+
InterfaceObject(object) => object.class.describe(),
9595
PhysicalLiteral => "physical literal",
9696
DeferredConstant => "deferred constant",
9797
ProtectedType(..) => "protected type",
@@ -107,6 +107,15 @@ impl NamedEntityKind {
107107
}
108108
}
109109

110+
/// Signals, (shared) variables and constants
111+
#[derive(Clone)]
112+
pub struct InterfaceObject {
113+
pub class: ObjectClass,
114+
pub mode: Mode,
115+
pub subtype: Subtype,
116+
pub has_default: bool,
117+
}
118+
110119
#[derive(Clone)]
111120
pub struct Subtype {
112121
base: Arc<NamedEntity>,

0 commit comments

Comments
 (0)