internal object GetVariableValue(VariableAction variable) {
int variablekey = variable.VarKey;
if (variable.IsGlobal) {
ActionFrame rootFrame = (ActionFrame) this.actionStack[0];
object result = rootFrame.GetVariable(variablekey);
if (result != null) {
return result;
}
// Variable wasn't evaluated yet
if (variable.Stylesheetid == -1) {
throw XsltException.Create(Res.Xslt_CircularReference, variable.NameStr);
}
int saveStackSize = this.actionStack.Length;
ActionFrame varFrame = PushNewFrame();
varFrame.Inherit(rootFrame);
varFrame.Init(variable, rootFrame.NodeSet);
do {
bool endOfFrame = ((ActionFrame) this.actionStack.Peek()).Execute(this);
if (endOfFrame) {
this.actionStack.Pop();
}
} while (saveStackSize < this.actionStack.Length);
Debug.Assert(saveStackSize == this.actionStack.Length);
result = rootFrame.GetVariable(variablekey);
Debug.Assert(result != null, "Variable was just calculated and result can't be null");
return result;
} else {
return ((ActionFrame) this.actionStack.Peek()).GetVariable(variablekey);
}
}