| 336 | } |
| 337 | |
| 338 | std::unique_ptr<hdlAst::iHdlExprItem> VerExprPrimaryParser::visitAssignment_pattern( |
| 339 | sv2017Parser::Assignment_patternContext *ctx) { |
| 340 | // assignment_pattern: |
| 341 | // APOSTROPHE_LBRACE ( |
| 342 | // expression ( COMMA expression )* |
| 343 | // | structure_pattern_key COLON expression |
| 344 | // ( COMMA structure_pattern_key COLON expression )* |
| 345 | // | array_pattern_key COLON expression |
| 346 | // ( COMMA array_pattern_key COLON expression )* |
| 347 | // | constant_expression LBRACE expression ( COMMA expression )* RBRACE |
| 348 | // )? RBRACE; |
| 349 | std::vector<std::unique_ptr<iHdlExprItem>> keys; |
| 350 | auto exprs = make_unique<std::vector<std::unique_ptr<iHdlExprItem>>>(); |
| 351 | for (auto e : ctx->expression()) { |
| 352 | auto o = VerExprParser(this).visitExpression(e); |
| 353 | exprs->push_back(move(o)); |
| 354 | } |
| 355 | auto sp = ctx->structure_pattern_key(); |
| 356 | if (sp.size()) { |
| 357 | for (auto _sp : sp) { |
| 358 | keys.push_back(visitStructure_pattern_key(_sp)); |
| 359 | } |
| 360 | } else { |
| 361 | auto ap = ctx->array_pattern_key(); |
| 362 | if (ap.size()) { |
| 363 | for (auto _ap : ap) { |
| 364 | keys.push_back(visitArray_pattern_key(_ap)); |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | auto ce = ctx->constant_expression(); |
| 369 | if (ce) { |
| 370 | NotImplementedLogger::print( |
| 371 | "VerExprPrimaryParser.visitAssignment_pattern constant_expression", |
| 372 | ctx); |
| 373 | return create_object<HdlExprNotImplemented>(ctx); |
| 374 | } |
| 375 | if (keys.size()) { |
| 376 | // associate keys with items (create a list of key:expr) |
| 377 | auto new_exprs = |
| 378 | make_unique<std::vector<std::unique_ptr<iHdlExprItem>>>(); |
| 379 | auto e_it = exprs->begin(); |
| 380 | assert(keys.size() == exprs->size()); |
| 381 | for (auto &k : keys) { |
| 382 | auto n_e = make_unique<HdlOp>(move(k), HdlOpType::MAP_ASSOCIATION, |
| 383 | move(*e_it)); |
| 384 | new_exprs->push_back(move(n_e)); |
| 385 | ++e_it; |
| 386 | } |
| 387 | exprs = move(new_exprs); |
| 388 | } |
| 389 | |
| 390 | return make_unique<HdlValueArr>(move(exprs)); |
| 391 | } |
| 392 | unique_ptr<iHdlExprItem> VerExprPrimaryParser::visitPrimaryTypeRef( |
| 393 | sv2017Parser::PrimaryTypeRefContext *ctx) { |
| 394 | // | type_reference #PrimaryTypeRef |
nothing calls this directly
no test coverage detected