macro_rules! resolve {
($fold:expr; $name:ident as $($declaration:ident($id:ident) => $block:block),+) => { ... };
}Expand description
A macro that hides the boiler plate required for name resolution using the resolver struct
It is defined in the name_resolution module but due to limitations of rustdoc can’t be shown there in the documentation
If $name wasn’t found or doesn’t math any SymbolDeclaration::$declaration the appropriate errors are added to $self.errors and execution continuous after the macro
§Arguments
-
$self- reference to an ast fold (implementation of theFoldtrait) -
$name- The Identifier (typeIdent) that should be resolved
The following three arguments can be repeated as often as necessary (like in a match block)
-
$declarationAn identifier of anSymbolDeclarationvariant which you wish to resolve$nameas -
$idThe identifier under which the ID of the resolved declaration will be available inside the associated `$block -
$blockA block ({statements}) which will be executed when$nameis resolved as aSymbolDeclaration::$declaration
§Examples
The following tries to resolve ident as a Nature
use OpenVAF::symbol_table::SymbolDeclaration::Nature;
use OpenVAF::symbol_table::SymbolDeclaration::Discipline;
resolve!(fold; ident as
Nature(id) => {
println!("Resolved nature")
}
Discipline(id) => {
println!("Resolved a discipline")
}
);
println!("Not found or not a discipline/nature")