Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
VariableAction.cs
Go to the documentation of this file.
2
4
6{
7 public static object BeingComputedMark = new object();
8
10
11 protected string nameStr;
12
13 protected string baseUri;
14
15 protected int selectKey = -1;
16
17 protected int stylesheetid;
18
20
21 private int _varKey;
22
23 internal int Stylesheetid => stylesheetid;
24
26
27 internal string NameStr => nameStr;
28
29 internal int VarKey => _varKey;
30
31 internal bool IsGlobal
32 {
33 get
34 {
35 if (varType != 0)
36 {
37 return varType == VariableType.GlobalParameter;
38 }
39 return true;
40 }
41 }
42
44
46 {
47 get
48 {
49 if (varType != VariableType.LocalVariable)
50 {
51 return varType == VariableType.LocalParameter;
52 }
53 return true;
54 }
55 }
56
58 {
59 get
60 {
61 if (varType != VariableType.LocalParameter)
62 {
63 return varType == VariableType.GlobalParameter;
64 }
65 return true;
66 }
67 }
68
70 {
71 varType = type;
72 }
73
74 internal override void Compile(Compiler compiler)
75 {
76 stylesheetid = compiler.Stylesheetid;
77 baseUri = compiler.Input.BaseURI;
80 if (compiler.Recurse())
81 {
83 compiler.ToParent();
84 if (selectKey != -1 && containedActions != null)
85 {
87 }
88 }
89 if (containedActions != null)
90 {
91 baseUri = baseUri + "#" + compiler.GetUnicRtfId();
92 }
93 else
94 {
95 baseUri = null;
96 }
97 _varKey = compiler.InsertVariable(this);
98 }
99
100 internal override bool CompileAttribute(Compiler compiler)
101 {
102 string localName = compiler.Input.LocalName;
103 string value = compiler.Input.Value;
104 if (Ref.Equal(localName, compiler.Atoms.Name))
105 {
106 nameStr = value;
107 name = compiler.CreateXPathQName(nameStr);
108 }
109 else
110 {
111 if (!Ref.Equal(localName, compiler.Atoms.Select))
112 {
113 return false;
114 }
115 selectKey = compiler.AddQuery(value);
116 }
117 return true;
118 }
119
120 internal override void Execute(Processor processor, ActionFrame frame)
121 {
122 object obj = null;
123 switch (frame.State)
124 {
125 default:
126 return;
127 case 0:
128 {
129 if (IsGlobal)
130 {
131 if (frame.GetVariable(_varKey) != null)
132 {
133 frame.Finished();
134 return;
135 }
137 }
138 if (varType == VariableType.GlobalParameter)
139 {
140 obj = processor.GetGlobalParameter(name);
141 }
142 else if (varType == VariableType.LocalParameter)
143 {
144 obj = processor.GetParameter(name);
145 }
146 if (obj != null)
147 {
148 break;
149 }
150 if (selectKey != -1)
151 {
152 obj = processor.RunQuery(frame, selectKey);
153 break;
154 }
155 if (containedActions == null)
156 {
157 obj = string.Empty;
158 break;
159 }
161 processor.PushOutput(output);
162 processor.PushActionFrame(frame);
163 frame.State = 1;
164 return;
165 }
166 case 1:
167 {
169 obj = ((NavigatorOutput)recordOutput).Navigator;
170 break;
171 }
172 case 2:
173 break;
174 }
175 frame.SetVariable(_varKey, obj);
176 frame.Finished();
177 }
178
180 {
181 return ((XsltCompileContext)xsltContext).EvaluateVariable(this);
182 }
183}
static string Xslt_VariableCntSel2
Definition SR.cs:1894
Definition SR.cs:7
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static XsltException Create(string res, params string[] args)
void SetVariable(int index, object value)
void CompileAttributes(Compiler compiler)
void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName)
override void Compile(Compiler compiler)
override void Execute(Processor processor, ActionFrame frame)
override bool CompileAttribute(Compiler compiler)
object Evaluate(XsltContext xsltContext)