/home/runner/work/LabNeura/LabNeura/include/labneura/eda/expression.h
Line | Count | Source |
1 | | #ifndef LABNEURA_EDA_EXPRESSION_H |
2 | | #define LABNEURA_EDA_EXPRESSION_H |
3 | | |
4 | | #include <string> |
5 | | #include <cstddef> |
6 | | #include <utility> |
7 | | #include <vector> |
8 | | |
9 | | namespace labneura::eda { |
10 | | |
11 | | enum class ExpressionKind { |
12 | | Identifier, |
13 | | Literal, |
14 | | Unary, |
15 | | Binary, |
16 | | Conditional, |
17 | | BitSelect, |
18 | | RangeSelect, |
19 | | Concatenation, |
20 | | Opaque |
21 | | }; |
22 | | |
23 | | class Expression { |
24 | | public: |
25 | 8 | Expression() = default; |
26 | | Expression(ExpressionKind kind, std::string value, std::string source, |
27 | | std::vector<Expression> operands = {}, std::size_t width = 0) |
28 | 12.0k | : kind_(kind), |
29 | 12.0k | value_(std::move(value)), |
30 | 12.0k | source_(std::move(source)), |
31 | 12.0k | operands_(std::move(operands)), |
32 | 12.0k | width_(width) {} |
33 | | |
34 | 4.83k | ExpressionKind get_kind() const noexcept { return kind_; } |
35 | 1.50k | const std::string& get_value() const noexcept { return value_; } |
36 | 1.86k | const std::string& get_source() const noexcept { return source_; } |
37 | 1.62k | const std::vector<Expression>& get_operands() const noexcept { |
38 | 1.62k | return operands_; |
39 | 1.62k | } |
40 | 24 | std::size_t get_width() const noexcept { return width_; } |
41 | | |
42 | | private: |
43 | | ExpressionKind kind_ = ExpressionKind::Opaque; |
44 | | std::string value_; |
45 | | std::string source_; |
46 | | std::vector<Expression> operands_; |
47 | | std::size_t width_ = 0; |
48 | | }; |
49 | | |
50 | | } // namespace labneura::eda |
51 | | |
52 | | #endif |