mirror of
https://github.com/jezhiggins/arabica
synced 2024-11-17 07:48:50 +01:00
litte bit more work on variable resolution, but train in v wobbly and it giving me a headache
This commit is contained in:
parent
42bcf3566b
commit
6785fd8944
3 changed files with 39 additions and 4 deletions
|
@ -112,6 +112,37 @@ private:
|
|||
}; // class ExecutionContext
|
||||
|
||||
///////////////////////////
|
||||
class ResolvedVariable : public Variable_instance
|
||||
{
|
||||
public:
|
||||
ResolvedVariable(const Variable_declaration& var,
|
||||
const DOM::Node<std::string>& node,
|
||||
ExecutionContext& context) :
|
||||
var_(var)
|
||||
{
|
||||
DOMSink sink;
|
||||
value_ = var_.value(node, context, sink);
|
||||
} // ResolvedVariable
|
||||
|
||||
virtual const std::string& name() const { return var_.name(); }
|
||||
virtual const Precedence& precedence() const { return var_.precedence(); }
|
||||
virtual Arabica::XPath::XPathValue<std::string> value() const { return value_; }
|
||||
|
||||
virtual void injectGlobalScope(const Scope& scope) const
|
||||
{
|
||||
;
|
||||
} // globalScope
|
||||
|
||||
private:
|
||||
const Variable_declaration& var_;
|
||||
mutable Arabica::XPath::XPathValue<std::string> value_;
|
||||
|
||||
ResolvedVariable();
|
||||
ResolvedVariable(const ResolvedVariable&);
|
||||
ResolvedVariable& operator=(const ResolvedVariable&);
|
||||
const ResolvedVariable& operator==(const ResolvedVariable&) const;
|
||||
}; // class ResolvedVariable
|
||||
|
||||
class VariableClosure : public Variable_instance
|
||||
{
|
||||
public:
|
||||
|
@ -119,6 +150,9 @@ public:
|
|||
const DOM::Node<std::string>& node,
|
||||
ExecutionContext& context)
|
||||
{
|
||||
if(var.precedence() == Precedence::FrozenPrecedence()) // we're running, so resolve immediately
|
||||
return Variable_instance_ptr(new ResolvedVariable(var, node, context));
|
||||
|
||||
return Variable_instance_ptr(new VariableClosure(var, node, context));
|
||||
} // create
|
||||
|
||||
|
|
|
@ -120,9 +120,6 @@ public:
|
|||
return;
|
||||
} // if ...
|
||||
|
||||
if(var->precedence() == Precedence::FrozenPrecedence()) // we're running, so resolve immediately
|
||||
var->value();
|
||||
|
||||
stack[name] = var;
|
||||
} // declareVariable
|
||||
|
||||
|
|
|
@ -29,4 +29,8 @@ Performance
|
|||
params - avoid creating closure for xsl:param if the param has been passed - DONE
|
||||
- if running, resolve variable immediately, don't bother to create closure
|
||||
- when declaring variable, don't create closure/resolve if higher-precedence variable already exists
|
||||
- bin variable_instance_pointer, think I can pass by value
|
||||
- bin variable_instance_pointer, think I can pass by value
|
||||
- actually, I think we avoid the whole closure creation business by getting the variables to pass in themselves,
|
||||
or a simple wrapper around themselves. Top-level variables can hang on to a pointer to the toplevel injected context.
|
||||
Top level variables are the only ones that need to worry about precedence. Immediate variable can just look up by name,
|
||||
then get on with it.
|
Loading…
Reference in a new issue