-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support importing functions into modport
(refs: #732)
- Loading branch information
1 parent
c192eda
commit 7408778
Showing
22 changed files
with
5,578 additions
and
5,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use crate::analyzer_error::AnalyzerError; | ||
use crate::symbol::SymbolKind; | ||
use crate::symbol_table; | ||
use veryl_parser::veryl_grammar_trait::*; | ||
use veryl_parser::veryl_walker::{Handler, HandlerPoint}; | ||
use veryl_parser::ParolError; | ||
|
||
pub struct CheckModport<'a> { | ||
pub errors: Vec<AnalyzerError>, | ||
text: &'a str, | ||
point: HandlerPoint, | ||
} | ||
|
||
impl<'a> CheckModport<'a> { | ||
pub fn new(text: &'a str) -> Self { | ||
Self { | ||
errors: Vec::new(), | ||
text, | ||
point: HandlerPoint::Before, | ||
} | ||
} | ||
} | ||
|
||
impl<'a> Handler for CheckModport<'a> { | ||
fn set_point(&mut self, p: HandlerPoint) { | ||
self.point = p; | ||
} | ||
} | ||
|
||
impl<'a> VerylGrammarTrait for CheckModport<'a> { | ||
fn modport_item(&mut self, arg: &ModportItem) -> Result<(), ParolError> { | ||
if let HandlerPoint::Before = self.point { | ||
if let Ok(symbol) = symbol_table::resolve(arg.identifier.as_ref()) { | ||
match &*arg.modport_item_group { | ||
ModportItemGroup::Direction(_) => { | ||
let is_variable = match symbol.found.kind { | ||
SymbolKind::Variable(_) => true, | ||
_ => false, | ||
}; | ||
|
||
if !is_variable { | ||
self.errors.push(AnalyzerError::invalid_modport_port_item( | ||
&arg.identifier.identifier_token.token.to_string(), | ||
self.text, | ||
&arg.identifier.as_ref().into(), | ||
)); | ||
} | ||
} | ||
ModportItemGroup::Import(_) => { | ||
let is_function = match symbol.found.kind { | ||
SymbolKind::Function(_) => true, | ||
_ => false, | ||
}; | ||
|
||
if !is_function { | ||
self.errors | ||
.push(AnalyzerError::invalid_modport_function_item( | ||
&arg.identifier.identifier_token.token.to_string(), | ||
self.text, | ||
&arg.identifier.as_ref().into(), | ||
)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.