Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ParticleContentValidator.cs
Go to the documentation of this file.
3
4namespace System.Xml.Schema;
5
7{
9
11
13
15
16 private bool _isPartial;
17
18 private int _minMaxNodesCount;
19
20 private readonly bool _enableUpaCheck;
21
26
32
33 public override void InitValidation(ValidationState context)
34 {
35 throw new InvalidOperationException();
36 }
37
38 public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
39 {
40 throw new InvalidOperationException();
41 }
42
43 public override bool CompleteValidation(ValidationState context)
44 {
45 throw new InvalidOperationException();
46 }
47
48 public void Start()
49 {
51 _positions = new Positions();
53 }
54
55 public void OpenGroup()
56 {
57 _stack.Push(null);
58 }
59
60 public void CloseGroup()
61 {
63 if (syntaxTreeNode == null)
64 {
65 return;
66 }
67 if (_stack.Count == 0)
68 {
70 _isPartial = false;
71 return;
72 }
74 if (interiorNode != null)
75 {
78 _isPartial = true;
79 }
80 else
81 {
82 _isPartial = false;
83 }
85 }
86
87 public bool Exists(XmlQualifiedName name)
88 {
89 if (_symbols.Exists(name))
90 {
91 return true;
92 }
93 return false;
94 }
95
96 public void AddName(XmlQualifiedName name, object particle)
97 {
98 AddLeafNode(new LeafNode(_positions.Add(_symbols.AddName(name, particle), particle)));
99 }
100
101 public void AddNamespaceList(NamespaceList namespaceList, object particle)
102 {
103 _symbols.AddNamespaceList(namespaceList, particle, allowLocal: false);
104 AddLeafNode(new NamespaceListNode(namespaceList, particle));
105 }
106
108 {
109 if (_stack.Count > 0)
110 {
112 if (interiorNode != null)
113 {
116 }
117 }
118 _stack.Push(node);
119 _isPartial = true;
120 }
121
129
137
138 public void AddStar()
139 {
140 Closure(new StarNode());
141 }
142
143 public void AddPlus()
144 {
145 Closure(new PlusNode());
146 }
147
148 public void AddQMark()
149 {
150 Closure(new QmarkNode());
151 }
152
163
165 {
166 if (_stack.Count > 0)
167 {
170 if (_isPartial && interiorNode != null)
171 {
172 node.LeftChild = interiorNode.RightChild;
174 }
175 else
176 {
179 }
181 }
182 else if (_contentNode != null)
183 {
186 }
187 }
188
190 {
191 if (_contentNode == null)
192 {
193 if (base.ContentType == XmlSchemaContentType.Mixed)
194 {
195 if (!base.IsOpen)
196 {
198 }
199 return ContentValidator.Any;
200 }
201 return ContentValidator.Empty;
202 }
207 int count = _positions.Count;
208 BitSet bitSet = new BitSet(count);
209 BitSet lastpos = new BitSet(count);
210 BitSet[] array = new BitSet[count];
211 for (int i = 0; i < count; i++)
212 {
213 array[i] = new BitSet(count);
214 }
215 interiorNode.ConstructPos(bitSet, lastpos, array);
216 if (_minMaxNodesCount > 0)
217 {
220 if (_enableUpaCheck)
221 {
223 for (int j = 0; j < count; j++)
224 {
226 }
227 }
229 }
230 int[][] array2 = null;
232 {
233 if (_enableUpaCheck)
234 {
236 }
237 }
238 else if (useDFA)
239 {
241 }
242 if (array2 != null)
243 {
244 return new DfaContentValidator(array2, _symbols, base.ContentType, base.IsOpen, interiorNode.LeftChild.IsNullable);
245 }
246 return new NfaContentValidator(bitSet, array, _symbols, _positions, leafNode.Pos, base.ContentType, base.IsOpen, interiorNode.LeftChild.IsNullable);
247 }
248
250 {
251 int count = _positions.Count;
254 int num = 0;
255 for (int num2 = count - 1; num2 >= 0; num2--)
256 {
257 Position position = _positions[num2];
258 if (position.symbol == -2)
259 {
261 BitSet bitSet = new BitSet(count);
262 bitSet.Clear();
263 bitSet.Or(followpos[num2]);
264 if (leafRangeNode.Min != leafRangeNode.Max)
265 {
266 bitSet.Or(leafRangeNode.NextIteration);
267 }
268 for (int num3 = bitSet.NextSet(-1); num3 != -1; num3 = bitSet.NextSet(num3))
269 {
270 if (num3 > num2)
271 {
273 if (position2.symbol == -2)
274 {
276 bitSet.Or(array[leafRangeNode2.Pos]);
277 }
278 }
279 }
280 array[num] = bitSet;
281 leafRangeNode.Pos = num++;
283 }
284 }
285 return array;
286 }
287
289 {
290 object[] array = new object[_symbols.Count];
291 for (int num = curpos.NextSet(-1); num != -1; num = curpos.NextSet(num))
292 {
293 Position position = _positions[num];
294 int symbol = position.symbol;
295 if (symbol >= 0)
296 {
297 if (array[symbol] != null)
298 {
299 throw new UpaException(array[symbol], position.particle);
300 }
301 array[symbol] = position.particle;
302 }
303 }
304 }
305
307 {
309 {
311 bitSet.Or(curpos);
313 curpos = curpos.Clone();
314 for (int num = bitSet.NextSet(-1); num != -1; num = bitSet.NextSet(num))
315 {
317 curpos.Or(minmaxFollowPos[leafRangeNode.Pos]);
318 }
319 }
320 return curpos;
321 }
322
324 {
326 for (int i = 0; i < _positions.Count; i++)
327 {
329 }
330 }
331
333 {
334 object[] array = new object[_symbols.Count];
335 for (int num = curpos.NextSet(-1); num != -1; num = curpos.NextSet(num))
336 {
337 int symbol = _positions[num].symbol;
338 if (array[symbol] == null)
339 {
340 array[symbol] = _positions[num].particle;
341 }
342 else if (array[symbol] != _positions[num].particle)
343 {
344 throw new UpaException(array[symbol], _positions[num].particle);
345 }
346 }
347 }
348
349 private int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos)
350 {
351 int count = _positions.Count;
352 int num = 8192 / count;
353 int count2 = _symbols.Count;
355 Hashtable hashtable = new Hashtable();
356 hashtable.Add(new BitSet(count), -1);
358 int num2 = 0;
359 queue.Enqueue(firstpos);
360 hashtable.Add(firstpos, 0);
361 arrayList.Add(new int[count2 + 1]);
362 while (queue.Count > 0)
363 {
364 BitSet bitSet = queue.Dequeue();
365 int[] array = (int[])arrayList[num2];
366 if (bitSet[endMarkerPos])
367 {
368 array[count2] = 1;
369 }
370 for (int i = 0; i < count2; i++)
371 {
372 BitSet bitSet2 = new BitSet(count);
373 for (int num3 = bitSet.NextSet(-1); num3 != -1; num3 = bitSet.NextSet(num3))
374 {
375 if (i == _positions[num3].symbol)
376 {
378 }
379 }
380 object obj = hashtable[bitSet2];
381 if (obj != null)
382 {
383 array[i] = (int)obj;
384 continue;
385 }
386 int num4 = hashtable.Count - 1;
387 if (num4 >= num)
388 {
389 return null;
390 }
391 queue.Enqueue(bitSet2);
392 hashtable.Add(bitSet2, num4);
393 arrayList.Add(new int[count2 + 1]);
394 array[i] = num4;
395 }
396 num2++;
397 }
398 return (int[][])arrayList.ToArray(typeof(int[]));
399 }
400}
void Add(TKey key, TValue value)
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
int NextSet(int startFrom)
Definition BitSet.cs:68
void Or(BitSet other)
Definition BitSet.cs:113
bool Intersects(BitSet other)
Definition BitSet.cs:190
static readonly ContentValidator Empty
static readonly ContentValidator Any
static readonly ContentValidator TextOnly
void AddName(XmlQualifiedName name, object particle)
override bool CompleteValidation(ValidationState context)
void CheckUniqueParticleAttribution(BitSet firstpos, BitSet[] followpos)
override void InitValidation(ValidationState context)
int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos)
BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos)
override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
ParticleContentValidator(XmlSchemaContentType contentType)
BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals)
ParticleContentValidator(XmlSchemaContentType contentType, bool enableUpaCheck)
void AddNamespaceList(NamespaceList namespaceList, object particle)
int Add(int symbol, object particle)
Definition Positions.cs:13
bool Exists(XmlQualifiedName name)
int AddName(XmlQualifiedName name, object particle)
void AddNamespaceList(NamespaceList list, object particle, bool allowLocal)
void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions)
static readonly XmlQualifiedName Empty