increment changes with the aim of improviing performance of variables

This commit is contained in:
jez 2009-11-23 21:02:33 +00:00
commit aa518e3964
5 changed files with 50 additions and 3 deletions

View file

@ -27,6 +27,26 @@ protected:
} // declare
}; // Param
class GlobalParam : public Variable_impl
{
public:
GlobalParam(const std::string& name,
const Arabica::XPath::XPathExpressionPtr<std::string>& select,
const Precedence& precedence) :
Variable_impl(name, select, precedence)
{
} // GlobalParam
virtual ~GlobalParam() { }
protected:
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
{
context.declareParam(node, *this);
} // declare
}; // GlobalParam
} // namespace XSLT
} // namespace Arabica
#endif

View file

@ -196,11 +196,11 @@ const ChildElement StylesheetHandler::allowedChildren[] =
{ "key", CreateHandler<KeyHandler>},
{ "namespace-alias", CreateHandler<NamespaceAliasHandler>},
{ "output", CreateHandler<OutputHandler>},
{ "param", CreateHandler<TopLevelVariableHandler<Param> >},
{ "param", CreateHandler<TopLevelVariableHandler<GlobalParam> >},
{ "preserve-space", CreateHandler<NotImplementedYetHandler>},
{ "strip-space", CreateHandler<NotImplementedYetHandler>},
{ "template", CreateHandler<TemplateHandler> },
{ "variable", CreateHandler<TopLevelVariableHandler<Variable> > },
{ "variable", CreateHandler<TopLevelVariableHandler<GlobalVariable> > },
{ 0, 0 }
}; // StylesheetHandler::allowedChildren

View file

@ -26,6 +26,24 @@ public:
} // declare
}; // Variable
class GlobalVariable : public Variable_impl
{
public:
GlobalVariable(const std::string& name,
const Arabica::XPath::XPathExpressionPtr<std::string>& select,
const Precedence precedence) :
Variable_impl(name, select, precedence)
{
} // Variable
virtual ~GlobalVariable() { }
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
{
context.declareVariable(node, *this);
} // declare
}; // class GlobalVariable
} // namespace XSLT
} // namespace Arabica
#endif

View file

@ -12,7 +12,7 @@ namespace XSLT
{
class Variable_instance;
typedef boost::shared_ptr<Variable_instance> Variable_instance_ptr;
typedef Variable_instance* Variable_instance_ptr;
typedef std::map<std::string, Variable_instance_ptr> Scope;
class Variable_instance

View file

@ -1,3 +1,12 @@
Introduce GlobalVariable and GlobalParam.
Rename Variable_instance to DeclaredVariable.
Get rid of Variable_declaration. Variables should implement Variable_instance.
Normal variables don't bother with injectGlobalScope, GlobalVariables do.
Variables become their own closures. Forget all the ref counting nonsense, it is not necessary.
Normal variables resolve immediately and push themselves on the stack.
GlobalVariables resolve on demand.
====================================================
Elements test suite
Errors test suite