dbertoni 2003/08/01 18:07:49
Modified: c/src/xalanc/XSLT ElemApplyTemplates.cpp
ElemCallTemplate.cpp ElemForEach.cpp
ElemTemplate.cpp ElemTemplateElement.cpp
ElemVariable.cpp StylesheetExecutionContext.cpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
StylesheetRoot.cpp VariablesStack.cpp
VariablesStack.hpp
Log:
Cleaned up a bunch of stuff with setup and tear-down of params.
Revision Changes Path
1.2 +5 -6 xml-xalan/c/src/xalanc/XSLT/ElemApplyTemplates.cpp
Index: ElemApplyTemplates.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemApplyTemplates.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElemApplyTemplates.cpp 29 Jun 2003 03:58:07 -0000 1.1
+++ ElemApplyTemplates.cpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -214,8 +214,7 @@
NodeSorter*
sorter,
int
/* selectStackFrameIndex */) const
{
- XalanNode* const sourceNode = executionContext.getCurrentNode();
- assert(sourceNode != 0);
+ int savedStackFrameIndex;
// Push the params & stack frame, but then execute the select
// expression inside transformSelectedChildren, which must be
@@ -223,8 +222,8 @@
StylesheetExecutionContext::ParamsPushPop thePushPop(
executionContext,
*this,
- sourceNode,
- this);
+ this,
+ savedStackFrameIndex);
const XalanQName* const currentMode =
executionContext.getCurrentMode();
assert(currentMode != 0);
@@ -238,7 +237,7 @@
executionContext,
theTemplate,
sorter,
- thePushPop.getStackFrameIndex());
+ savedStackFrameIndex);
executionContext.setCurrentMode(currentMode);
}
@@ -248,7 +247,7 @@
executionContext,
theTemplate,
sorter,
- thePushPop.getStackFrameIndex());
+ savedStackFrameIndex);
}
}
1.2 +0 -4 xml-xalan/c/src/xalanc/XSLT/ElemCallTemplate.cpp
Index: ElemCallTemplate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemCallTemplate.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElemCallTemplate.cpp 29 Jun 2003 03:58:07 -0000 1.1
+++ ElemCallTemplate.cpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -153,15 +153,11 @@
{
ElemTemplateElement::execute(executionContext);
- XalanNode* const sourceNode = executionContext.getCurrentNode();
- assert(sourceNode != 0);
-
assert(m_template != 0);
StylesheetExecutionContext::ParamsPushPop thePushPop(
executionContext,
*this,
- sourceNode,
m_template);
m_template->execute(executionContext);
1.3 +1 -1 xml-xalan/c/src/xalanc/XSLT/ElemForEach.cpp
Index: ElemForEach.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemForEach.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElemForEach.cpp 9 Jul 2003 23:44:12 -0000 1.2
+++ ElemForEach.cpp 2 Aug 2003 01:07:48 -0000 1.3
@@ -217,7 +217,7 @@
assert(m_selectPattern != 0);
assert(executionContext.getCurrentNode() != 0);
- StylesheetExecutionContext::SetAndRestoreCurrentTemplate
theSetAndRestore(executionContext, 0);
+ StylesheetExecutionContext::PushAndPopCurrentTemplate
thePushAndPop(executionContext, 0);
if (hasChildren() == true)
{
1.2 +1 -1 xml-xalan/c/src/xalanc/XSLT/ElemTemplate.cpp
Index: ElemTemplate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemTemplate.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElemTemplate.cpp 29 Jun 2003 03:58:07 -0000 1.1
+++ ElemTemplate.cpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -217,7 +217,7 @@
void
ElemTemplate::executeChildren(StylesheetExecutionContext&
executionContext) const
{
- StylesheetExecutionContext::SetAndRestoreCurrentTemplate
theSetAndRestore(executionContext, this);
+ StylesheetExecutionContext::PushAndPopCurrentTemplate
thePushAndPop(executionContext, this);
ElemTemplateElement::executeChildren(executionContext);
}
1.4 +1 -1 xml-xalan/c/src/xalanc/XSLT/ElemTemplateElement.cpp
Index: ElemTemplateElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemTemplateElement.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemTemplateElement.cpp 15 Jul 2003 01:04:54 -0000 1.3
+++ ElemTemplateElement.cpp 2 Aug 2003 01:07:48 -0000 1.4
@@ -310,7 +310,7 @@
}
else
{
- const XPathExecutionContext::CurrentNodeSetAndRestore
theCurrentNodeSetAndRestore(executionContext, theCurrentNode, sourceNode);
+ const XPathExecutionContext::CurrentNodePushAndPop
theCurrentNodePushAndPop(executionContext, sourceNode);
executeChildren(executionContext);
}
1.3 +1 -1 xml-xalan/c/src/xalanc/XSLT/ElemVariable.cpp
Index: ElemVariable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemVariable.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElemVariable.cpp 12 Jul 2003 00:38:31 -0000 1.2
+++ ElemVariable.cpp 2 Aug 2003 01:07:48 -0000 1.3
@@ -304,7 +304,7 @@
}
else
{
- const XPathExecutionContext::CurrentNodeSetAndRestore
theCurrentNodeSetAndRestore(executionContext, theCurrentNode, sourceNode);
+ const XPathExecutionContext::CurrentNodePushAndPop
theCurrentNodePushAndPop(executionContext, sourceNode);
theValue = m_selectPattern->execute(*this,
executionContext);
}
1.2 +17 -36
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.cpp
Index: StylesheetExecutionContext.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StylesheetExecutionContext.cpp 29 Jun 2003 03:58:08 -0000 1.1
+++ StylesheetExecutionContext.cpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -84,52 +84,33 @@
-StylesheetExecutionContext::ParamsPushPop::ParamsPushPop(
- StylesheetExecutionContext&
executionContext,
+StylesheetExecutionContext::ParamsPushPop::doPush(
const ElemTemplateElement&
xslCallTemplateElement,
- XalanNode*
sourceNode,
- const ElemTemplateElement* targetTemplate)
:
- m_executionContext(executionContext),
- m_savedStackFrameIndex(executionContext.getCurrentStackFrameIndex())
+ const ElemTemplateElement* targetTemplate,
+ int
savedStackFrameIndex)
{
- // It would be cleaner to replace these two lines with separate
- // subobjects, but that would means saving two more copies of
- // the execution context on the stack. Instead, we're just using
- // a catch block to make sure that the code in the destructor runs
- // if there's a problem pushing the params.
- executionContext.pushContextMarker();
-
- executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
-
- try
- {
- if (xslCallTemplateElement.hasParams() == true)
- {
- executionContext.pushParams(
- xslCallTemplateElement,
- sourceNode,
- targetTemplate);
- }
-
- executionContext.setCurrentStackFrameIndex();
- }
- catch(...)
+ if (xslCallTemplateElement.hasParams() == true)
{
-
m_executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
+
getExecutionContext().setCurrentStackFrameIndex(savedStackFrameIndex);
- m_executionContext.popContextMarker();
-
- throw;
+ getExecutionContext().pushParams(
+ xslCallTemplateElement,
+ targetTemplate);
}
}
-StylesheetExecutionContext::ParamsPushPop::~ParamsPushPop()
+StylesheetExecutionContext::ParamsPushPop::doPush(
+ const ElemTemplateElement&
xslCallTemplateElement,
+ const ElemTemplateElement* targetTemplate)
{
- m_executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
-
- m_executionContext.popContextMarker();
+ if (xslCallTemplateElement.hasParams() == true)
+ {
+ getExecutionContext().pushParams(
+ xslCallTemplateElement,
+ targetTemplate);
+ }
}
1.5 +65 -44
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.hpp
Index: StylesheetExecutionContext.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StylesheetExecutionContext.hpp 15 Jul 2003 07:04:27 -0000 1.4
+++ StylesheetExecutionContext.hpp 2 Aug 2003 01:07:48 -0000 1.5
@@ -370,42 +370,36 @@
* @param theTemplate The current template instance
*/
virtual void
- setCurrentTemplate(const ElemTemplate* theTemplate) = 0;
+ pushCurrentTemplate(const ElemTemplate* theTemplate) = 0;
+
+ virtual void
+ popCurrentTemplate() = 0;
/*
- * A class to manage setting and restoring the current
+ * A class to manage pushing and popping the current
* template instance.
*/
- class SetAndRestoreCurrentTemplate
+ class PushAndPopCurrentTemplate
{
public:
- SetAndRestoreCurrentTemplate(
+ PushAndPopCurrentTemplate(
StylesheetExecutionContext&
executionContext,
const ElemTemplate*
theTemplate) :
- m_executionContext(executionContext),
- m_template(executionContext.getCurrentTemplate())
+ m_executionContext(executionContext)
{
- executionContext.setCurrentTemplate(theTemplate);
+ executionContext.pushCurrentTemplate(theTemplate);
}
- ~SetAndRestoreCurrentTemplate()
+ ~PushAndPopCurrentTemplate()
{
- m_executionContext.setCurrentTemplate(m_template);
+ m_executionContext.popCurrentTemplate();
}
private:
- // Not implemented...
- SetAndRestoreCurrentTemplate(const
SetAndRestoreCurrentTemplate&);
-
- SetAndRestoreCurrentTemplate&
- operator=(const SetAndRestoreCurrentTemplate&);
-
// Data members...
StylesheetExecutionContext& m_executionContext;
-
- const ElemTemplate* const m_template;
};
/**
@@ -835,11 +829,27 @@
executionContext.pushContextMarker();
}
+ PushAndPopContextMarker(
+ StylesheetExecutionContext&
executionContext,
+ int&
currentStackFrameIndex) :
+ m_executionContext(executionContext)
+ {
+ currentStackFrameIndex =
executionContext.getCurrentStackFrameIndex();
+
+ executionContext.pushContextMarker();
+ }
+
~PushAndPopContextMarker()
{
m_executionContext.popContextMarker();
}
+ StylesheetExecutionContext&
+ getExecutionContext() const
+ {
+ return m_executionContext;
+ }
+
private:
StylesheetExecutionContext& m_executionContext;
@@ -882,13 +892,11 @@
* Also, push default arguments on the stack.
*
* @param xslCallTemplateElement "call-template" element
- * @param sourceNode source node
* @param targetTemplate target template
*/
virtual void
pushParams(
const ElemTemplateElement& xslCallTemplateElement,
- XalanNode*
sourceNode,
const ElemTemplateElement* targetTemplate) = 0;
/**
@@ -915,7 +923,7 @@
* @param elem the element
*/
virtual void
- popElementFrame(const ElemTemplateElement* elem) = 0;
+ popElementFrame() = 0;
/*
* A class to manage pushing and popping an element's stack
@@ -928,22 +936,19 @@
PushAndPopElementFrame(
StylesheetExecutionContext&
executionContext,
const ElemTemplateElement* element) :
- m_executionContext(executionContext),
- m_element(element)
+ m_executionContext(executionContext)
{
executionContext.pushElementFrame(element);
}
~PushAndPopElementFrame()
{
- m_executionContext.popElementFrame(m_element);
+ m_executionContext.popElementFrame();
}
private:
StylesheetExecutionContext& m_executionContext;
-
- const ElemTemplateElement* m_element;
};
/**
@@ -993,12 +998,6 @@
m_executionContext.setCurrentStackFrameIndex(m_savedIndex);
}
- int
- getStackFrameIndex() const
- {
- return m_savedIndex;
- }
-
private:
StylesheetExecutionContext& m_executionContext;
@@ -1009,29 +1008,48 @@
/*
* A class to manage stack state during execution.
*/
- class ParamsPushPop
+ class ParamsPushPop : public PushAndPopContextMarker
{
public:
ParamsPushPop(
- StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement&
xslCallTemplateElement,
- XalanNode*
sourceNode,
- const ElemTemplateElement* targetTemplate);
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement&
xslCallTemplateElement,
+ const ElemTemplateElement*
targetTemplate) :
+ PushAndPopContextMarker(executionContext)
+ {
+ doPush(
+ xslCallTemplateElement,
+ targetTemplate);
+ }
- ~ParamsPushPop();
+ ParamsPushPop(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement&
xslCallTemplateElement,
+ const ElemTemplateElement*
targetTemplate,
+ int&
savedStackFrameIndex) :
+ PushAndPopContextMarker(executionContext,
savedStackFrameIndex)
+ {
+ doPush(
+ xslCallTemplateElement,
+ targetTemplate,
+ savedStackFrameIndex);
+ }
- int
- getStackFrameIndex() const
+ ~ParamsPushPop()
{
- return m_savedStackFrameIndex;
}
private:
- StylesheetExecutionContext& m_executionContext;
-
- const int
m_savedStackFrameIndex;
+ doPush(
+ const ElemTemplateElement&
xslCallTemplateElement,
+ const ElemTemplateElement* targetTemplate,
+ int
stackFrameIndex);
+
+ doPush(
+ const ElemTemplateElement&
xslCallTemplateElement,
+ const ElemTemplateElement* targetTemplate);
};
/**
@@ -1784,7 +1802,10 @@
getCurrentNode() const = 0;
virtual void
- setCurrentNode(XalanNode* theCurrentNode) = 0;
+ pushCurrentNode(XalanNode* theCurrentNode) = 0;
+
+ virtual void
+ popCurrentNode() = 0;
virtual bool
isNodeAfter(
1.6 +33 -17
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp
Index: StylesheetExecutionContextDefault.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StylesheetExecutionContextDefault.cpp 15 Jul 2003 07:04:27 -0000
1.5
+++ StylesheetExecutionContextDefault.cpp 2 Aug 2003 01:07:48 -0000
1.6
@@ -168,7 +168,7 @@
m_ignoreHTMLElementNamespaces(false),
m_sourceTreeResultTreeFactory(),
m_mode(0),
- m_currentTemplate(0),
+ m_currentTemplateStack(),
m_formatterToTextCache(),
m_formatterToSourceTreeCache(),
m_nodeSorterCache(),
@@ -211,7 +211,7 @@
m_ignoreHTMLElementNamespaces(false),
m_sourceTreeResultTreeFactory(),
m_mode(0),
- m_currentTemplate(0),
+ m_currentTemplateStack(),
m_formatterToTextCache(),
m_formatterToSourceTreeCache(),
m_nodeSorterCache(),
@@ -329,15 +329,23 @@
const ElemTemplate*
StylesheetExecutionContextDefault::getCurrentTemplate() const
{
- return m_currentTemplate;
+ return m_currentTemplateStack.back();
}
void
-StylesheetExecutionContextDefault::setCurrentTemplate(const ElemTemplate*
theTemplate)
+StylesheetExecutionContextDefault::pushCurrentTemplate(const ElemTemplate*
theTemplate)
{
- m_currentTemplate = theTemplate;
+ m_currentTemplateStack.push_back(theTemplate);
+}
+
+
+
+void
+StylesheetExecutionContextDefault::popCurrentTemplate()
+{
+ m_currentTemplateStack.pop_back();
}
@@ -779,7 +787,6 @@
void
StylesheetExecutionContextDefault::pushParams(
const ElemTemplateElement& xslCallTemplateElement,
- XalanNode*
sourceNode,
const ElemTemplateElement* targetTemplate)
{
// We have a params vector that we reuse, but occasionally, a
@@ -798,7 +805,7 @@
m_paramsVector.reserve(eDefaultParamsVectorSize);
}
- getParams(xslCallTemplateElement, sourceNode, m_paramsVector);
+ getParams(xslCallTemplateElement, m_paramsVector);
m_variablesStack.pushParams(
m_paramsVector,
@@ -808,7 +815,7 @@
{
ParamsVectorType tempParams;
- getParams(xslCallTemplateElement, sourceNode, tempParams);
+ getParams(xslCallTemplateElement, tempParams);
m_variablesStack.pushParams(
tempParams,
@@ -837,9 +844,9 @@
void
-StylesheetExecutionContextDefault::popElementFrame(const
ElemTemplateElement* elem)
+StylesheetExecutionContextDefault::popElementFrame()
{
- m_variablesStack.popElementFrame(elem);
+ m_variablesStack.popElementFrame();
}
@@ -1134,7 +1141,7 @@
{
XALAN_USING_STD(find)
- const ElementRecursionStackType::const_iterator i =
+ const ElementTemplateElementStackType::const_iterator i =
find(m_elementRecursionStack.begin(),
m_elementRecursionStack.end(),
theElement);
@@ -1696,7 +1703,8 @@
}
m_mode = 0;
- m_currentTemplate = 0;
+
+ m_currentTemplateStack.clear();
m_formatterToTextCache.reset();
m_formatterToSourceTreeCache.reset();
@@ -1732,9 +1740,17 @@
void
-StylesheetExecutionContextDefault::setCurrentNode(XalanNode* theCurrentNode)
+StylesheetExecutionContextDefault::pushCurrentNode(XalanNode*
theCurrentNode)
+{
+ m_xpathExecutionContextDefault.pushCurrentNode(theCurrentNode);
+}
+
+
+
+void
+StylesheetExecutionContextDefault::popCurrentNode()
{
- m_xpathExecutionContextDefault.setCurrentNode(theCurrentNode);
+ m_xpathExecutionContextDefault.popCurrentNode();
}
@@ -2438,9 +2454,9 @@
void
StylesheetExecutionContextDefault::getParams(
const ElemTemplateElement& xslCallTemplateElement,
- XalanNode*
sourceNode,
ParamsVectorType& params)
{
+ assert(getCurrentNode() != 0);
assert(params.empty() == true);
const ElemTemplateElement* child =
@@ -2473,7 +2489,7 @@
theXObject =
createVariable(
*pxpath,
- sourceNode,
+ getCurrentNode(),
*xslParamElement);
}
else
@@ -2481,7 +2497,7 @@
theXObject =
createVariable(
*xslParamElement,
- sourceNode);
+ getCurrentNode());
}
params.push_back(ParamsVectorType::value_type(&xslParamElement->getQName(),
theXObject));
1.5 +15 -10
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StylesheetExecutionContextDefault.hpp 15 Jul 2003 07:04:27 -0000
1.4
+++ StylesheetExecutionContextDefault.hpp 2 Aug 2003 01:07:48 -0000
1.5
@@ -130,7 +130,7 @@
#endif
#if defined(XALAN_NO_STD_NAMESPACE)
- typedef deque<const ElemTemplateElement*>
ElementRecursionStackType;
+ typedef deque<const ElemTemplateElement*>
ElementTemplateElementStackType;
typedef vector<FormatterListener*>
FormatterListenerVectorType;
typedef vector<PrintWriter*>
PrintWriterVectorType;
typedef vector<XalanOutputStream*>
OutputStreamVectorType;
@@ -140,14 +140,16 @@
typedef map<XalanDOMString,
XPathCacheEntry,
less<XalanDOMString> >
XPathCacheMapType;
+ typedef deque<const ElemTemplate*>
CurrentTemplateStackType;
#else
- typedef std::deque<const ElemTemplateElement*>
ElementRecursionStackType;
+ typedef std::deque<const ElemTemplateElement*>
ElementTemplateElementStackType;
typedef std::vector<FormatterListener*>
FormatterListenerVectorType;
typedef std::vector<PrintWriter*>
PrintWriterVectorType;
typedef std::vector<XalanOutputStream*>
OutputStreamVectorType;
typedef std::set<const KeyDeclaration*>
KeyDeclarationSetType;
typedef std::pair<const XPath*, ClockType>
XPathCacheEntry;
typedef std::map<XalanDOMString, XPathCacheEntry>
XPathCacheMapType;
+ typedef std::deque<const ElemTemplate*>
CurrentTemplateStackType;
#endif
typedef Stylesheet::KeyTablesTableType
KeyTablesTableType;
@@ -351,7 +353,10 @@
getCurrentTemplate() const;
virtual void
- setCurrentTemplate(const ElemTemplate* theTemplate);
+ pushCurrentTemplate(const ElemTemplate* theTemplate);
+
+ virtual void
+ popCurrentTemplate();
virtual bool
doDiagnosticsOutput() const;
@@ -494,7 +499,6 @@
virtual void
pushParams(
const ElemTemplateElement& xslCallTemplateElement,
- XalanNode*
sourceNode,
const ElemTemplateElement* targetTemplate);
virtual const XObjectPtr
@@ -504,7 +508,7 @@
pushElementFrame(const ElemTemplateElement* elem);
virtual void
- popElementFrame(const ElemTemplateElement* elem);
+ popElementFrame();
virtual int
getGlobalStackFrameIndex() const;
@@ -845,7 +849,10 @@
getCurrentNode() const;
virtual void
- setCurrentNode(XalanNode* theCurrentNode);
+ pushCurrentNode(XalanNode* theCurrentNode);
+
+ virtual void
+ popCurrentNode();
virtual bool
isNodeAfter(
@@ -1041,13 +1048,11 @@
* call.
*
* @param xslCallTemplateElement "call-template" element
- * @param sourceNode source node
* @param params The params
*/
void
getParams(
const ElemTemplateElement& xslCallTemplateElement,
- XalanNode*
sourceNode,
ParamsVectorType& params);
/**
@@ -1105,7 +1110,7 @@
eDefaultTextAllocatorBlockSize = 20,
eDefaultTextIWSAllocatorBlockSize = 20 };
- ElementRecursionStackType m_elementRecursionStack;
+ ElementTemplateElementStackType m_elementRecursionStack;
const PrefixResolver* m_prefixResolver;
@@ -1148,7 +1153,7 @@
// Holds the current mode.
const XalanQName* m_mode;
- const ElemTemplate*
m_currentTemplate;
+ CurrentTemplateStackType m_currentTemplateStack;
typedef XalanObjectCacheDefault<FormatterToText>
FormatterToTextCacheType;
typedef XalanObjectCacheDefault<FormatterToSourceTree>
FormatterToSourceTreeCacheType;
1.6 +1 -1 xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp
Index: StylesheetRoot.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StylesheetRoot.cpp 15 Jul 2003 07:04:27 -0000 1.5
+++ StylesheetRoot.cpp 2 Aug 2003 01:07:48 -0000 1.6
@@ -252,7 +252,7 @@
executionContext.setCurrentMode(&s_emptyQName);
- XPathExecutionContext::CurrentNodeSetAndRestore
theCurrentNodeSetAndRestore(executionContext, sourceTree);
+ const XPathExecutionContext::CurrentNodePushAndPop
theCurrentNodePushAndPop(executionContext, sourceTree);
// Output the action of the found root rule. All processing
// occurs from here.
1.2 +64 -10 xml-xalan/c/src/xalanc/XSLT/VariablesStack.cpp
Index: VariablesStack.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/VariablesStack.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VariablesStack.cpp 29 Jun 2003 03:58:08 -0000 1.1
+++ VariablesStack.cpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,7 +80,8 @@
m_globalStackFrameIndex(-1),
m_globalStackFrameMarked(false),
m_currentStackFrameIndex(0),
- m_guardStack()
+ m_guardStack(),
+ m_elementFrameStack()
{
m_stack.reserve(eDefaultStackSize);
}
@@ -103,6 +104,7 @@
m_stack.clear();
m_guardStack.clear();
+ m_elementFrameStack.clear();
m_globalStackFrameMarked = false;
m_globalStackFrameIndex = -1;
@@ -150,21 +152,53 @@
{
const VariableStackStackType::size_type nElems = m_stack.size();
- for(VariableStackStackType::size_type i = nElems; i > 0 &&
m_stack.empty() == false; --i)
+ VariableStackStackType::size_type i = nElems;
+
+ for(; i > 0; --i)
{
+ assert(i >= m_stack.size());
+
const StackEntry& theEntry = m_stack[i -
1];
assert(theEntry == back());
const StackEntry::eType type = theEntry.getType();
assert(type < StackEntry::eNextValue && type >= 0);
+#if !defined(NDEBUG)
+ const ElemTemplateElement* const theElement =
+ theEntry.getElement();
+#endif
+
pop();
if (type == StackEntry::eContextMarker)
{
break;
}
+#if !defined(NDEBUG)
+ else if (type == StackEntry::eElementFrameMarker)
+ {
+ if (m_elementFrameStack.empty() == true)
+ {
+ throw InvalidStackContextException();
+ }
+
+ const ElemTemplateElement* const theStackBack =
+ m_elementFrameStack.back();
+
+ m_elementFrameStack.pop_back();
+
+ if (theElement != theStackBack)
+ {
+ throw InvalidStackContextException();
+ }
+ }
+#endif
}
+
+ assert(m_stack.size() == i - 1);
+
+ m_currentStackFrameIndex = i - 1;
}
@@ -176,8 +210,7 @@
CommitPushElementFrame(
VariablesStack&
theVariableStack,
const ElemTemplateElement*
targetTemplate) :
- m_variableStack(&theVariableStack),
- m_targetTemplate(targetTemplate)
+ m_variableStack(&theVariableStack)
{
theVariableStack.pushElementFrame(targetTemplate);
}
@@ -186,7 +219,7 @@
{
if (m_variableStack != 0)
{
- m_variableStack->popElementFrame(m_targetTemplate);
+ m_variableStack->popElementFrame();
}
}
@@ -199,8 +232,6 @@
private:
VariablesStack* m_variableStack;
-
- const ElemTemplateElement* const m_targetTemplate;
};
@@ -549,6 +580,10 @@
VariablesStack::pushElementFrame(const ElemTemplateElement* elem)
{
push(StackEntry(elem));
+
+#if !defined(NDEBUG)
+ m_elementFrameStack.push_back(elem);
+#endif
}
@@ -575,7 +610,7 @@
void
-VariablesStack::popElementFrame(const ElemTemplateElement* elem)
+VariablesStack::popElementFrame()
{
const VariableStackStackType::size_type nElems = m_stack.size();
assert(nElems > 0);
@@ -596,14 +631,26 @@
}
else if (theEntry.getType() == StackEntry::eElementFrameMarker)
{
+#if !defined(NDEBUG)
const ElemTemplateElement* const theElement =
theEntry.getElement();
- if (theElement != elem)
+ if (m_elementFrameStack.empty() == true)
{
throw InvalidStackContextException();
}
+ const ElemTemplateElement* const theStackBack =
+ m_elementFrameStack.back();
+
+ m_elementFrameStack.pop_back();
+
+ if (theElement != theStackBack)
+ {
+ throw InvalidStackContextException();
+ }
+#endif
+
break;
}
}
@@ -674,6 +721,13 @@
VariablesStack::StackEntry::~StackEntry()
{
+#if !defined(NDEBUG)
+ m_qname = (const XalanQName*) 0xDEADBEEF;
+
+ m_variable = (const ElemVariable*) 0xDEADBEEF;
+
+ m_element = (const ElemTemplateElement*) 0xDEADBEEF;
+#endif
}
1.2 +14 -6 xml-xalan/c/src/xalanc/XSLT/VariablesStack.hpp
Index: VariablesStack.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/VariablesStack.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VariablesStack.hpp 29 Jun 2003 03:58:08 -0000 1.1
+++ VariablesStack.hpp 2 Aug 2003 01:07:48 -0000 1.2
@@ -126,7 +126,7 @@
* @param elem the element
*/
void
- popElementFrame(const ElemTemplateElement* elem);
+ popElementFrame();
/**
* Push a context marker onto the stack to let us know when to stop
@@ -179,11 +179,13 @@
};
#if defined(XALAN_NO_STD_NAMESPACE)
- typedef vector<ParamsVectorEntry> ParamsVectorType;
- typedef vector<const ElemVariable*> RecursionGuardStackType;
+ typedef vector<ParamsVectorEntry>
ParamsVectorType;
+ typedef vector<const ElemVariable*>
RecursionGuardStackType;
+ typedef vector<const ElemTemplateElement*>
ElemTemplateElementStackType;
#else
- typedef std::vector<ParamsVectorEntry> ParamsVectorType;
- typedef std::vector<const ElemVariable*> RecursionGuardStackType;
+ typedef std::vector<ParamsVectorEntry>
ParamsVectorType;
+ typedef std::vector<const ElemVariable*>
RecursionGuardStackType;
+ typedef std::vector<const ElemTemplateElement*>
ElemTemplateElementStackType;
#endif
/**
@@ -590,7 +592,13 @@
* that are being evaluated dynamically, to protect
* against circular definitions.
*/
- RecursionGuardStackType m_guardStack;
+ RecursionGuardStackType m_guardStack;
+
+ /**
+ * This will be a stack for tracking element frames.
+ * This is only used in debug builds.
+ */
+ ElemTemplateElementStackType m_elementFrameStack;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]