1/*
2 * Copyright (c) Huawei Device Co., Ltd. 2021 - 2023. All rights reserved.
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
16#ifndef ES2PANDA_IR_SRCDUMP_H
17#define ES2PANDA_IR_SRCDUMP_H
18
19#include <ir/astNode.h>
20#include <lexer/token/sourceLocation.h>
21#include <lexer/token/tokenType.h>
22#include <util/ustring.h>
23
24#include <sstream>
25#include <variant>
26
27namespace ark::es2panda::ir {
28
29class SrcDumper {
30public:
31    explicit SrcDumper(const ir::AstNode *node);
32
33    void Add(const std::string &str);
34    void Add(int32_t i);
35    void Add(int64_t l);
36    void Add(float f);
37    void Add(double d);
38
39    std::string Str() const
40    {
41        return ss_.str();
42    }
43
44    void IncrIndent();
45    void DecrIndent();
46    void Endl(size_t num = 1);
47
48private:
49    std::stringstream ss_;
50    std::string indent_;
51};
52}  // namespace ark::es2panda::ir
53
54#endif  // ES2PANDA_IR_SRCDUMP_H
55