-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verilog: extract scope data structure from parser
This extracts the scope data structure from the parser class into a separate file, as the scopes need to be preserved until all Verilog parsing is finished.
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/parser.h> | ||
|
||
#include "verilog_parse_tree.h" | ||
#include "verilog_scope.h" | ||
#include "verilog_standard.h" | ||
|
||
#include <map> | ||
|
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,9 @@ | ||
/*******************************************************************\ | ||
Module: Verilog Scope | ||
Author: Daniel Kroening, [email protected] | ||
\*******************************************************************/ | ||
|
||
#include "verilog_scope.h" |
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,54 @@ | ||
/*******************************************************************\ | ||
Module: Verilog Scopes | ||
Author: Daniel Kroening, [email protected] | ||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_VERILOG_SCOPE_H | ||
#define CPROVER_VERILOG_SCOPE_H | ||
|
||
#include <util/irep.h> | ||
|
||
#include <map> | ||
|
||
// parser scopes and identifiers | ||
struct scopet | ||
{ | ||
scopet() : parent(nullptr), prefix("Verilog::") | ||
{ | ||
} | ||
|
||
explicit scopet( | ||
irep_idt _base_name, | ||
const std::string &separator, | ||
scopet *_parent) | ||
: parent(_parent), | ||
__base_name(_base_name), | ||
prefix(id2string(_parent->prefix) + id2string(_base_name) + separator) | ||
{ | ||
} | ||
|
||
scopet *parent = nullptr; | ||
bool is_type = false; | ||
irep_idt __base_name; | ||
std::string prefix; | ||
|
||
irep_idt identifier() const | ||
{ | ||
PRECONDITION(parent != nullptr); | ||
return parent->prefix + id2string(__base_name); | ||
} | ||
|
||
const irep_idt &base_name() const | ||
{ | ||
return __base_name; | ||
} | ||
|
||
// sub-scopes | ||
using scope_mapt = std::map<irep_idt, scopet>; | ||
scope_mapt scope_map; | ||
}; | ||
|
||
#endif |