diff --git a/libwccl/ops/funexeccontext.h b/libwccl/ops/funexeccontext.h index 4a41cccb41bc61b35ea18bdb784da22b658e2597..43e039cb116888d7c4133491ca3e35fefed3de21 100644 --- a/libwccl/ops/funexeccontext.h +++ b/libwccl/ops/funexeccontext.h @@ -4,6 +4,7 @@ #include <boost/noncopyable.hpp> #include <libwccl/variables.h> #include <libwccl/sentencecontext.h> +#include <libwccl/ops/actionexeccontext.h> namespace Wccl { @@ -11,7 +12,8 @@ namespace Wccl { * Class holding execution context of a functional operator * i.e. state that the function should operate on. */ -class FunExecContext : public boost::noncopyable { +class FunExecContext : boost::noncopyable +{ public: FunExecContext( const SentenceContext& sentence_context, const boost::shared_ptr<Variables>& vars) @@ -19,6 +21,13 @@ public: { } + FunExecContext(const ActionExecContext& action_exec_context) + : sentence_context_(action_exec_context.sentence_context()), + vars_(action_exec_context.variables()) + { + // this is intentionally left implicit :) + } + /** * @returns Context of a sentence the operator is applied to. * @note Functional operators should not change sentence state, diff --git a/libwccl/ops/rule.cpp b/libwccl/ops/rule.cpp index 0ff62625678c4a3e2089ba1e57df32f029e3c5f5..ba843bd232e191f2c41c6405ebe95d116b62e5e4 100644 --- a/libwccl/ops/rule.cpp +++ b/libwccl/ops/rule.cpp @@ -16,8 +16,8 @@ Bool Rule::execute(SentenceContext &sentence_context) "Current position is outside boundaries of the sentence."); } Bool changed(false); - if(condition_->apply(FunExecContext(sentence_context, variables_))->get_value()) { - ActionExecContext aec(sentence_context, variables_); + ActionExecContext aec(sentence_context, variables_); + if(condition_->apply(aec)->get_value()) { foreach(const boost::shared_ptr<Action>& action, *actions_) { if(action->execute(aec).get_value()) { changed.set_value(true);