Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
ContainerAction.cs
Go to the documentation of this file.
6
8
10{
12
14
15 private int _maxid;
16
17 internal override void Compile(Compiler compiler)
18 {
19 throw new NotImplementedException();
20 }
21
23 {
25 string localName = input.LocalName;
26 string text = null;
27 string text2 = null;
28 if (input.MoveToFirstAttribute())
29 {
30 do
31 {
32 string namespaceURI = input.NamespaceURI;
33 string localName2 = input.LocalName;
34 if (namespaceURI.Length != 0)
35 {
36 continue;
37 }
38 if (Ref.Equal(localName2, input.Atoms.Version))
39 {
40 text2 = input.Value;
41 if (1.0 <= XmlConvert.ToXPathDouble(text2))
42 {
44 }
45 else if (!compiler.ForwardCompatibility)
46 {
48 }
49 }
50 else if (Ref.Equal(localName2, input.Atoms.ExtensionElementPrefixes))
51 {
52 compiler.InsertExtensionNamespace(input.Value);
53 }
54 else if (Ref.Equal(localName2, input.Atoms.ExcludeResultPrefixes))
55 {
56 compiler.InsertExcludedNamespace(input.Value);
57 }
58 else if (!Ref.Equal(localName2, input.Atoms.Id))
59 {
61 }
62 }
63 while (input.MoveToNextAttribute());
64 input.ToParent();
65 }
66 if (text2 == null)
67 {
69 }
70 if (text != null && !compiler.ForwardCompatibility)
71 {
73 }
74 }
75
77 {
79 string text = null;
80 if (input.MoveToFirstAttribute())
81 {
82 do
83 {
85 string localName = input.LocalName;
86 if (Ref.Equal(namespaceURI, input.Atoms.UriXsl) && Ref.Equal(localName, input.Atoms.Version))
87 {
88 text = input.Value;
89 }
90 }
91 while (input.MoveToNextAttribute());
92 input.ToParent();
93 }
94 if (text == null)
95 {
96 if (Ref.Equal(input.LocalName, input.Atoms.Stylesheet) && input.NamespaceURI == "http://www.w3.org/TR/WD-xsl")
97 {
99 }
101 }
102 compiler.AddTemplate(compiler.CreateSingleTemplateAction());
103 }
104
106 {
108 while (input.NodeType != XPathNodeType.Element)
109 {
110 if (!compiler.Advance())
111 {
113 }
114 }
115 if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl))
116 {
117 if (!Ref.Equal(input.LocalName, input.Atoms.Stylesheet) && !Ref.Equal(input.LocalName, input.Atoms.Transform))
118 {
120 }
121 compiler.PushNamespaceScope();
124 if (!inInclude)
125 {
127 }
128 }
129 else
130 {
131 compiler.PushLiteralScope();
133 }
134 compiler.PopScope();
135 }
136
138 {
139 NavigatorInput navigatorInput = compiler.ResolveDocument(uri);
140 compiler.PushInputDocument(navigatorInput);
141 try
142 {
143 compiler.PushStylesheet(new Stylesheet());
146 }
148 {
149 throw;
150 }
151 catch (Exception inner)
152 {
153 throw new XsltCompileException(inner, navigatorInput.BaseURI, navigatorInput.LineNumber, navigatorInput.LinePosition);
154 }
155 finally
156 {
157 compiler.PopInputDocument();
158 }
159 return compiler.PopStylesheet();
160 }
161
163 {
164 ArrayList imports = compiler.CompiledStylesheet.Imports;
165 int stylesheetid = compiler.Stylesheetid;
166 int num = imports.Count - 1;
167 while (0 <= num)
168 {
169 Uri uri = imports[num] as Uri;
170 imports[num] = CompileImport(compiler, uri, ++_maxid);
171 num--;
172 }
173 compiler.Stylesheetid = stylesheetid;
174 }
175
177 {
178 Uri uri = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
179 string text = uri.ToString();
180 if (compiler.IsCircularReference(text))
181 {
183 }
184 NavigatorInput navigatorInput = compiler.ResolveDocument(uri);
185 compiler.PushInputDocument(navigatorInput);
186 try
187 {
189 }
191 {
192 throw;
193 }
194 catch (Exception inner)
195 {
196 throw new XsltCompileException(inner, navigatorInput.BaseURI, navigatorInput.LineNumber, navigatorInput.LinePosition);
197 }
198 finally
199 {
200 compiler.PopInputDocument();
201 }
203 }
204
206 {
208 string localName = input.LocalName;
209 string text = null;
210 string text2 = null;
211 string text3 = null;
212 string prefix = null;
213 if (input.MoveToFirstAttribute())
214 {
215 do
216 {
217 string namespaceURI = input.NamespaceURI;
218 string localName2 = input.LocalName;
219 if (namespaceURI.Length == 0)
220 {
221 if (Ref.Equal(localName2, input.Atoms.StylesheetPrefix))
222 {
223 text3 = input.Value;
224 text = compiler.GetNsAlias(ref text3);
225 }
226 else if (Ref.Equal(localName2, input.Atoms.ResultPrefix))
227 {
228 prefix = input.Value;
229 text2 = compiler.GetNsAlias(ref prefix);
230 }
231 else if (!compiler.ForwardCompatibility)
232 {
234 }
235 }
236 }
237 while (input.MoveToNextAttribute());
238 input.ToParent();
239 }
240 CheckRequiredAttribute(compiler, text, "stylesheet-prefix");
241 CheckRequiredAttribute(compiler, text2, "result-prefix");
243 compiler.AddNamespaceAlias(text, new NamespaceInfo(prefix, text2, compiler.Stylesheetid));
244 }
245
247 {
249 string localName = input.LocalName;
250 int num = -1;
251 int num2 = -1;
253 if (input.MoveToFirstAttribute())
254 {
255 do
256 {
257 string namespaceURI = input.NamespaceURI;
258 string localName2 = input.LocalName;
259 string value = input.Value;
260 if (namespaceURI.Length == 0)
261 {
262 if (Ref.Equal(localName2, input.Atoms.Name))
263 {
264 xmlQualifiedName = compiler.CreateXPathQName(value);
265 }
266 else if (Ref.Equal(localName2, input.Atoms.Match))
267 {
268 num = compiler.AddQuery(value, allowVar: false, allowKey: false, isPattern: true);
269 }
270 else if (Ref.Equal(localName2, input.Atoms.Use))
271 {
272 num2 = compiler.AddQuery(value, allowVar: false, allowKey: false, isPattern: false);
273 }
274 else if (!compiler.ForwardCompatibility)
275 {
277 }
278 }
279 }
280 while (input.MoveToNextAttribute());
281 input.ToParent();
282 }
283 CheckRequiredAttribute(compiler, num != -1, "match");
284 CheckRequiredAttribute(compiler, num2 != -1, "use");
286 compiler.InsertKey(xmlQualifiedName, num, num2);
287 }
288
290 {
295 if (input.MoveToFirstAttribute())
296 {
297 do
298 {
299 if (input.Prefix.Length != 0)
300 {
301 continue;
302 }
303 string localName = input.LocalName;
304 string value = input.Value;
305 if (Ref.Equal(localName, input.Atoms.Name))
306 {
307 xmlQualifiedName = compiler.CreateXPathQName(value);
308 }
309 else if (Ref.Equal(localName, input.Atoms.DecimalSeparator))
310 {
312 }
313 else if (Ref.Equal(localName, input.Atoms.GroupingSeparator))
314 {
316 }
317 else if (Ref.Equal(localName, input.Atoms.Infinity))
318 {
320 }
321 else if (Ref.Equal(localName, input.Atoms.MinusSign))
322 {
324 }
325 else if (Ref.Equal(localName, input.Atoms.NaN))
326 {
328 }
329 else if (Ref.Equal(localName, input.Atoms.Percent))
330 {
332 }
333 else if (Ref.Equal(localName, input.Atoms.PerMille))
334 {
336 }
337 else if (Ref.Equal(localName, input.Atoms.Digit))
338 {
339 if (CheckAttribute(value.Length == 1, compiler))
340 {
342 }
343 }
344 else if (Ref.Equal(localName, input.Atoms.ZeroDigit))
345 {
346 if (CheckAttribute(value.Length == 1, compiler))
347 {
349 }
350 }
351 else if (Ref.Equal(localName, input.Atoms.PatternSeparator) && CheckAttribute(value.Length == 1, compiler))
352 {
354 }
355 }
356 while (input.MoveToNextAttribute());
357 input.ToParent();
358 }
360 if (xmlQualifiedName == null)
361 {
363 }
364 compiler.AddDecimalFormat(xmlQualifiedName, decimalFormat);
366 }
367
369 {
370 if (!valid)
371 {
372 if (!compiler.ForwardCompatibility)
373 {
374 throw XsltException.Create(System.SR.Xslt_InvalidAttrValue, compiler.Input.LocalName, compiler.Input.Value);
375 }
376 return false;
377 }
378 return true;
379 }
380
382 {
383 string singleAttribute = compiler.GetSingleAttribute(compiler.Input.Atoms.Elements);
385 for (int i = 0; i < array.Length; i++)
386 {
387 double priority = NameTest(array[i]);
388 compiler.CompiledStylesheet.AddSpace(compiler, array[i], priority, preserve);
389 }
391 }
392
393 private double NameTest(string name)
394 {
395 if (name == "*")
396 {
397 return -0.5;
398 }
399 int num = name.Length - 2;
400 if (0 <= num && name[num] == ':' && name[num + 1] == '*')
401 {
402 if (!PrefixQName.ValidatePrefix(name.Substring(0, num)))
403 {
404 throw XsltException.Create(System.SR.Xslt_InvalidAttrValue, "elements", name);
405 }
406 return -0.25;
407 }
409 return 0.0;
410 }
411
413 {
414 if (!compiler.Recurse())
415 {
416 return;
417 }
419 bool flag = false;
420 do
421 {
422 switch (input.NodeType)
423 {
424 case XPathNodeType.Element:
425 {
426 string localName = input.LocalName;
427 string namespaceURI = input.NamespaceURI;
428 if (Ref.Equal(namespaceURI, input.Atoms.UriXsl))
429 {
430 if (Ref.Equal(localName, input.Atoms.Import))
431 {
432 if (flag)
433 {
435 }
436 Uri uri = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
437 string text = uri.ToString();
438 if (compiler.IsCircularReference(text))
439 {
441 }
442 compiler.CompiledStylesheet.Imports.Add(uri);
444 break;
445 }
446 if (Ref.Equal(localName, input.Atoms.Include))
447 {
448 flag = true;
450 break;
451 }
452 flag = true;
453 compiler.PushNamespaceScope();
454 if (Ref.Equal(localName, input.Atoms.StripSpace))
455 {
457 }
458 else if (Ref.Equal(localName, input.Atoms.PreserveSpace))
459 {
461 }
462 else if (Ref.Equal(localName, input.Atoms.Output))
463 {
465 }
466 else if (Ref.Equal(localName, input.Atoms.Key))
467 {
469 }
470 else if (Ref.Equal(localName, input.Atoms.DecimalFormat))
471 {
473 }
474 else if (Ref.Equal(localName, input.Atoms.NamespaceAlias))
475 {
477 }
478 else if (Ref.Equal(localName, input.Atoms.AttributeSet))
479 {
480 compiler.AddAttributeSet(compiler.CreateAttributeSetAction());
481 }
482 else if (Ref.Equal(localName, input.Atoms.Variable))
483 {
484 VariableAction variableAction = compiler.CreateVariableAction(VariableType.GlobalVariable);
485 if (variableAction != null)
486 {
488 }
489 }
490 else if (Ref.Equal(localName, input.Atoms.Param))
491 {
492 VariableAction variableAction2 = compiler.CreateVariableAction(VariableType.GlobalParameter);
493 if (variableAction2 != null)
494 {
496 }
497 }
498 else if (Ref.Equal(localName, input.Atoms.Template))
499 {
500 compiler.AddTemplate(compiler.CreateTemplateAction());
501 }
502 else if (!compiler.ForwardCompatibility)
503 {
504 throw compiler.UnexpectedKeyword();
505 }
506 compiler.PopScope();
507 }
508 else if (namespaceURI == input.Atoms.UrnMsxsl && localName == input.Atoms.Script)
509 {
511 }
512 else if (namespaceURI.Length == 0)
513 {
515 }
516 break;
517 }
518 default:
520 case XPathNodeType.SignificantWhitespace:
521 case XPathNodeType.Whitespace:
522 case XPathNodeType.ProcessingInstruction:
523 case XPathNodeType.Comment:
524 break;
525 }
526 }
527 while (compiler.Advance());
528 compiler.ToParent();
529 }
530
532 {
533 do
534 {
536 }
537 while (compiler.Advance());
538 }
539
541 {
543 if (input.NodeType == XPathNodeType.Element)
544 {
546 if (Ref.Equal(namespaceURI, input.Atoms.UriXsl))
547 {
548 compiler.PushNamespaceScope();
550 compiler.PopScope();
551 return;
552 }
553 compiler.PushLiteralScope();
554 compiler.InsertExtensionNamespace();
555 if (compiler.IsExtensionNamespace(namespaceURI))
556 {
557 AddAction(compiler.CreateNewInstructionAction());
558 }
559 else
560 {
562 }
563 compiler.PopScope();
564 }
565 else
566 {
568 }
569 }
570
572 {
575 string localName = input.LocalName;
576 if (Ref.Equal(localName, input.Atoms.ApplyImports))
577 {
578 compiledAction = compiler.CreateApplyImportsAction();
579 }
580 else if (Ref.Equal(localName, input.Atoms.ApplyTemplates))
581 {
582 compiledAction = compiler.CreateApplyTemplatesAction();
583 }
584 else if (Ref.Equal(localName, input.Atoms.Attribute))
585 {
586 compiledAction = compiler.CreateAttributeAction();
587 }
588 else if (Ref.Equal(localName, input.Atoms.CallTemplate))
589 {
590 compiledAction = compiler.CreateCallTemplateAction();
591 }
592 else if (Ref.Equal(localName, input.Atoms.Choose))
593 {
594 compiledAction = compiler.CreateChooseAction();
595 }
596 else if (Ref.Equal(localName, input.Atoms.Comment))
597 {
598 compiledAction = compiler.CreateCommentAction();
599 }
600 else if (Ref.Equal(localName, input.Atoms.Copy))
601 {
602 compiledAction = compiler.CreateCopyAction();
603 }
604 else if (Ref.Equal(localName, input.Atoms.CopyOf))
605 {
606 compiledAction = compiler.CreateCopyOfAction();
607 }
608 else if (Ref.Equal(localName, input.Atoms.Element))
609 {
610 compiledAction = compiler.CreateElementAction();
611 }
612 else
613 {
614 if (Ref.Equal(localName, input.Atoms.Fallback))
615 {
616 return;
617 }
618 if (Ref.Equal(localName, input.Atoms.ForEach))
619 {
620 compiledAction = compiler.CreateForEachAction();
621 }
622 else if (Ref.Equal(localName, input.Atoms.If))
623 {
624 compiledAction = compiler.CreateIfAction(IfAction.ConditionType.ConditionIf);
625 }
626 else if (Ref.Equal(localName, input.Atoms.Message))
627 {
628 compiledAction = compiler.CreateMessageAction();
629 }
630 else if (Ref.Equal(localName, input.Atoms.Number))
631 {
632 compiledAction = compiler.CreateNumberAction();
633 }
634 else if (Ref.Equal(localName, input.Atoms.ProcessingInstruction))
635 {
636 compiledAction = compiler.CreateProcessingInstructionAction();
637 }
638 else if (Ref.Equal(localName, input.Atoms.Text))
639 {
640 compiledAction = compiler.CreateTextAction();
641 }
642 else if (Ref.Equal(localName, input.Atoms.ValueOf))
643 {
644 compiledAction = compiler.CreateValueOfAction();
645 }
646 else if (Ref.Equal(localName, input.Atoms.Variable))
647 {
648 compiledAction = compiler.CreateVariableAction(VariableType.LocalVariable);
649 }
650 else
651 {
652 if (!compiler.ForwardCompatibility)
653 {
654 throw compiler.UnexpectedKeyword();
655 }
656 compiledAction = compiler.CreateNewInstructionAction();
657 }
658 }
660 }
661
663 {
665 switch (input.NodeType)
666 {
667 case XPathNodeType.Element:
668 AddEvent(compiler.CreateBeginEvent());
670 if (compiler.Recurse())
671 {
673 compiler.ToParent();
674 }
675 AddEvent(new EndEvent(XPathNodeType.Element));
676 break;
677 case XPathNodeType.Text:
678 case XPathNodeType.SignificantWhitespace:
679 AddEvent(compiler.CreateTextEvent());
680 break;
681 case XPathNodeType.Attribute:
682 case XPathNodeType.Namespace:
683 case XPathNodeType.Whitespace:
684 case XPathNodeType.ProcessingInstruction:
685 case XPathNodeType.Comment:
686 break;
687 }
688 }
689
691 {
693 if (input.Navigator.MoveToAttribute("use-attribute-sets", input.Atoms.UriXsl))
694 {
695 AddAction(compiler.CreateUseAttributeSetsAction());
696 input.Navigator.MoveToParent();
697 }
698 compiler.InsertExcludedNamespace();
699 if (input.MoveToFirstNamespace())
700 {
701 do
702 {
703 string value = input.Value;
704 if (!(value == "http://www.w3.org/1999/XSL/Transform") && !compiler.IsExcludedNamespace(value) && !compiler.IsExtensionNamespace(value) && !compiler.IsNamespaceAlias(value))
705 {
707 }
708 }
709 while (input.MoveToNextNamespace());
710 input.ToParent();
711 }
712 if (!input.MoveToFirstAttribute())
713 {
714 return;
715 }
716 do
717 {
718 if (!Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl))
719 {
720 AddEvent(compiler.CreateBeginEvent());
721 AddEvents(compiler.CompileAvt(input.Value));
722 AddEvent(new EndEvent(XPathNodeType.Attribute));
723 }
724 }
725 while (input.MoveToNextAttribute());
726 input.ToParent();
727 }
728
730 {
731 compiler.RootAction.Output.Compile(compiler);
732 }
733
734 internal void AddAction(Action action)
735 {
736 if (containedActions == null)
737 {
739 }
741 lastCopyCodeAction = null;
742 }
743
744 [MemberNotNull("lastCopyCodeAction")]
745 private void EnsureCopyCodeAction()
746 {
747 if (lastCopyCodeAction == null)
748 {
752 }
753 }
754
760
766
768 {
771 string text = null;
772 if (input.MoveToFirstAttribute())
773 {
774 do
775 {
776 if (input.LocalName == input.Atoms.Language)
777 {
778 string value = input.Value;
779 if (string.Equals(value, "jscript", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "javascript", StringComparison.OrdinalIgnoreCase))
780 {
781 lang = ScriptingLanguage.JScript;
782 continue;
783 }
784 if (string.Equals(value, "c#", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "csharp", StringComparison.OrdinalIgnoreCase))
785 {
786 lang = ScriptingLanguage.CSharp;
787 continue;
788 }
789 if (!string.Equals(value, "vb", StringComparison.OrdinalIgnoreCase) && !string.Equals(value, "visualbasic", StringComparison.OrdinalIgnoreCase))
790 {
792 }
793 lang = ScriptingLanguage.VisualBasic;
794 }
795 else if (input.LocalName == input.Atoms.ImplementsPrefix)
796 {
797 if (!PrefixQName.ValidatePrefix(input.Value))
798 {
800 }
801 text = compiler.ResolveXmlNamespace(input.Value);
802 }
803 }
804 while (input.MoveToNextAttribute());
805 input.ToParent();
806 }
807 if (text == null)
808 {
809 throw XsltException.Create(System.SR.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
810 }
811 if (!input.Recurse() || input.NodeType != XPathNodeType.Text)
812 {
814 }
815 compiler.AddScript(input.Value, lang, text, input.BaseURI, input.LineNumber);
816 input.ToParent();
817 }
818
819 internal override void Execute(Processor processor, ActionFrame frame)
820 {
821 switch (frame.State)
822 {
823 case 0:
824 if (containedActions != null && containedActions.Count > 0)
825 {
826 processor.PushActionFrame(frame);
827 frame.State = 1;
828 }
829 else
830 {
831 frame.Finished();
832 }
833 break;
834 case 1:
835 frame.Finished();
836 break;
837 }
838 }
839
841 {
843 {
845 }
846 return null;
847 }
848
850 {
851 if (containedActions == null)
852 {
853 return;
854 }
856 {
858 {
859 throw XsltException.Create(System.SR.Xslt_DuplicateWithParam, name.ToString());
860 }
861 }
862 }
863
865 {
866 if (containedActions != null)
867 {
868 for (int i = 0; i < containedActions.Count; i++)
869 {
870 ((Action)containedActions[i]).ReplaceNamespaceAlias(compiler);
871 }
872 }
873 }
874}
virtual int Add(object? value)
static string Xslt_MissingAttribute
Definition SR.cs:1882
static string Xslt_InvalidContents
Definition SR.cs:2076
static string Xslt_ScriptEmpty
Definition SR.cs:2118
static string Xslt_WrongStylesheetElement
Definition SR.cs:1866
static string Xslt_NotFirstImport
Definition SR.cs:2072
static string Xslt_InvalidAttrValue
Definition SR.cs:1884
static string Xslt_NullNsAtTopLevel
Definition SR.cs:1874
static string Xslt_CircularInclude
Definition SR.cs:1890
static string Xslt_ScriptInvalidLanguage
Definition SR.cs:1930
static string Xslt_InvalidAttribute
Definition SR.cs:1880
static string Xslt_WdXslNamespace
Definition SR.cs:1868
static string Xslt_DuplicateWithParam
Definition SR.cs:1956
Definition SR.cs:7
override string ToString()
Definition Uri.cs:1119
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static double ToXPathDouble(object o)
static string[] SplitString(string value)
static XsltException Create(string res, params string[] args)
void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName)
void CompileStylesheetAttributes(Compiler compiler)
Stylesheet CompileImport(Compiler compiler, Uri uri, int id)
void CompileInstruction(Compiler compiler)
void CompileLiteralAttributesAndNamespaces(Compiler compiler)
void CompileSingleTemplate(Compiler compiler)
void CompileDocument(Compiler compiler, bool inInclude)
void CheckDuplicateParams(XmlQualifiedName name)
bool CheckAttribute(bool valid, Compiler compiler)
void CompileOnceTemplate(Compiler compiler)
void AddEvents(ArrayList copyEvents)
override void Execute(Processor processor, ActionFrame frame)
void CompileDecimalFormat(Compiler compiler)
override void ReplaceNamespaceAlias(Compiler compiler)
override void Compile(Compiler compiler)
void CompileNamespaceAlias(Compiler compiler)
void CompileSpace(Compiler compiler, bool preserve)
void CompileTopLevelElements(Compiler compiler)
void AddEvents(ArrayList copyEvents)
static void ParseQualifiedName(string qname, out string prefix, out string local)
static bool ValidatePrefix(string prefix)
delegate void Action()