-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathCodePath.cs
89 lines (78 loc) · 2.2 KB
/
CodePath.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decompiler
{
//Not a fan of this code, should really have been handled using a tree but too far into project to change this now
internal class CodePath
{
public CodePath Parent;
public int EndOffset;
public int BreakOffset;
public CodePathType Type;
public List<CodePath> ChildPaths;
public CodePath(CodePathType Type, int EndOffset, int BreakOffset)
{
Parent = null;
this.Type = Type;
this.EndOffset = EndOffset;
this.BreakOffset = BreakOffset;
ChildPaths = new List<CodePath>();
}
public CodePath(CodePath Parent, CodePathType Type, int EndOffset, int BreakOffset)
{
this.Parent = Parent;
this.Type = Type;
this.EndOffset = EndOffset;
this.BreakOffset = BreakOffset;
ChildPaths = new List<CodePath>();
}
public CodePath CreateCodePath(CodePathType Type, int EndOffset, int BreakOffset)
{
CodePath C = new CodePath(this, Type, EndOffset, BreakOffset);
this.ChildPaths.Add(C);
return C;
}
}
internal enum CodePathType
{
While,
If,
Else,
Main
}
internal class SwitchStatement
{
public Dictionary<int, List<string>> Cases;
public List<int> Offsets;
public int breakoffset;
public SwitchStatement Parent;
public List<SwitchStatement> ChildSwitches;
public SwitchStatement(Dictionary<int, List<string>> Cases, int BreakOffset)
{
Parent = null;
this.Cases = Cases;
this.breakoffset = BreakOffset;
ChildSwitches = new List<SwitchStatement>();
Offsets = Cases == null ? new List<int>() : Cases.Keys.ToList();
Offsets.Add(BreakOffset);
}
public SwitchStatement(SwitchStatement Parent, Dictionary<int, List<string>> Cases, int BreakOffset)
{
this.Parent = Parent;
this.Cases = Cases;
this.breakoffset = BreakOffset;
ChildSwitches = new List<SwitchStatement>();
Offsets = Cases == null ? new List<int>() : Cases.Keys.ToList();
Offsets.Add(BreakOffset);
}
public SwitchStatement CreateSwitchStatement(Dictionary<int, List<string>> Cases, int BreakOffset)
{
SwitchStatement S = new SwitchStatement(this, Cases, BreakOffset);
this.ChildSwitches.Add(S);
return S;
}
}
}