本文整理汇总了C++中AST::setRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ AST::setRoot方法的具体用法?C++ AST::setRoot怎么用?C++ AST::setRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST
的用法示例。
在下文中一共展示了AST::setRoot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluatePTClause
bool QueryEvaluator::evaluatePTClause(TNode * PT_node,
vector<int> row,
vector<vector<int>> * new_rows,
ResultTable * temp_result) {
TNode * stmt_node = PT_node->getChildAtIndex(0);
string stmt_name = stmt_node->getValue();
Symbol stmt_type = SyntaxHelper::getSymbolType(table.getType(stmt_name));
int stmt_index=row[0]; // get stmt_index from row
if (stmt_index==-1) {
// retrieve a list of values of stmt_type from PKB
vector<int> stmt_indexes = getAllPKBValues(stmt_name);
for (size_t i=0; i<stmt_indexes.size(); i++) {
//save back stmt_indexes[i] to row
row[0] = stmt_indexes[i];
//recursive call to update new_rows
vector<vector<int>> rows;
bool isSatisfied = evaluatePTClause(PT_node, row, &rows, temp_result);
if (isSatisfied) {
for (size_t j=0; j<rows.size(); j++) {
new_rows->push_back(rows[j]);
}
}
}
} else {
// from here is hell of logic
// get ASTNode of this Stmt
TNode * root = PKB::getASTRoot();
AST tree; tree.setRoot(root);
TNode * ast_node = tree.findNodeOfStmt(stmt_index);
// handle first argument node
TNode * arg1_node = stmt_node->getChildAtIndex(0);
if (!evaluatePTArgNode(arg1_node, ast_node, ARG1, row, new_rows))
return false;
switch(stmt_type) {
case Assign:
{
TNode * expr_node = stmt_node->getChildAtIndex(1);
if (!evaluateExprNode(expr_node, ast_node)) return false;
return true;
}
case While:
{
break;
}
case If:
{
break;
}
default:
break;
}
}
if (!new_rows->empty()) return true;
return false;
}