Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlILStateAnalyzer.cs
Go to the documentation of this file.
2
4
5internal class XmlILStateAnalyzer
6{
8
9 protected QilFactory fac;
10
12
13 protected bool withinElem;
14
16 {
17 this.fac = fac;
18 }
19
21 {
22 if (ndConstr == null)
23 {
24 parentInfo = null;
25 xstates = PossibleXmlStates.WithinSequence;
26 withinElem = false;
28 }
29 else
30 {
32 if (ndConstr.NodeType == QilNodeType.Function)
33 {
37 {
39 {
40 possibleXmlStates = item.InitialStates;
41 }
42 else if (possibleXmlStates != item.InitialStates)
43 {
45 }
47 }
49 }
50 else
51 {
52 if (ndConstr.NodeType != QilNodeType.Choice)
53 {
57 }
58 if (ndConstr.NodeType != QilNodeType.RtfCtor)
59 {
61 }
62 }
64 switch (ndConstr.NodeType)
65 {
66 case QilNodeType.DocumentCtor:
67 xstates = PossibleXmlStates.WithinContent;
68 break;
69 case QilNodeType.ElementCtor:
70 xstates = PossibleXmlStates.EnumAttrs;
71 break;
72 case QilNodeType.AttributeCtor:
73 xstates = PossibleXmlStates.WithinAttr;
74 break;
75 case QilNodeType.CommentCtor:
76 xstates = PossibleXmlStates.WithinComment;
77 break;
78 case QilNodeType.PICtor:
79 xstates = PossibleXmlStates.WithinPI;
80 break;
81 case QilNodeType.XsltCopy:
83 break;
84 case QilNodeType.Function:
86 break;
87 case QilNodeType.RtfCtor:
88 xstates = PossibleXmlStates.WithinContent;
89 break;
90 case QilNodeType.Choice:
92 break;
93 }
94 if (ndContent != null)
95 {
97 }
98 if (ndConstr.NodeType == QilNodeType.Choice)
99 {
101 }
102 if (ndConstr.NodeType == QilNodeType.Function)
103 {
105 }
106 }
107 return ndContent;
108 }
109
110 protected virtual QilNode AnalyzeContent(QilNode nd)
111 {
112 QilNodeType nodeType = nd.NodeType;
113 if ((uint)(nodeType - 14) <= 2u)
114 {
115 nd = fac.Nop(nd);
116 }
121 switch (nd.NodeType)
122 {
123 case QilNodeType.Loop:
125 break;
126 case QilNodeType.Sequence:
128 break;
129 case QilNodeType.Conditional:
131 break;
132 case QilNodeType.Choice:
134 break;
135 case QilNodeType.Error:
136 case QilNodeType.Warning:
138 break;
139 case QilNodeType.Nop:
140 {
141 QilNode child = (nd as QilUnary).Child;
143 if ((uint)(nodeType2 - 14) <= 2u)
144 {
146 break;
147 }
149 AnalyzeContent(child);
150 break;
151 }
152 default:
154 break;
155 }
157 return nd;
158 }
159
161 {
162 XmlQueryType xmlType = ndLoop.XmlType;
164 if (!xmlType.IsSingleton)
165 {
166 StartLoop(xmlType, info);
167 }
169 if (!xmlType.IsSingleton)
170 {
171 EndLoop(xmlType, info);
172 }
173 }
174
176 {
178 for (int i = 0; i < ndSeq.Count; i++)
179 {
180 ndSeq[i] = AnalyzeContent(ndSeq[i]);
181 }
182 }
183
196
198 {
199 int num = ndChoice.Branches.Count - 1;
200 ndChoice.Branches[num] = AnalyzeContent(ndChoice.Branches[num]);
202 while (--num >= 0)
203 {
204 xstates = info.InitialStates;
205 ndChoice.Branches[num] = AnalyzeContent(ndChoice.Branches[num]);
207 {
209 }
210 }
212 }
213
215 {
216 XmlQueryType xmlType = ndCopy.XmlType;
217 if (!xmlType.IsSingleton)
218 {
219 StartLoop(xmlType, info);
220 }
221 if (MaybeContent(xmlType))
222 {
223 if (MaybeAttrNmsp(xmlType))
224 {
225 if (xstates == PossibleXmlStates.EnumAttrs)
226 {
228 }
229 }
230 else if (xstates == PossibleXmlStates.EnumAttrs || withinElem)
231 {
232 xstates = PossibleXmlStates.WithinContent;
233 }
234 }
235 if (!xmlType.IsSingleton)
236 {
237 EndLoop(xmlType, info);
238 }
239 }
240
242 {
244 if (typ.MaybeMany && xstates == PossibleXmlStates.EnumAttrs && MaybeContent(typ))
245 {
247 }
248 }
249
251 {
253 if (typ.MaybeEmpty && info.InitialStates != xstates)
254 {
256 }
257 }
258
260 {
261 return (typ.NodeKinds & (XmlNodeKindFlags.Attribute | XmlNodeKindFlags.Namespace)) != 0;
262 }
263
265 {
266 if (typ.IsNode)
267 {
268 return (typ.NodeKinds & ~(XmlNodeKindFlags.Attribute | XmlNodeKindFlags.Namespace)) != 0;
269 }
270 return true;
271 }
272}
static XmlILConstructInfo Write(QilNode nd)
virtual QilNode AnalyzeContent(QilNode nd)
void EndLoop(XmlQueryType typ, XmlILConstructInfo info)
virtual QilNode Analyze(QilNode ndConstr, QilNode ndContent)
virtual void AnalyzeChoice(QilChoice ndChoice, XmlILConstructInfo info)
virtual void AnalyzeSequence(QilList ndSeq, XmlILConstructInfo info)
void StartLoop(XmlQueryType typ, XmlILConstructInfo info)
virtual void AnalyzeCopy(QilNode ndCopy, XmlILConstructInfo info)
virtual void AnalyzeConditional(QilTernary ndCond, XmlILConstructInfo info)
virtual void AnalyzeLoop(QilLoop ndLoop, XmlILConstructInfo info)
QilUnary Nop(QilNode child)