-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytecode.cpp
More file actions
65 lines (63 loc) · 2.14 KB
/
Copy pathbytecode.cpp
File metadata and controls
65 lines (63 loc) · 2.14 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
#include "extract.h"
struct instruction currentInstruction;
/*
* Function for obtaining the string representation of each instruction
* The return value will be <instruction> <number of operands>
*/
void setCurrentInstruction(uint8_t opcode){
switch (opcode){
case 0x02:
currentInstruction.instrName = "iconst_m1";
currentInstruction.numOperands = 0;
return;
case 0x03:
currentInstruction.instrName = "iconst_0";
currentInstruction.numOperands = 0;
return;
case 0x04:
currentInstruction.instrName = "iconst_1";
currentInstruction.numOperands = 0;
return;
case 0x05:
currentInstruction.instrName = "iconst_2";
currentInstruction.numOperands = 0;
return;
case 0x06:
currentInstruction.instrName = "iconst_3";
currentInstruction.numOperands = 0;
return;
case 0x07:
currentInstruction.instrName = "iconst_4";
currentInstruction.numOperands = 0;
return;
case 0x08:
currentInstruction.instrName = "iconst_5";
currentInstruction.numOperands = 0;
return;
case 0x2a:
currentInstruction.instrName = "aload_0";
currentInstruction.numOperands = 0;
return;
case 0xb1:
currentInstruction.instrName = "return";
currentInstruction.numOperands = 0;
return;
case 0xb2:
currentInstruction.instrName = "getstatic";
currentInstruction.numOperands = 2;
return;
case 0xb6:
currentInstruction.instrName = "invokevirtual";
currentInstruction.numOperands = 2;
return;
case 0xb7:
currentInstruction.instrName = "invokespecial";
currentInstruction.numOperands = 2;
return;
default :
currentInstruction.instrName = "";
currentInstruction.numOperands = -1;
currentInstruction.operand1 = -1;
currentInstruction.operand2 = -1;
}
}