Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TemplateAction.cs
Go to the documentation of this file.
3
5
7{
8 private int _matchKey = -1;
9
11
12 private double _priority = double.NaN;
13
15
16 private int _templateId;
17
19
20 internal int MatchKey => _matchKey;
21
23
24 internal double Priority => _priority;
25
26 internal XmlQualifiedName Mode => _mode;
27
28 internal int TemplateId
29 {
30 get
31 {
32 return _templateId;
33 }
34 set
35 {
37 }
38 }
39
40 internal override void Compile(Compiler compiler)
41 {
43 if (_matchKey == -1)
44 {
45 if (_name == null)
46 {
48 }
49 if (_mode != null)
50 {
52 }
53 }
54 compiler.BeginTemplate(this);
55 if (compiler.Recurse())
56 {
59 compiler.ToParent();
60 }
61 compiler.EndTemplate();
63 }
64
65 internal virtual void CompileSingle(Compiler compiler)
66 {
67 _matchKey = compiler.AddQuery("/", allowVar: false, allowKey: true, isPattern: true);
68 _priority = 0.5;
70 }
71
72 internal override bool CompileAttribute(Compiler compiler)
73 {
74 string localName = compiler.Input.LocalName;
75 string value = compiler.Input.Value;
76 if (Ref.Equal(localName, compiler.Atoms.Match))
77 {
78 _matchKey = compiler.AddQuery(value, allowVar: false, allowKey: true, isPattern: true);
79 }
80 else if (Ref.Equal(localName, compiler.Atoms.Name))
81 {
82 _name = compiler.CreateXPathQName(value);
83 }
84 else if (Ref.Equal(localName, compiler.Atoms.Priority))
85 {
87 if (double.IsNaN(_priority) && !compiler.ForwardCompatibility)
88 {
90 }
91 }
92 else
93 {
94 if (!Ref.Equal(localName, compiler.Atoms.Mode))
95 {
96 return false;
97 }
98 if (compiler.AllowBuiltInMode && value == "*")
99 {
101 }
102 else
103 {
104 _mode = compiler.CreateXPathQName(value);
105 }
106 }
107 return true;
108 }
109
111 {
112 if (double.IsNaN(_priority) && _matchKey != -1)
113 {
114 TheQuery theQuery = compiler.QueryStore[MatchKey];
116 Query query;
118 {
120 compiler.QueryStore.Add(new TheQuery(new CompiledXpathExpr(unionExpr.qy2, compiledQuery.Expression, needContext: false), theQuery._ScopeManager));
122 templateAction._priority = unionExpr.qy2.XsltDefaultPriority;
123 compiler.AddTemplate(templateAction);
124 }
125 if (compiledQuery.QueryTree != query)
126 {
127 compiler.QueryStore[MatchKey] = new TheQuery(new CompiledXpathExpr(query, compiledQuery.Expression, needContext: false), theQuery._ScopeManager);
128 }
129 _priority = query.XsltDefaultPriority;
130 }
131 }
132
134 {
136 do
137 {
138 switch (input.NodeType)
139 {
140 case XPathNodeType.Element:
141 if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl) && Ref.Equal(input.LocalName, input.Atoms.Param))
142 {
143 compiler.PushNamespaceScope();
144 AddAction(compiler.CreateVariableAction(VariableType.LocalParameter));
145 compiler.PopScope();
146 break;
147 }
148 return;
149 case XPathNodeType.Text:
150 return;
151 case XPathNodeType.SignificantWhitespace:
152 AddEvent(compiler.CreateTextEvent());
153 break;
154 }
155 }
156 while (input.Advance());
157 }
158
168
170 {
172 {
173 base.ReplaceNamespaceAlias(compiler);
175 }
176 }
177
178 internal override void Execute(Processor processor, ActionFrame frame)
179 {
180 switch (frame.State)
181 {
182 case 0:
183 if (variableCount > 0)
184 {
186 }
187 if (containedActions != null && containedActions.Count > 0)
188 {
189 processor.PushActionFrame(frame);
190 frame.State = 1;
191 }
192 else
193 {
194 frame.Finished();
195 }
196 break;
197 case 1:
198 frame.Finished();
199 break;
200 }
201 }
202}
static string Xslt_TemplateNoAttrib
Definition SR.cs:2094
static string Xslt_InvalidAttrValue
Definition SR.cs:1884
static string Xslt_InvalidModeAttribute
Definition SR.cs:2126
Definition SR.cs:7
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static double ToXPathDouble(object o)
static XsltException Create(string res, params string[] args)
void CompileAttributes(Compiler compiler)
static XmlQualifiedName BuiltInMode
Definition Compiler.cs:81
void CompileOnceTemplate(Compiler compiler)
virtual void CompileSingle(Compiler compiler)
override void Execute(Processor processor, ActionFrame frame)
override void ReplaceNamespaceAlias(Compiler compiler)
void CompileParameters(Compiler compiler)
override void Compile(Compiler compiler)
void AnalyzePriority(Compiler compiler)
override bool CompileAttribute(Compiler compiler)