| 756 | } |
| 757 | |
| 758 | void parser_exe_print(char const* p, Vector<std::string> const& vars, |
| 759 | Vector<char const*> const& locals) |
| 760 | { |
| 761 | Vector<std::pair<std::string,paren_t>> pstack; |
| 762 | int count = 0; |
| 763 | auto& os = amrex::OutStream(); |
| 764 | os << " # Instruction StackSize StackTop\n"; |
| 765 | |
| 766 | auto get_sym = [&] (int i) -> std::pair<std::string,paren_t> |
| 767 | { |
| 768 | if (i >= AMREX_PARSER_LOCAL_IDX0) { |
| 769 | return {locals[i-AMREX_PARSER_LOCAL_IDX0],paren_t::atom}; |
| 770 | } else { |
| 771 | return {vars[i],paren_t::atom}; |
| 772 | } |
| 773 | }; |
| 774 | |
| 775 | auto get_val = [&] (double v) -> std::pair<std::string,paren_t> |
| 776 | { |
| 777 | return {std::to_string(v), paren_t::atom}; |
| 778 | }; |
| 779 | |
| 780 | while (*((parser_exe_t*)p) != PARSER_EXE_NULL) { // NOLINT |
| 781 | switch (*((parser_exe_t*)p)) |
| 782 | { |
| 783 | case PARSER_EXE_NUMBER: |
| 784 | { |
| 785 | pstack.emplace_back(get_val(((ParserExeNumber*)p)->v)); |
| 786 | os << std::setw(3) << count++ |
| 787 | << std::setw(16) << "push" |
| 788 | << std::setw(12) << pstack.size() |
| 789 | << " " |
| 790 | << pstack.back().first << "\n"; |
| 791 | p += sizeof(ParserExeNumber); |
| 792 | break; |
| 793 | } |
| 794 | case PARSER_EXE_SYMBOL: |
| 795 | { |
| 796 | int i = ((ParserExeSymbol*)p)->i; |
| 797 | pstack.emplace_back(get_sym(i)); |
| 798 | os << std::setw(3) << count++ |
| 799 | << std::setw(16) << "push" |
| 800 | << std::setw(12) << pstack.size() |
| 801 | << " " |
| 802 | << pstack.back().first; |
| 803 | if (i >= AMREX_PARSER_LOCAL_IDX0) { |
| 804 | os << " = " << pstack[i-AMREX_PARSER_LOCAL_IDX0].first; |
| 805 | } |
| 806 | os << "\n"; |
| 807 | p += sizeof(ParserExeSymbol); |
| 808 | break; |
| 809 | } |
| 810 | case PARSER_EXE_ADD: |
| 811 | { |
| 812 | auto n = pstack.size(); |
| 813 | pstack[n-2] = make_op_string(pstack[n-2],{"+",paren_t::plusminus}, pstack[n-1]); // NOLINT |
| 814 | pstack.pop_back(); |
| 815 | os << std::setw(3) << count++ |
no test coverage detected