Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LabelInfo.cs
Go to the documentation of this file.
4
6
7internal sealed class LabelInfo
8{
9 private readonly LabelTarget _node;
10
11 private Label _label;
12
13 private bool _labelDefined;
14
16
18
20
21 private readonly bool _canReturn;
22
23 private bool _acrossBlockJump;
24
26
27 private readonly ILGenerator _ilg;
28
29 internal Label Label
30 {
31 get
32 {
34 return _label;
35 }
36 }
37
38 internal bool CanReturn => _canReturn;
39
40 internal bool CanBranch => _opCode != OpCodes.Leave;
41
43 {
44 _ilg = il;
45 _node = node;
47 }
48
50 {
52 if (_definitions.Count > 0)
53 {
55 }
56 }
57
59 {
61 {
62 if (labelScopeInfo.ContainsTarget(_node))
63 {
65 }
66 }
68 block.AddLabelInfo(_node, this);
69 if (_definitions.Count == 1)
70 {
72 {
74 }
75 return;
76 }
78 {
80 }
81 _labelDefined = false;
82 }
83
85 {
86 _opCode = (_canReturn ? OpCodes.Ret : OpCodes.Br);
88 {
90 {
91 return;
92 }
93 if (labelScopeInfo.Kind == LabelScopeKind.Finally || labelScopeInfo.Kind == LabelScopeKind.Filter)
94 {
95 break;
96 }
97 if (labelScopeInfo.Kind == LabelScopeKind.Try || labelScopeInfo.Kind == LabelScopeKind.Catch)
98 {
100 }
101 }
102 _acrossBlockJump = true;
103 if (_node != null && _node.Type != typeof(void))
104 {
106 }
107 if (_definitions.Count > 1)
108 {
110 }
113 _opCode = (_canReturn ? OpCodes.Ret : OpCodes.Br);
115 {
116 if (labelScopeInfo4.Kind == LabelScopeKind.Finally)
117 {
119 }
120 if (labelScopeInfo4.Kind == LabelScopeKind.Filter)
121 {
123 }
124 if (labelScopeInfo4.Kind == LabelScopeKind.Try || labelScopeInfo4.Kind == LabelScopeKind.Catch)
125 {
127 }
128 }
130 {
131 if (!labelScopeInfo5.CanJumpInto)
132 {
133 if (labelScopeInfo5.Kind == LabelScopeKind.Expression)
134 {
136 }
138 }
139 }
140 }
141
142 internal void ValidateFinish()
143 {
144 if (_references.Count > 0 && _definitions.Count == 0)
145 {
147 }
148 }
149
150 internal void EmitJump()
151 {
152 if (_opCode == OpCodes.Ret)
153 {
155 return;
156 }
157 StoreValue();
159 }
160
161 private void StoreValue()
162 {
164 if (_value != null)
165 {
167 }
168 }
169
170 internal void Mark()
171 {
172 if (_canReturn)
173 {
174 if (!_labelDefined)
175 {
176 return;
177 }
179 }
180 else
181 {
182 StoreValue();
183 }
185 }
186
187 internal void MarkWithEmptyStack()
188 {
190 if (_value != null)
191 {
193 }
194 }
195
196 private void EnsureLabelAndValue()
197 {
198 if (!_labelDefined)
199 {
200 _labelDefined = true;
202 if (_node != null && _node.Type != typeof(void))
203 {
205 }
206 }
207 }
208}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
void Reference(LabelScopeInfo block)
Definition LabelInfo.cs:49
readonly List< LabelScopeInfo > _references
Definition LabelInfo.cs:19
void ValidateJump(LabelScopeInfo reference)
Definition LabelInfo.cs:84
LabelInfo(ILGenerator il, LabelTarget node, bool canReturn)
Definition LabelInfo.cs:42
readonly HashSet< LabelScopeInfo > _definitions
Definition LabelInfo.cs:17
void Define(LabelScopeInfo block)
Definition LabelInfo.cs:58
static Exception ControlCannotLeaveFilterTest()
Definition Error.cs:728
static Exception NonLocalJumpWithValue(object p0)
Definition Error.cs:748
static Exception ControlCannotLeaveFinally()
Definition Error.cs:723
static Exception ControlCannotEnterTry()
Definition Error.cs:738
static Exception ControlCannotEnterExpression()
Definition Error.cs:743
static Exception LabelTargetUndefined(object p0)
Definition Error.cs:718
static Exception AmbiguousJump(object p0)
Definition Error.cs:733
static Exception LabelTargetAlreadyDefined(object p0)
Definition Error.cs:713
virtual LocalBuilder DeclareLocal(Type localType)
virtual void MarkLabel(Label loc)
virtual void Emit(OpCode opcode)
static readonly OpCode Leave
Definition OpCodes.cs:379
static readonly OpCode Stloc
Definition OpCodes.cs:429
static readonly OpCode Br
Definition OpCodes.cs:115
static readonly OpCode Ret
Definition OpCodes.cs:87
static readonly OpCode Ldloc
Definition OpCodes.cs:425