2 #ifndef _MADARA_NO_KARL_
45 value = array_->item();
56 bool left_child_can_change =
false;
57 bool right_child_can_change =
false;
60 if (this->var_ != 0 || this->array_ != 0)
61 left_child_can_change =
true;
65 "madara::expression::VariableIncrementNode: "
66 "KARL COMPILE ERROR: Variable assignment has no variable\n");
69 "madara::expression::VariableIncrementNode: "
70 "KARL COMPILE ERROR: "
71 "Node has no variable left-hand side\n");
76 right_value = this->rhs_->prune(right_child_can_change);
77 if (!right_child_can_change &&
dynamic_cast<LeafNode*
>(rhs_) == 0)
80 this->rhs_ =
new LeafNode(*(this->logger_), right_value);
86 "madara::expression::VariableIncrementNode: "
87 "KARL COMPILE ERROR: Variable assignment has no right expression\n");
90 "madara::expression::VariableIncrementNode: "
91 "KARL COMPILE ERROR: "
92 "Node has no right expression\n");
95 can_change = left_child_can_change || right_child_can_change;
109 rhs = rhs_->evaluate(settings);
116 "madara::expression::CompositeAssignmentNode::evaluate: "
117 "Attempting to set variable %s to %s.\n",
118 var_->expand_key().c_str(), rhs.
to_string().c_str());
121 var_->set(result, settings);
127 "madara::expression::CompositeAssignmentNode::evaluate: "
128 "Attempting to set index of var %s to %s.\n",
129 array_->expand_key().c_str(), rhs.
to_string().c_str());
132 array_->set(result, settings);
138 "madara::expression::CompositeAssignmentNode::evaluate: "
139 "left hand side was neither a variable nor an array reference. "
140 "Check your expression for errors.\n",
141 array_->expand_key().c_str(), rhs.
to_string().c_str());
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
const ThreadSafeContext * context_
An exception for unrecoverable KaRL compilation issues.
An abstract base class defines a simple abstract implementation of an expression tree node.
Defines a terminal node of that references the current value stored in a variable.
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value.
virtual void accept(Visitor &visitor) const
Define the accept() operation used for the Visitor pattern.
VariableNode * var_
variable holder
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prune the tree of unnecessary nodes.
VariableIncrementNode(ComponentNode *lhs, madara::knowledge::KnowledgeRecord value, ComponentNode *rhs, madara::knowledge::ThreadSafeContext &context)
Ctor.
virtual ~VariableIncrementNode(void)
Dtor.
virtual madara::knowledge::KnowledgeRecord item(void) const
Return the item stored in the node.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the node and its children.
CompositeArrayReference * array_
variable index holder
Defines a terminal node of that references the current value stored in a variable.
Abstract base class for all visitors to all classes that derive from ComponentNode.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
This class encapsulates an entry in a KnowledgeBase.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...