forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkvast
95 lines (74 loc) · 1.14 KB
/
kvast
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
kvast
=====
KeyValue storage for AST
To optimize serialized storage use a concatenated
string array and use the sdb array string api
eax=33
------
0.op=set []0=set,eax,33
0.a=eax
0.b=33
ebx=(8*(eax+4))
---------------
0.op=set []0=set,ebx,$1
0.a=ebx
0.b=$1
1.op=mul []1=mul,8,$2
1.a=8
1.b=$2
2.op=add []2=add,eax,4
2.a=eax
2.b=4
ebx=8*(eax+4)+3
---------------
0.op=set []0=set,ebx,$3
0.a=ebx
0.b=$3
1.op=mul []1=mul,8,$2
1.a=8
1.b=$2
2.op=add []2=add,eax,4
2.a=eax
2.b=4
3.op=add []3=add,$1,3
3.a=$1
3.b=3
ebx=8*(eax+4+ecx+2)+1
---------------------
0.op=set
0.a=ebx
0.b=$5
1.op=mul
1.a=8
1.b=$4
(
2.op=add
2.a=eax
2.b=4
// update toplevel b reference
3.op=add
3.a=$2
3.b=ecx
// update toplevel b reference
4.op=add
4.a=$3
4.b=2
}
// update toplevel b reference
5.op=add
5.a=$1
5.b=1
Parsing
=======
Parsing is done by a state machine which reads the expression string and creates a keyvalue string that represents the ESIL instruction.
This is an example
switch (ch) {
case '+':
case '-':
case '*':
case '/':
if (expect_arg) {
expect_arg = ch;
}
break;
}