Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LabelInfo.cs
Go to the documentation of this file.
2
4
5internal sealed class LabelInfo
6{
7 private readonly LabelTarget _node;
8
10
11 private object _definitions;
12
14
15 private bool _acrossBlockJump;
16
17 private bool HasDefinitions => _definitions != null;
18
20
22 {
23 _node = node;
24 }
25
31
33 {
36 {
38 }
39 }
40
42 {
44 {
45 if (labelScopeInfo.ContainsTarget(_node))
46 {
48 }
49 }
51 block.AddLabelInfo(_node, this);
53 {
55 {
57 }
58 return;
59 }
61 {
63 }
64 _label = null;
65 }
66
68 {
70 {
72 {
73 return;
74 }
75 if (labelScopeInfo.Kind == LabelScopeKind.Finally || labelScopeInfo.Kind == LabelScopeKind.Filter)
76 {
77 break;
78 }
79 }
80 _acrossBlockJump = true;
81 if (_node != null && _node.Type != typeof(void))
82 {
84 }
86 {
88 }
92 {
93 if (labelScopeInfo4.Kind == LabelScopeKind.Finally)
94 {
96 }
97 if (labelScopeInfo4.Kind == LabelScopeKind.Filter)
98 {
100 }
101 }
103 {
104 if (!labelScopeInfo5.CanJumpInto)
105 {
106 if (labelScopeInfo5.Kind == LabelScopeKind.Expression)
107 {
109 }
111 }
112 }
113 }
114
115 internal void ValidateFinish()
116 {
117 if (_references.Count > 0 && !HasDefinitions)
118 {
120 }
121 }
122
124 {
125 if (_label == null)
126 {
127 _label = compiler.Instructions.MakeLabel();
128 }
129 }
130
131 private bool DefinedIn(LabelScopeInfo scope)
132 {
133 if (_definitions == scope)
134 {
135 return true;
136 }
138 {
139 return hashSet.Contains(scope);
140 }
141 return false;
142 }
143
145 {
146 if (_definitions is LabelScopeInfo result)
147 {
148 return result;
149 }
151 {
152 if (enumerator.MoveNext())
153 {
154 return enumerator.Current;
155 }
156 }
157 throw new InvalidOperationException();
158 }
159
160 private void AddDefinition(LabelScopeInfo scope)
161 {
162 if (_definitions == null)
163 {
164 _definitions = scope;
165 return;
166 }
168 if (hashSet == null)
169 {
171 hashSet = obj;
173 }
174 hashSet.Add(scope);
175 }
176
177 internal static T CommonNode<T>(T first, T second, Func<T, T> parent) where T : class
178 {
179 EqualityComparer<T> @default = EqualityComparer<T>.Default;
180 if (@default.Equals(first, second))
181 {
182 return first;
183 }
184 HashSet<T> hashSet = new HashSet<T>(@default);
185 for (T val = first; val != null; val = parent(val))
186 {
187 hashSet.Add(val);
188 }
189 for (T val2 = second; val2 != null; val2 = parent(val2))
190 {
191 if (hashSet.Contains(val2))
192 {
193 return val2;
194 }
195 }
196 return null;
197 }
198}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
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
void ValidateJump(LabelScopeInfo reference)
Definition LabelInfo.cs:67
BranchLabel GetLabel(LightCompiler compiler)
Definition LabelInfo.cs:26
void EnsureLabel(LightCompiler compiler)
Definition LabelInfo.cs:123
void Reference(LabelScopeInfo block)
Definition LabelInfo.cs:32
readonly List< LabelScopeInfo > _references
Definition LabelInfo.cs:13
static T CommonNode< T >(T first, T second, Func< T, T > parent)
Definition LabelInfo.cs:177
void AddDefinition(LabelScopeInfo scope)
Definition LabelInfo.cs:160