forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDexOpcodeDefs.cpp
More file actions
76 lines (67 loc) · 1.86 KB
/
Copy pathDexOpcodeDefs.cpp
File metadata and controls
76 lines (67 loc) · 1.86 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
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "DexOpcodeDefs.h"
#include <sstream>
#include <stdexcept>
std::string print(DexOpcode opcode) {
/* clang-format off */
switch (opcode) {
#define OP(op, code, fmt, literal) \
case DOPCODE_##op: \
return #literal;
DOPS QDOPS
#undef OP
case FOPCODE_PACKED_SWITCH:
return "PACKED_SWITCH_DATA";
case FOPCODE_SPARSE_SWITCH:
return "SPARSE_SWITCH_DATA";
case FOPCODE_FILLED_ARRAY:
return "FILLED_ARRAY_DATA";
default:
return "NO_VALID_OPCODE";
}
/* clang-format on */
}
DexOpcode quicken(DexOpcode opcode) {
switch (opcode) {
case DOPCODE_RETURN_VOID:
return DOPCODE_RETURN_VOID_NO_BARRIER;
case DOPCODE_IGET:
return DOPCODE_IGET_QUICK;
case DOPCODE_IGET_WIDE:
return DOPCODE_IGET_WIDE_QUICK;
case DOPCODE_IGET_OBJECT:
return DOPCODE_IGET_OBJECT_QUICK;
case DOPCODE_IGET_BOOLEAN:
return DOPCODE_IGET_BOOLEAN_QUICK;
case DOPCODE_IGET_BYTE:
return DOPCODE_IGET_BYTE_QUICK;
case DOPCODE_IGET_CHAR:
return DOPCODE_IGET_CHAR_QUICK;
case DOPCODE_IGET_SHORT:
return DOPCODE_IGET_SHORT_QUICK;
case DOPCODE_IPUT:
return DOPCODE_IPUT_QUICK;
case DOPCODE_IPUT_WIDE:
return DOPCODE_IPUT_WIDE_QUICK;
case DOPCODE_IPUT_OBJECT:
return DOPCODE_IPUT_OBJECT_QUICK;
case DOPCODE_IPUT_BOOLEAN:
return DOPCODE_IPUT_BOOLEAN_QUICK;
case DOPCODE_IPUT_BYTE:
return DOPCODE_IPUT_BYTE_QUICK;
case DOPCODE_IPUT_CHAR:
return DOPCODE_IPUT_CHAR_QUICK;
case DOPCODE_IPUT_SHORT:
return DOPCODE_IPUT_SHORT_QUICK;
default:
std::ostringstream msg;
msg << std::string("Can't quicken opcode: ") << std::hex
<< (uint16_t)opcode;
throw std::invalid_argument(msg.str());
}
}