MCPcopy Create free account
hub / github.com/Nic30/hdlConvertor / visitConditional_waveforms

Method visitConditional_waveforms

src/vhdlConvertor/exprParser.cpp:427–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427unique_ptr<iHdlExprItem> VhdlExprParser::visitConditional_waveforms(
428 vhdlParser::Conditional_waveformsContext *ctx) {
429 // conditional_waveforms:
430 // waveform WHEN condition
431 // ( ELSE waveform WHEN condition )*
432 // ( ELSE waveform )?
433 // ;
434 auto waveforms = ctx->waveform();
435 auto conditions = ctx->condition();
436 auto c = conditions.rbegin();
437 unique_ptr<iHdlExprItem> res = nullptr;
438 for (auto w = waveforms.rbegin(); w != waveforms.rend(); ++w) {
439 auto w_expr = visitWaveform(*w);
440 if (res == nullptr) {
441 // the first iteration
442 bool has_default_else = waveforms.size() > conditions.size();
443 if (has_default_else) {
444 // this waveform is a default else
445 res = move(w_expr);
446 continue;
447 }
448 }
449 auto c_expr = visitCondition(*c);
450 res = HdlOp::ternary(*w, move(c_expr), move(w_expr), move(res));
451 c++;
452 }
453 return res;
454}
455
456unique_ptr<iHdlExprItem> VhdlExprParser::visitWaveform_element(
457 vhdlParser::Waveform_elementContext *ctx) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected