-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbase.h
More file actions
105 lines (84 loc) · 3.52 KB
/
base.h
File metadata and controls
105 lines (84 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef DECOMPILER_BASE
#define DECOMPILER_BASE
#include "libpandabase/mem/arena_allocator.h"
#include "libpandabase/mem/pool_manager.h"
#include "libpandafile/class_data_accessor.h"
#include "libpandafile/class_data_accessor-inl.h"
#include "libpandafile/method_data_accessor.h"
#include "libpandafile/module_data_accessor-inl.h"
#include "libpandafile/file.h"
#include "libpandafile/util/collect_util.h"
#include "libpandabase/utils/logger.h"
/////////////////////////////////////////////////////////////
#include "compiler/optimizer/ir/graph.h"
#include "compiler/optimizer/pass.h"
#include "compiler/optimizer/ir_builder/ir_builder.h"
#include "compiler/optimizer/analysis/loop_analyzer.h"
#include "compiler/optimizer/optimizations/branch_elimination.h"
#include "compiler/optimizer/optimizations/cleanup.h"
#include "compiler/optimizer/optimizations/lowering.h"
#include "compiler/optimizer/optimizations/move_constants.h"
#include "compiler/optimizer/optimizations/regalloc/reg_alloc.h"
#include "compiler/optimizer/optimizations/vn.h"
#include "constant_propagation/constant_propagation.h"
#include "compiler/optimizer/ir/basicblock.h"
#include "compiler/optimizer/ir/graph_visitor.h"
#include "compiler/optimizer/ir/inst.h"
#include "compiler/optimizer/ir/runtime_interface.h"
/////////////////////////////////////////////////////////////
#include "bytecode_optimizer/ir_interface.h"
#include "bytecode_optimizer/runtime_adapter.h"
#include "bytecode_optimizer/bytecode_analysis_results.h"
#include "bytecode_optimizer/bytecodeopt_options.h"
#include "bytecode_optimizer/optimize_bytecode.h"
#include "bytecode_optimizer/reg_acc_alloc.h"
#include "bytecode_optimizer/reg_encoder.h"
#include "bytecode_optimizer/tagged_value.h"
#include "bytecode_optimizer/codegen.h"
#include "bytecode_optimizer/common.h"
/////////////////////////////////////////////////////////////
#include "assembler/annotation.h"
#include "assembler/assembly-function.h"
#include "assembly-parser.h"
#include "assembler/assembly-parser.h"
#include "disassembler/disassembler.h"
#include "ast.h"
#include <string>
#include <typeinfo>
#include <sstream>
#include <variant>
#include <vector>
#include <memory>
#include <stdexcept>
static int count = 0;
inline void HandleInnerError(const std::string& message) {
std::cerr << "Error: " << message << std::endl;
std::exit(EXIT_FAILURE);
}
template<typename... Args>
std::string formatString(Args... args) {
std::ostringstream oss;
int unpack[] = {0, ((void)(oss << args), 0)...};
static_cast<void>(unpack);
return oss.str();
}
template<typename... Args>
void HandleError(Args... args) {
std::ostringstream oss;
oss << formatString(args...);
HandleInnerError(oss.str());
}
template <typename Container, typename T>
bool contains(const Container& container, const T& value) {
if constexpr (std::is_same_v<Container, std::set<T>> || std::is_same_v<Container, std::unordered_set<T>>) {
return container.find(value) != container.end();
} else {
return std::find(container.begin(), container.end(), value) != container.end();
}
}
std::string RemoveArgumentsOfFunc(const std::string& input);
std::optional<std::vector<std::string>> GetLiteralArrayByOffset(panda::pandasm::Program* program, uint32_t offset);
std::optional<std::string> FindKeyByValue(const std::map<std::string, uint32_t>& myMap, const uint32_t& value);
uint32_t ParseHexFromKey(const std::string& key);
std::optional<panda::pandasm::LiteralArray> FindLiteralArrayByOffset(panda::pandasm::Program *program_, uint32_t offset) ;
#endif