1
0
Fork 0

Fixed some failures in ConditionFinder

This commit is contained in:
Michael Hackstein 2016-07-14 15:18:13 +02:00
parent 248b8884bd
commit b56a08bb6c
1 changed files with 22 additions and 11 deletions

View File

@ -157,8 +157,8 @@ static bool matchesPathAccessPattern(AstNode const* testee,
return false; return false;
} }
static void transformCondition(AstNode const* node, Variable const* pvar, Ast* ast) { static void transformCondition(AstNode const* node, Variable const* pvar,
Ast* ast, TraversalNode* tn) {
// TODO REMOVE OUTPUT // TODO REMOVE OUTPUT
node->dump(0); node->dump(0);
@ -204,23 +204,34 @@ static void transformCondition(AstNode const* node, Variable const* pvar, Ast* a
case NODE_TYPE_ATTRIBUTE_ACCESS: case NODE_TYPE_ATTRIBUTE_ACCESS:
TRI_ASSERT(baseCondition->numMembers() == 1); TRI_ASSERT(baseCondition->numMembers() == 1);
break; break;
case NODE_TYPE_OPERATOR_BINARY_ARRAY_EQ:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_NE:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_LT:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_LE:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_GT:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_GE:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_IN:
case NODE_TYPE_OPERATOR_BINARY_ARRAY_NIN:
TRI_ASSERT(baseCondition->numMembers() == 3);
break;
default: default:
TRI_ASSERT(false); TRI_ASSERT(false);
break; break;
} }
#endif #endif
// Navigate left side auto op = baseCondition->type;
// If we navigate over the side where access to path if (op >= NODE_TYPE_OPERATOR_BINARY_ARRAY_EQ &&
// variable is we can only find an arbitrary op <= NODE_TYPE_OPERATOR_BINARY_ARRAY_NIN) {
// amount of indexedAccess and attributeAccess. // TODO
// And the last 3 elements are: continue;
// If we find something else we abort. }
bool foundVar = false; bool foundVar = false;
bool isEdge = false; bool isEdge = false;
size_t idx = 0; size_t idx = 0;
AstNode* top = baseCondition; AstNode* top = baseCondition;
TRI_ASSERT(baseCondition->numMembers() == 2);
for (size_t i = 0; i < 2; ++i) { for (size_t i = 0; i < 2; ++i) {
AstNode* testee = baseCondition->getMemberUnchecked(i); AstNode* testee = baseCondition->getMemberUnchecked(i);
// Special case directly compare documents: // Special case directly compare documents:
@ -229,6 +240,7 @@ static void transformCondition(AstNode const* node, Variable const* pvar, Ast* a
TRI_ASSERT(!foundVar); TRI_ASSERT(!foundVar);
foundVar = true; foundVar = true;
top->changeMember(i, varRefNode); top->changeMember(i, varRefNode);
tn->registerCondition(isEdge, idx, baseCondition);
break; break;
} }
@ -244,6 +256,7 @@ static void transformCondition(AstNode const* node, Variable const* pvar, Ast* a
TRI_ASSERT(!foundVar); TRI_ASSERT(!foundVar);
foundVar = true; foundVar = true;
top->changeMember(i, varRefNode); top->changeMember(i, varRefNode);
tn->registerCondition(isEdge, idx, baseCondition);
break; break;
} }
} }
@ -253,13 +266,11 @@ static void transformCondition(AstNode const* node, Variable const* pvar, Ast* a
} }
} }
} }
result->dump(0);
} }
static bool extractSimplePathAccesses(AstNode const* node, TraversalNode* tn, static bool extractSimplePathAccesses(AstNode const* node, TraversalNode* tn,
Ast* ast) { Ast* ast) {
transformCondition(node, tn->pathOutVariable(), ast); transformCondition(node, tn->pathOutVariable(), ast, tn);
std::vector<AstNode const*> currentPath; std::vector<AstNode const*> currentPath;
std::vector<std::vector<AstNode const*>> paths; std::vector<std::vector<AstNode const*>> paths;
std::vector<std::vector<AstNode const*>> clonePath; std::vector<std::vector<AstNode const*>> clonePath;