MCPcopy Create free account
hub / github.com/PDAL/PDAL / uminus

Method uminus

filters/private/expr/MathParser.cpp:122–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122bool MathParser::uminus(Expression& expr)
123{
124 if (!match(TokenType::Dash))
125 return primary(expr);
126
127 if (!primary(expr))
128 {
129 setError("Expecting expression following '-'.");
130 return false;
131 }
132
133 NodePtr sub = expr.popNode(); // Pop the primary.
134 assert(sub.get());
135 ConstValueNode *constnode = dynamic_cast<ConstValueNode *>(sub.get());
136 if (constnode)
137 {
138 double v = -(constnode->value());
139 expr.pushNode(NodePtr(new ConstValueNode(v)));
140 }
141 else
142 expr.pushNode(NodePtr(new UnMathNode(NodeType::Negative, std::move(sub))));
143 return true;
144}
145
146bool MathParser::primary(Expression& expr)
147{

Callers

nothing calls this directly

Calls 4

popNodeMethod · 0.80
pushNodeMethod · 0.80
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected