| 705 | } |
| 706 | |
| 707 | uint8_t ElemSegment::GetFlags(const Module* module, |
| 708 | bool function_references_enabled) const { |
| 709 | uint8_t flags = 0; |
| 710 | |
| 711 | switch (kind) { |
| 712 | case SegmentKind::Active: { |
| 713 | Index table_index = module->GetTableIndex(table_var); |
| 714 | if (elem_type != Type::FuncRef || table_index != 0) { |
| 715 | flags |= SegExplicitIndex; |
| 716 | } |
| 717 | break; |
| 718 | } |
| 719 | |
| 720 | case SegmentKind::Passive: |
| 721 | flags |= SegPassive; |
| 722 | break; |
| 723 | |
| 724 | case SegmentKind::Declared: |
| 725 | flags |= SegDeclared; |
| 726 | break; |
| 727 | } |
| 728 | |
| 729 | if (function_references_enabled && |
| 730 | elem_type != Type(Type::FuncRef, Type::ReferenceNonNull)) { |
| 731 | flags |= SegUseElemExprs; |
| 732 | } else { |
| 733 | bool all_ref_func = |
| 734 | elem_type == Type::FuncRef && |
| 735 | std::all_of(elem_exprs.begin(), elem_exprs.end(), |
| 736 | [](const ExprList& elem_expr) { |
| 737 | return elem_expr.front().type() == ExprType::RefFunc; |
| 738 | }); |
| 739 | |
| 740 | if (!all_ref_func) { |
| 741 | flags |= SegUseElemExprs; |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | return flags; |
| 746 | } |
| 747 | |
| 748 | uint8_t DataSegment::GetFlags(const Module* module) const { |
| 749 | uint8_t flags = 0; |
no test coverage detected