2 #ifndef _MADARA_NO_KARL_
44 value = array_->item();
55 bool left_child_can_change =
false;
56 bool right_child_can_change =
false;
59 if (this->var_ != 0 || this->array_ != 0)
60 left_child_can_change =
true;
64 "madara::expression::VariableDecrementNode: "
65 "KARL COMPILE ERROR: Variable assignment has no variable\n");
68 "madara::expression::VariableDecrementNode: "
69 "KARL COMPILE ERROR: "
70 "Node has no variable left-hand side\n");
75 right_value = this->rhs_->prune(right_child_can_change);
76 if (!right_child_can_change &&
dynamic_cast<LeafNode*
>(rhs_) == 0)
79 this->rhs_ =
new LeafNode(*(this->logger_), right_value);
85 "madara::expression::VariableDecrementNode: "
86 "KARL COMPILE ERROR: Variable assignment has no right expression\n");
89 "madara::expression::VariableDecrementNode: "
90 "KARL COMPILE ERROR: "
91 "Node has no right expression\n");
94 can_change = left_child_can_change || right_child_can_change;
108 rhs = rhs_->evaluate(settings);
115 "madara::expression::CompositeAssignmentNode::evaluate: "
116 "Attempting to set variable %s to %s.\n",
117 var_->expand_key().c_str(), rhs.
to_string().c_str());
120 var_->set(result, settings);
126 "madara::expression::CompositeAssignmentNode::evaluate: "
127 "Attempting to set index of var %s to %s.\n",
128 array_->expand_key().c_str(), rhs.
to_string().c_str());
131 array_->set(result, settings);
137 "madara::expression::CompositeAssignmentNode::evaluate: "
138 "left hand side was neither a variable nor an array reference. "
139 "Check your expression for errors.\n",
140 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.
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 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.
virtual void accept(Visitor &visitor) const
Define the accept() operation used for the Visitor pattern.
VariableNode * var_
variable holder
VariableDecrementNode(ComponentNode *lhs, madara::knowledge::KnowledgeRecord value, ComponentNode *rhs, madara::knowledge::ThreadSafeContext &context)
Ctor.
virtual ~VariableDecrementNode(void)
Dtor.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prune the tree of unnecessary nodes.
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...