• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "dumper.h"
16 
17 namespace panda::es2panda::util {
18 
DumpLiterals(std::map<std::string,panda::pandasm::LiteralArray> const & literalTable)19 void Dumper::DumpLiterals(std::map<std::string, panda::pandasm::LiteralArray> const &literalTable)
20 {
21     std::cout << "======> literal array buffer <======" << std::endl;
22     for (auto it : literalTable) {
23         std::cout << "------------------------------------" << std::endl;
24         std::cout << "slot " << it.first << std::endl;
25         int count = 0;
26         for (auto literal : it.second.literals_) {
27             std::cout << "{" << std::endl;
28             std::cout << "  index: " << count++ << std::endl;
29             std::cout << "    tag: " <<
30                 unsigned(static_cast<std::underlying_type<panda::panda_file::LiteralTag>::type>(literal.tag_)) <<
31                 std::endl;
32             std::visit([](auto&& element) {
33                 if constexpr (std::is_same_v<decltype(element), unsigned char &>) {
34                     std::cout << "    val: " << unsigned(element) << std::endl;
35                 } else if constexpr (std::is_same_v<decltype(element), unsigned int &>) {
36                     std::cout << "    val: " << signed(element) << std::endl;
37                 } else {
38                     std::cout << "    val: " << element << std::endl;
39                 }
40             }, literal.value_);
41             std::cout << "}," << std::endl;
42         }
43     }
44 }
45 
46 }  // namespace panda::es2panda::util
47 
48