* Copyright (c) 2021-2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ES2PANDA_COMPILER_DEBUGGER_DEBUGINFO_DUMPER_H
#define ES2PANDA_COMPILER_DEBUGGER_DEBUGINFO_DUMPER_H
#include "assembly-ins.h"
#include "assembly-program.h"
#include "util/es2pandaMacros.h"
namespace ark::es2panda::debuginfo {
class DebugInfoDumper {
public:
explicit DebugInfoDumper(const pandasm::Program *prog);
~DebugInfoDumper() = default;
NO_COPY_SEMANTIC(DebugInfoDumper);
NO_MOVE_SEMANTIC(DebugInfoDumper);
void Dump();
private:
template <typename T>
void WrapArray(const char *name, const std::vector<T> &array, bool comma = true);
void WrapRegArray(ark::pandasm::Ins const &ins, bool comma = true);
void WrapIDArray(ark::pandasm::Ins const &ins, bool comma = true);
void WrapImmArray(ark::pandasm::Ins const &ins, bool comma = true);
void WriteIns(const pandasm::Ins &ins);
void WriteMetaData(const std::vector<pandasm::AnnotationData> &metaData);
template <typename T>
void WriteProperty(const char *key, T &&value, bool comma = true);
void WritePosInfo(const pandasm::debuginfo::Ins &posInfo);
void WriteVariableInfo(const pandasm::debuginfo::LocalVariable &localVariableDebug);
void Indent();
void DumpFunctions(const std::map<std::string, pandasm::Function> &table);
void DumpFuncBody(std::string const &name, const pandasm::Function &func);
const pandasm::Program *prog_;
std::stringstream ss_;
int32_t indent_ {0};
};
}
#endif