-
Notifications
You must be signed in to change notification settings - Fork 13
/
Version.cs
117 lines (92 loc) · 2.68 KB
/
Version.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UnluacNET
{
public abstract class Version
{
public static readonly Version LUA51 = new Version51();
public static readonly Version LUA52 = new Version52();
protected int m_versionNumber;
public abstract bool HasHeaderTail { get; }
public abstract int OuterBlockScopeAdjustment { get; }
public abstract Op TForTarget { get; }
public abstract bool UsesInlineUpvalueDeclaritions { get; }
public abstract bool UsesOldLoadNilEncoding { get; }
public abstract LFunctionType GetLFunctionType();
public abstract bool IsBreakableLoopEnd(Op op);
public OpcodeMap GetOpcodeMap()
{
return new OpcodeMap(m_versionNumber);
}
protected Version(int versionNumber)
{
m_versionNumber = versionNumber;
}
}
public sealed class Version51 : Version
{
public override bool HasHeaderTail
{
get { return false; }
}
public override int OuterBlockScopeAdjustment
{
get { return -1; }
}
public override Op TForTarget
{
get { return Op.TFORLOOP; }
}
public override bool UsesInlineUpvalueDeclaritions
{
get { return true; }
}
public override bool UsesOldLoadNilEncoding
{
get { return true; }
}
public override LFunctionType GetLFunctionType()
{
return LFunctionType.TYPE51;
}
public override bool IsBreakableLoopEnd(Op op)
{
return (op == Op.JMP || op == Op.FORLOOP);
}
public Version51() : base(0x51) { }
}
public sealed class Version52 : Version
{
public override bool HasHeaderTail
{
get { return true; }
}
public override int OuterBlockScopeAdjustment
{
get { return 0; }
}
public override Op TForTarget
{
get { return Op.TFORCALL; }
}
public override bool UsesInlineUpvalueDeclaritions
{
get { return false; }
}
public override bool UsesOldLoadNilEncoding
{
get { return false; }
}
public override LFunctionType GetLFunctionType()
{
return LFunctionType.TYPE52;
}
public override bool IsBreakableLoopEnd(Op op)
{
return (op == Op.JMP || op == Op.FORLOOP || op == Op.TFORLOOP);
}
public Version52() : base(0x52) { }
}
}