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::VariableMultiplyNode: "
65 "KARL COMPILE ERROR: Variable assignment has no variable\n");
68 "KARL COMPILE ERROR: "
69 "Node has no variable left-hand side\n");
74 right_value = this->rhs_->prune(right_child_can_change);
75 if (!right_child_can_change &&
dynamic_cast<LeafNode*
>(rhs_) == 0)
78 this->rhs_ =
new LeafNode(*(this->logger_), right_value);
84 "madara::expression::VariableMultiplyNode: "
85 "KARL COMPILE ERROR: Variable assignment has no right expression\n");
88 "KARL COMPILE ERROR: "
89 "Node has no right expression\n");
92 can_change = left_child_can_change || right_child_can_change;
106 rhs = rhs_->evaluate(settings);
113 "madara::expression::VariableMultiplyNode::evaluate: "
114 "Attempting to set variable %s to %s.\n",
115 var_->expand_key().c_str(), rhs.
to_string().c_str());
118 var_->set(result, settings);
124 "madara::expression::VariableMultiplyNode::evaluate: "
125 "Attempting to set index of var %s to %s.\n",
126 array_->expand_key().c_str(), rhs.
to_string().c_str());
129 array_->set(result, settings);
135 "madara::expression::VariableMultiplyNode::evaluate: "
136 "left hand side was neither a variable nor an array reference. "
137 "Check your expression for errors.\n",
138 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 prune(bool &can_change)
Prune the tree of unnecessary nodes.
virtual madara::knowledge::KnowledgeRecord item(void) const
Return the item stored in the node.
VariableNode * var_
variable holder
virtual ~VariableMultiplyNode(void)
Dtor.
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.
VariableMultiplyNode(ComponentNode *lhs, madara::knowledge::KnowledgeRecord value, ComponentNode *rhs, madara::knowledge::ThreadSafeContext &context)
Ctor.
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...