forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DexCallSite.cpp
59 lines (49 loc) · 1.77 KB
/
DexCallSite.cpp
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
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "DexCallSite.h"
#include "DexAnnotation.h"
#include "DexClass.h"
#include "DexIdx.h"
#include "DexMethodHandle.h"
#include <sstream>
void DexCallSite::gather_strings(std::vector<const DexString*>& lstring) const {
lstring.emplace_back(m_linker_method_name);
m_linker_method_type->gather_strings(lstring);
for (auto& ev : m_linker_method_args) {
ev->gather_strings(lstring);
}
}
void DexCallSite::gather_methodhandles(
std::vector<DexMethodHandle*>& lmethodhandle) const {
lmethodhandle.push_back(m_linker_method_handle);
for (auto& ev : m_linker_method_args) {
ev->gather_methodhandles(lmethodhandle);
}
}
void DexCallSite::gather_methods(std::vector<DexMethodRef*>& lmethod) const {
m_linker_method_handle->gather_methods(lmethod);
for (auto& ev : m_linker_method_args) {
ev->gather_methods(lmethod);
}
}
void DexCallSite::gather_fields(std::vector<DexFieldRef*>& lfield) const {
m_linker_method_handle->gather_fields(lfield);
for (auto& ev : m_linker_method_args) {
ev->gather_fields(lfield);
}
}
DexEncodedValueArray DexCallSite::as_encoded_value_array() const {
auto aev = std::make_unique<std::vector<std::unique_ptr<DexEncodedValue>>>();
aev->reserve(m_linker_method_args.size() + 3);
aev->emplace_back(new DexEncodedValueMethodHandle(m_linker_method_handle));
aev->emplace_back(new DexEncodedValueString(m_linker_method_name));
aev->emplace_back(new DexEncodedValueMethodType(m_linker_method_type));
for (auto& arg : m_linker_method_args) {
aev->emplace_back(arg->clone());
}
return DexEncodedValueArray(aev.release(), true);
}