• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Nic30 / hdlConvertor / #200

10 Jun 2025 02:20PM UTC coverage: 60.002% (+6.0%) from 54.006%
#200

push

travis-ci

Nic30
build: fix propagation of '-Wno-overloaded-virtual' for antrl4

41577 of 69293 relevant lines covered (60.0%)

1047823.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/src/vhdlConvertor/generateStatementParser.cpp
1
#include <hdlConvertor/createObject.h>
2
#include <hdlConvertor/notImplementedLogger.h>
3

4
#include <hdlConvertor/hdlAst/hdlStmFor.h>
5

6
#include <hdlConvertor/vhdlConvertor/blockDeclarationParser.h>
7
#include <hdlConvertor/vhdlConvertor/compInstanceParser.h>
8
#include <hdlConvertor/vhdlConvertor/constantParser.h>
9
#include <hdlConvertor/vhdlConvertor/entityParser.h>
10
#include <hdlConvertor/vhdlConvertor/exprParser.h>
11
#include <hdlConvertor/vhdlConvertor/generateStatementParser.h>
12
#include <hdlConvertor/vhdlConvertor/interfaceParser.h>
13
#include <hdlConvertor/vhdlConvertor/literalParser.h>
14
#include <hdlConvertor/vhdlConvertor/processParser.h>
15
#include <hdlConvertor/vhdlConvertor/referenceParser.h>
16
#include <hdlConvertor/vhdlConvertor/signalParser.h>
17
#include <hdlConvertor/vhdlConvertor/statementParser.h>
18
#include <hdlConvertor/vhdlConvertor/subProgramDeclarationParser.h>
19
#include <hdlConvertor/vhdlConvertor/subProgramParser.h>
20
#include <hdlConvertor/vhdlConvertor/variableParser.h>
21
#include <assert.h>
22

23
namespace hdlConvertor {
24
namespace vhdl {
25

26
using namespace hdlConvertor::hdlAst;
27
using namespace std;
28

29
std::unique_ptr<iHdlStatement> VhdlGenerateStatementParser::visitGenerate_statement(
206✔
30
                vhdlParser::Generate_statementContext *ctx) {
31
        //generate_statement
32
        //  : for_generate_statement
33
        //  | if_generate_statement
34
        //  | case_generate_statement
35
        //  ;
36

37
        auto fgs = ctx->for_generate_statement();
206✔
38
        if (fgs) {
206✔
39
                return visitFor_generate_statement(fgs);
93✔
40
        }
41

42
        auto ifs = ctx->if_generate_statement();
113✔
43
        if (ifs) {
113✔
44
                return visitIf_generate_statement(ifs);
111✔
45
        }
46

47
        auto cgs = ctx->case_generate_statement();
2✔
48
        assert(cgs);
2✔
49
        return visitCase_generate_statement(cgs);
2✔
50

51
}
52

53
std::unique_ptr<iHdlStatement> VhdlGenerateStatementParser::visitFor_generate_statement(
93✔
54
                vhdlParser::For_generate_statementContext *ctx) {
55
        // for_generate_statement:
56
        //           FOR parameter_specification GENERATE
57
        //               generate_statement_body
58
        //           END GENERATE ( label )? SEMI
59
        // ;
60

61
        VhdlStatementParser sp(commentParser, hierarchyOnly);
93✔
62
        auto args = sp.visitParameter_specification(ctx->parameter_specification());
93✔
63
        auto objs = visitGenerate_statement_body(ctx->generate_statement_body());
93✔
64
        auto fstm = create_object<HdlStmForIn>(ctx, move(args.first),
93✔
65
                        move(args.second), move(objs));
186✔
66
        auto label = ctx->label();
93✔
67
        if (label) {
93✔
68
                auto l = VhdlLiteralParser::visitLabel(label);
44✔
69
                fstm->labels.push_back(l);
44✔
70
        }
44✔
71
        fstm->in_preproc = true;
93✔
72
        return fstm;
186✔
73
}
93✔
74

75
std::unique_ptr<HdlStmIf> VhdlGenerateStatementParser::visitIf_generate_statement(
111✔
76
                vhdlParser::If_generate_statementContext *ctx) {
77
        // if_generate_statement:
78
        //       label COLON
79
        //           IF ( label COLON )? condition GENERATE
80
        //               generate_statement_body
81
        //           ( ELSIF ( label COLON )? condition GENERATE
82
        //               generate_statement_body )*
83
        //           ( ELSE ( label COLON )? GENERATE
84
        //               generate_statement_body )?
85
        //           END GENERATE ( label )? SEMI
86
        // ;
87

88
        auto c = ctx->condition();
111✔
89
        auto cIt = c.begin();
111✔
90
        auto s = ctx->generate_statement_body();
111✔
91
        auto sIt = s.begin();
111✔
92

93
        auto cond = VhdlExprParser::visitCondition(*cIt);
111✔
94
        auto ifTrue = visitGenerate_statement_body(*sIt);
111✔
95
        ++cIt;
111✔
96
        ++sIt;
111✔
97
        std::vector<HdlExprAndiHdlObj> elseIfs;
111✔
98
        while (cIt != c.end()) {
115✔
99
                auto c = VhdlExprParser::visitCondition(*cIt);
4✔
100
                auto stms = visitGenerate_statement_body(*sIt);
4✔
101
                elseIfs.push_back( { move(c), move(stms) });
4✔
102
                ++cIt;
4✔
103
                ++sIt;
4✔
104
        }
4✔
105
        std::unique_ptr<HdlStmIf> ifStm = nullptr;
111✔
106
        std::unique_ptr<hdlAst::iHdlObj> ifFalse = nullptr;
111✔
107
        if (sIt != s.end()) {
111✔
108
                ifFalse = visitGenerate_statement_body(*sIt);
8✔
109
        }
110

111
        ifStm = create_object<HdlStmIf>(ctx, move(cond), move(ifTrue), elseIfs,
222✔
112
                        move(ifFalse));
222✔
113
        ifStm->in_preproc = true;
111✔
114
        auto labels = ctx->label();
111✔
115
        if (labels.size()) {
111✔
116
                ifStm->labels.push_back(VhdlLiteralParser::visitLabel(labels[0]));
56✔
117
        }
118
        return ifStm;
111✔
119
}
111✔
120

121
std::unique_ptr<HdlStmCase> VhdlGenerateStatementParser::visitCase_generate_statement(
2✔
122
                vhdlParser::Case_generate_statementContext *ctx) {
123
        // case_generate_statement:
124
        //           CASE expression GENERATE
125
        //               case_generate_alternative
126
        //               ( case_generate_alternative )*
127
        //           END GENERATE ( label )? SEMI
128
        // ;
129

130
        auto _e = ctx->expression();
2✔
131
        auto e = VhdlExprParser::visitExpression(_e);
2✔
132
        vector<HdlExprAndiHdlObj> alternatives;
2✔
133
        unique_ptr<iHdlObj> _default = nullptr;
2✔
134
        vector<std::string> labels;
2✔
135
        auto label = ctx->label();
2✔
136
        if (label) {
2✔
137
                auto l = VhdlLiteralParser::visitLabel(label);
2✔
138
                labels.push_back(l);
2✔
139
        }
2✔
140
        for (auto a : ctx->case_generate_alternative()) {
8✔
141
                // case_generate_alternative:
142
                //       WHEN ( label COLON )? choices ARROW
143
                //           generate_statement_body_with_begin_end
144
                // ;
145
                if (a->label()) {
6✔
146
                        auto l = VhdlLiteralParser::visitLabel(a->label());
2✔
147
                        labels.push_back(l);
2✔
148
                }
2✔
149
                for (auto &ch : VhdlExprParser::visitChoices(a->choices())) {
14✔
150
                        auto s = a->generate_statement_body_with_begin_end();
8✔
151
                        auto stms = visitGenerate_statement_body(s);
8✔
152
                        if (ch == nullptr) {
8✔
153
                                assert(_default == nullptr);
×
154
                                _default = move(stms);
×
155
                        } else {
156
                                alternatives.push_back( { move(ch), move(stms) });
8✔
157
                        }
158
                }
14✔
159
        }
2✔
160
        auto cstm = create_object<HdlStmCase>(ctx, move(e), alternatives,
2✔
161
                        move(_default));
4✔
162
        cstm->in_preproc = true;
2✔
163
        return cstm;
2✔
164
}
2✔
165

166
template<typename CTX_T>
167
std::unique_ptr<hdlAst::iHdlObj> VhdlGenerateStatementParser::visitGenerate_statement_body(
224✔
168
                CTX_T *ctx) {
169
        // generate_statement_body:
170
        //     ( block_declarative_item*
171
        //       KW_BEGIN
172
        //         ( concurrent_statement )*
173
        //      )
174
        //      | ( concurrent_statement )*
175
        // ;
176
        auto bdis = ctx->block_declarative_item();
224✔
177
        auto cstms = ctx->concurrent_statement();
224✔
178
        VhdlStatementParser sp(commentParser, hierarchyOnly);
224✔
179
        auto b = create_object<HdlStmBlock>(ctx);
224✔
180
        b->in_preproc = true;
224✔
181
        if (bdis.size()) {
224✔
182
                VhdlBlockDeclarationParser _bdp(commentParser, hierarchyOnly);
34✔
183
                for (auto bdi : ctx->block_declarative_item()) {
111✔
184
                        _bdp.visitBlock_declarative_item(bdi, b->statements);
77✔
185
                }
186
        }
187
        for (auto cs : ctx->concurrent_statement()) {
550✔
188
                sp.visitConcurrent_statement(cs, b->statements);
326✔
189
        }
190
        if (bdis.size() == 0 && !ctx->KW_BEGIN() && b->statements.size() == 1) {
224✔
191
                auto res = move(b->statements.back());
145✔
192
                b->statements.pop_back();
145✔
193
                return res;
145✔
194
        } else {
×
195
                return b;
79✔
196
        }
197
}
224✔
198

199
template std::unique_ptr<hdlAst::iHdlObj> VhdlGenerateStatementParser::visitGenerate_statement_body<
200
                vhdl_antlr::vhdlParser::Generate_statement_bodyContext>(
201
                vhdl_antlr::vhdlParser::Generate_statement_bodyContext *ctx);
202
template std::unique_ptr<hdlAst::iHdlObj> VhdlGenerateStatementParser::visitGenerate_statement_body<
203
                vhdl_antlr::vhdlParser::Generate_statement_body_with_begin_endContext>(
204
                vhdl_antlr::vhdlParser::Generate_statement_body_with_begin_endContext *ctx);
205

206
}
207
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc