1
0
Fork 0

added unary operator

This commit is contained in:
Jan Steemann 2014-09-19 17:46:36 +02:00
parent 9f08e441fd
commit ae5f454bfc
2 changed files with 20 additions and 0 deletions

View File

@ -664,6 +664,10 @@ bool AstNode::isSimple () const {
return (getMember(0)->isSimple() && getMember(1)->isSimple());
}
if (type == NODE_TYPE_OPERATOR_UNARY_NOT) {
return getMember(0)->isSimple();
}
if (type == NODE_TYPE_FCALL) {
// some functions have C++ handlers
// check if the called function is one of them

View File

@ -404,6 +404,22 @@ AqlValue Expression::executeSimpleExpression (AstNode const* node,
return res;
}
else if (node->type == NODE_TYPE_OPERATOR_UNARY_NOT) {
TRI_document_collection_t const* myCollection = nullptr;
AqlValue operand = executeSimpleExpression(node->getMember(0), &myCollection, trx, docColls, argv, startPos, vars, regs);
bool operandIsBoolean = operand.isBoolean();
bool operandIsTrue = operand.isTrue();
operand.destroy();
if (! operandIsBoolean) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_INVALID_LOGICAL_VALUE);
}
return AqlValue(new triagens::basics::Json(! operandIsTrue));
}
else if (node->type == NODE_TYPE_OPERATOR_BINARY_AND ||
node->type == NODE_TYPE_OPERATOR_BINARY_OR) {
TRI_document_collection_t const* leftCollection = nullptr;