-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpCode.cs
executable file
·60 lines (53 loc) · 1.98 KB
/
OpCode.cs
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
using System;
using System.Collections.Generic;
using System.Text;
using Mono.Cecil.Cil;
namespace Escan.Engine
{
internal class OpCode
{
internal static bool IsACallInstruction(Instruction oInstr)
{
return oInstr.OpCode == OpCodes.Call ||
oInstr.OpCode == OpCodes.Calli ||
oInstr.OpCode == OpCodes.Callvirt ||
oInstr.OpCode == OpCodes.Newobj;
//FIXME: we should study this case:
// || anInstruction.OpCode == OpCodes.Newarr;
}
internal static bool IsAPopInstruction(Instruction oInstr)
{
return oInstr.OpCode == OpCodes.Pop;
}
//for arrays/vectors
internal static bool IsAStelemRef(Instruction oInstr)
{
return oInstr.OpCode == OpCodes.Stelem_Ref;
//TODO: perhaps there are more
}
//Para saber si una instruccion es un ldarg
internal static bool IsALdargInstruction(Instruction oInstr)
{
return oInstr.OpCode == OpCodes.Ldarg ||
oInstr.OpCode == OpCodes.Ldarg_0 ||
oInstr.OpCode == OpCodes.Ldarg_1 ||
oInstr.OpCode == OpCodes.Ldarg_2 ||
oInstr.OpCode == OpCodes.Ldarg_3 ||
oInstr.OpCode == OpCodes.Ldarg_S;
//FIXME: what is OpCodes.Ldarga?
}
internal static bool IsAStlocInstruction(Instruction oInstr)
{
return oInstr.OpCode == OpCodes.Stloc ||
oInstr.OpCode == OpCodes.Stloc_0 ||
oInstr.OpCode == OpCodes.Stloc_1 ||
oInstr.OpCode == OpCodes.Stloc_2 ||
oInstr.OpCode == OpCodes.Stloc_3 ||
oInstr.OpCode == OpCodes.Stloc_S;
}
internal static bool IsARet(Instruction oInstr)
{
return oInstr.Next.OpCode == OpCodes.Ret;
}
}
}