void QTreeValidator::validatePTClause(QueryData & queryData, PTClauseEntry * ptClausePtr, const std::vector<std::string>& synList) { QEvalPTClause *evalPtClause = new QEvalPTClause(); evalPtClause->ptType = ptClausePtr->getPatternType(); idx_t tmpIdx = getVarArgIdx(synList, ptClausePtr->getSynonym()); assert(ARG_IDX_NOT_FOUND != tmpIdx); assert(isDecArgStmtType(queryData.getVarDecType(tmpIdx))); evalPtClause->stmt = tmpIdx; determineVar(evalPtClause->var, evalPtClause->varArgType, ptClausePtr->getFirstParameter(), synList, true); if (evalPtClause->ptType == PTClauseType::PT_Assign) { std::string patternStr = ptClausePtr->getSecondParameter(); if (isImplicit(patternStr)) { evalPtClause->pattern = ""; evalPtClause->completeMatch = false; } else if (isDoubleQuoted(patternStr)) { evalPtClause->pattern = dropDoubleQuote(patternStr); evalPtClause->completeMatch = true; } else if (isUnderlineDoubleQuoted(patternStr)) { evalPtClause->pattern = dropUnderlineDoubleQuote(patternStr); evalPtClause->completeMatch = false; } else { assert(false); } } evalPtClause->inVarArgIdxSet.insert(evalPtClause->stmt); if (ArgType::DECVAR == evalPtClause->varArgType) { evalPtClause->inVarArgIdxSet.insert(evalPtClause->var); } queryData.appendQEvalClause(evalPtClause); }
void QTreeValidator::validateSTClause(QueryData & queryData, STClauseEntry * stClausePtr, const std::vector<std::string>& synList) { QEvalSTClause* evalStClause = new QEvalSTClause(); std::string firstInput = stClausePtr->getFirstParameter(), secondInput = stClausePtr->getSecondParameter(); evalStClause->stType = stClausePtr->getClauseType(); switch (evalStClause->stType) { case ST_ModifiesS: case ST_UsesS: validateSTSModUseClause(evalStClause, firstInput, secondInput, synList); break; case ST_ModifiesP: case ST_UsesP: validateSTPModUseClause(evalStClause, firstInput, secondInput, synList); break; case ST_Follows: case ST_FollowsA: case ST_Parent: case ST_ParentA: case ST_Next: case ST_NextA: case ST_Affects: case ST_AffectsA: validateSTPFAXClause(evalStClause, firstInput, secondInput, synList); break; case ST_Calls: case ST_CallsA: validateCallClause(evalStClause, firstInput, secondInput, synList); break; default: assert(false); } if (ArgType::DECVAR == evalStClause->firstType) { evalStClause->inVarArgIdxSet.insert(evalStClause->first); } if (ArgType::DECVAR == evalStClause->secondType) { evalStClause->inVarArgIdxSet.insert(evalStClause->second); } queryData.appendQEvalClause(evalStClause); }
void QTreeValidator::validateWTClause(QueryData & queryData, WTClauseEntry * wtClausePtr, const std::vector<std::string>& synList, const std::vector<std::string>& implList) { QEvalWTClause *evalWtClause = new QEvalWTClause(); const WithRefType refType = wtClausePtr->getLeftRefType(); assert(refType == wtClausePtr->getRightRefType()); const std::string lSyn = wtClausePtr->getLeftSyn(), rSyn = wtClausePtr->getRightSyn(); idx_t firstIdx = IDX_NOT_FOUND, secondIdx = IDX_NOT_FOUND; std::string firstStr, secondStr; ArgType firstType = ArgType::NOT_SPECIFIED, secondType = ArgType::NOT_SPECIFIED; const WithAttrRefType firstAttrRefType = wtClausePtr->getLeftAttrType(), secondAttrRefType = wtClausePtr->getRightAttrType(); // determine type determineArgIdxType(firstIdx, firstType, lSyn, synList, implList); determineArgIdxType(secondIdx, secondType, rSyn, synList, implList); // determine not specified type // not in implList, not in synList if (ArgType::NOT_SPECIFIED == firstType) { firstType = ArgType::CONST; if (refType == WithRefType::W_Integer) { firstIdx = std::stoi(lSyn); } else if (refType == WithRefType::W_String) { assert(isDoubleQuoted(lSyn)); firstStr = dropDoubleQuote(lSyn); } else { assert(false); } } if (ArgType::NOT_SPECIFIED == secondType) { secondType = ArgType::CONST; if (refType == WithRefType::W_Integer) { secondIdx = std::stoi(rSyn); } else if (refType == WithRefType::W_String) { assert(isDoubleQuoted(rSyn)); secondStr = dropDoubleQuote(rSyn); } else { assert(false); } } evalWtClause->first = firstIdx; evalWtClause->second = secondIdx; evalWtClause->firstStr = firstStr; evalWtClause->secondStr = secondStr; evalWtClause->firstType = firstType; evalWtClause->secondType = secondType; evalWtClause->firstAttrRefType = firstAttrRefType; evalWtClause->secondAttrRefType = secondAttrRefType; evalWtClause->refType = refType; if (evalWtClause->firstType == ArgType::DECVAR) { evalWtClause->inVarArgIdxSet.insert(evalWtClause->first); } if (evalWtClause->secondType == ArgType::DECVAR) { evalWtClause->inVarArgIdxSet.insert(evalWtClause->second); } queryData.appendQEvalClause(evalWtClause); }