• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HC_GEN_DECOMPILE_GEN_H
10 #define HC_GEN_DECOMPILE_GEN_H
11 
12 #include <fstream>
13 #include <string>
14 
15 #include "ast.h"
16 
17 namespace OHOS {
18 namespace Hardware {
19 class DecompileGen {
20 public:
21     DecompileGen(std::shared_ptr<Ast> ast, std::string outPutFileName);
22 
23     ~DecompileGen() = default;
24 
25     bool OutPut();
26 
27 private:
28     bool Init();
29 
30     void WriteFile(const std::string &str);
31 
32     int32_t PrintBaseType(const std::shared_ptr<AstObject> &astObj);
33 
34     std::string GetNodeRefPath(uint32_t value);
35 
36     int32_t PrintArrayType(const std::shared_ptr<AstObject> &astObj);
37 
38     uint32_t OutPutWalk(const std::shared_ptr<AstObject> &astObj, int32_t walkDepth);
39 
40     uint32_t CloseBrace(const std::shared_ptr<AstObject> &astObj, int32_t walkDepth);
41 
42     const std::string fileHeader_;
43     std::string outPutFileName_;
44     std::ofstream file_;
45     std::shared_ptr<Ast> ast_;
46 };
47 } // namespace Hardware
48 } // namespace OHOS
49 #endif // HC_GEN_DECOMPILE_GEN_H
50