-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope.h
More file actions
92 lines (67 loc) · 2.13 KB
/
Copy pathscope.h
File metadata and controls
92 lines (67 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Copyright CERN 2016
* @author Maciej Suminski (maciej.suminski@cern.ch)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCOPE_H
#define SCOPE_H
#include "variable.h"
#include <string>
#include <map>
class Scope;
typedef std::map<std::string, Scope*> ScopeStringMap;
class Scope {
public:
///> Possible scope types in VCD files
enum scope_type_t {
BEGIN, FORK, FUNCTION, MODULE, TASK, UNKNOWN
};
Scope(scope_type_t scope_type, const std::string&name, Scope*parent);
~Scope();
inline const std::string&name() const {
return name_;
}
inline const std::string&full_name() const {
return full_name_;
}
inline scope_type_t type() const {
return scope_type_;
}
Scope*make_scope(scope_type_t type, const std::string&name);
Scope*get_scope(const std::string&name);
ScopeStringMap&scopes() {
return scopes_;
}
void add_variable(Variable*var);
Variable*get_variable(const std::string&name);
std::map<std::string, Variable*>&variables() {
return vars_;
}
inline Scope*parent() const {
return parent_;
}
private:
// The unique part of the scope name
const std::string name_;
// Full scope name, including the scopes hierarchy
std::string full_name_;
// Scope kind
const scope_type_t scope_type_;
// Subscopes
ScopeStringMap scopes_;
// Variables stored in the scope
VarStringMap vars_;
// Parent scope, NULL if it is the root scope
Scope*parent_;
};
#endif /* SCOPE_H */