这篇教程C++ visitNode函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中visitNode函数的典型用法代码示例。如果您正苦于以下问题:C++ visitNode函数的具体用法?C++ visitNode怎么用?C++ visitNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了visitNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: switchGLSLValue* GLSLVisitor::visitNode(GLSLUnaryExpression* const unary){ if (! unary) return 0; GLSLExpression* const operand = unary->getExpression(); if (! operand) return 0; GLSLValue* res = 0; switch (operand->getNodeType()) { case GLSLNodeTypes::NODE_POSTFIX_EXPRESSION: res = visitNode(static_cast<GLSLPostfixExpression* const>(operand)); break; case GLSLNodeTypes::NODE_UNARY_EXPRESSION: res = visitNode(static_cast<GLSLUnaryExpression*>(operand)); break; } // switch // TODO: to "really" evaluate this expression, check opToken, value and // apply that operator. //Token* const opToken = unary->getToken(); return res;}
开发者ID:151706061,项目名称:Voreen,代码行数:27,
示例2: switchbool AnnotationVisitor::visit(ParseTreeNode* const node) { if (node == 0) return false; bool res = true; try { switch (node->getNodeType()) { case AnnotationNodeTypes::NODE_ANNOTATION: visitNode(dynamic_cast<AnnotationNode*>(node)); break; case AnnotationNodeTypes::NODE_ANNOTATION_TAGS: visitNode(dynamic_cast<AnnotationTags*>(node)); break; case AnnotationNodeTypes::NODE_ANNOTATION_TAG_NAME: visitNode(dynamic_cast<AnnotationTagName*>(node)); break; case AnnotationNodeTypes::NODE_ANNOTATION_TAG_VALUES: visitNode(dynamic_cast<AnnotationTagValues*>(node)); break; default: res = false; log_ << "AnnotationVisitor::visit() called for ParseTreeNode!/n"; break; } // switch } catch (std::runtime_error& e) { log_ << " Exception: " << e.what() << "/n"; return false; } return res;}
开发者ID:151706061,项目名称:Voreen,代码行数:35,
示例3: visitNodevoid DefaultVisitor::visitStatement(StatementAst *node){ visitNode(node->assignStmt); visitNode(node->ifStmt); visitNode(node->blockStmt); visitNode(node->returnStmt);}
开发者ID:KDE,项目名称:kdevelop-pg-qt,代码行数:7,
示例4: visitNodeGLSLValue* GLSLVisitor::visitNode(GLSLCondition* const cond){ if (! cond) return 0; GLSLTypeSpecifier* const spec = cond->getTypeSpecifier(); IdentifierToken* const id = cond->getIdentifier(); if ((spec) && (id)) { try { GLSLVariableSymbol symbol = visitNode(spec); symbol.setID(id->getValue()); symbol.setIsArray(false); symbol.setNumArrayElements(0); activeSymbols_->insertSymbol(new GLSLVariableSymbol(symbol)); } catch (std::runtime_error& e) { log_ << " Exeption in GLSLVisitor::visitNode(GLSLCondition*): " << e.what() << "/n"; } } // If spec and id where both not NULL, the expression is the initializer // // NOTE: initializer is however only an assignemnt expression, not // an arbitrary expression to be more precise. return visitNode(cond->getExpression());}
开发者ID:151706061,项目名称:Voreen,代码行数:27,
示例5: visitNodeint PreprocessorVisitor::visitNode(LogicalExpression* const n) { if (LogicalBinaryExpression* const lbex = dynamic_cast<LogicalBinaryExpression* const>(n)) return visitNode(lbex); else if (DefinedOperator* const defop = dynamic_cast<DefinedOperator* const>(n)) return visitNode(defop); throw std::runtime_error("unknown logical expression class!");}
开发者ID:alvatar,项目名称:smartmatter,代码行数:8,
示例6: ifint PreprocessorVisitor::visitNode(ArithmeticExpression* const n) { if (IntConstant* const c = dynamic_cast<IntConstant* const>(n)) return c->getValue(); else if (BinaryExpression* const b = dynamic_cast<BinaryExpression* const>(n)) return visitNode(b); else if (UnaryExpression* const u = dynamic_cast<UnaryExpression* const>(n)) return visitNode(u); throw std::runtime_error("error: unknown arithmetic expression class!");}
开发者ID:alvatar,项目名称:smartmatter,代码行数:10,
示例7: visitNodevoid CloneTree::visitCons(Model::ConsItem *node){ visitNode(node->mLeft); Model::Node *left = mTemps.top(); mTemps.pop(); visitNode(node->mRight); Model::Node *right = mTemps.top(); mTemps.pop(); mTemps.push(KDevPG::cons(left, right));}
开发者ID:KDE,项目名称:kdevelop-pg-qt,代码行数:14,
示例8: kthSmallest int kthSmallest(TreeNode *pRoot, int k) { if (!pRoot) return 0; auto ret = 0; auto iterCount = 0; std::vector<TreeNode*> nodes; nodes.push_back(pRoot); while (!nodes.empty()) { TreeNode *pNode = nodes.back(); if (pushNodeIfNotNull(&nodes, pNode->left)) continue; if (visitNode(pNode, &iterCount, k, &ret)) break; if (pushNodeIfNotNull(&nodes, pNode->right)) continue; bool found = false; TreeNode *pChild = pNode; TreeNode *pParent = nullptr; while (true) { nodes.pop_back(); if (nodes.empty()) break; // 遍历完左子树的话,先回溯到父结点,再开始遍历右子树,如果有的话 pParent = nodes.back(); if (pChild == pParent->left) { found = visitNode(pParent, &iterCount, k, &ret); if (pushNodeIfNotNull(&nodes, pParent->right)) break; } pChild = pParent; } if (found) break; } return ret; }
开发者ID:fish47,项目名称:leetcode,代码行数:48,
示例9: whilevoidGraphvizFunction::printGraph( ItemFactory* aFactory, const Item& in, std::fstream& os){ // create helper qnames for comparison Item lNodeQName = aFactory->createQName("", "", "node"); Item lEdgeQName = aFactory->createQName("", "", "edge"); Item lRelQName = aFactory->createQName("", "", "rel"); // print the graph with all its children Item lGraphId; if (!getAttribute(aFactory, "id", in, lGraphId)) { GraphvizFunction::throwErrorWithQName(aFactory, "IM003", "GXL parse error: edge does not have an 'id' attribute"); } os << "digraph /"" << lGraphId.getStringValue() << "/" {" << std::endl; // visit nodes and edges (TODO add rel elements) Iterator_t lChildren = in.getChildren(); lChildren->open(); Item item; while (lChildren->next(item)) { Item lNodeName; item.getNodeName(lNodeName); if (lNodeName.getLocalName() == lNodeQName.getLocalName()) { visitNode(aFactory, item, os); } else if (lNodeName.getLocalName() == lEdgeQName.getLocalName()) { visitEdge(aFactory, item, os); } } os << "}" << std::endl;} /* GraphvizFunction::printGraph */
开发者ID:28msec,项目名称:zorba-graphviz-module,代码行数:34,
示例10: whilevoid CodeGenerator::visitAlternative(Model::AlternativeItem *node){ QList<Model::Node*> top_level_nodes; QStack<Model::Node*> working_list; working_list.push(node->mRight); working_list.push(node->mLeft); while (!working_list.empty()) { Model::Node *n = working_list.top(); working_list.pop(); if (Model::AlternativeItem *a = nodeCast<Model::AlternativeItem*>(n)) { working_list.push(a->mRight); working_list.push(a->mLeft); } else { top_level_nodes.push_back(n); } } QList<Model::Node*>::iterator it = top_level_nodes.begin(); while (it != top_level_nodes.end()) { Model::Node *n = *it; ++it; Model::ConditionItem *cond = nodeCast<Model::ConditionItem*>(n); out << "if ("; if (cond) out << "("; generateTestCondition(n, out); if (cond) out << ") && (" << cond->mCode << ")"; out << ") {" << endl; visitNode(n); out << "}"; if (it != top_level_nodes.end()) out << "else "; else { out << "else {" << endl; if (!mCurrentCatchId) out << "return false;" << endl; else out << "goto __catch_" << mCurrentCatchId << ";"; out << "}" << endl; } }}
开发者ID:KDE,项目名称:kdevelop-pg-qt,代码行数:60,
示例11: generateTestConditionvoid CodeGenerator::visitEvolve(Model::EvolveItem *node){ out << "if ("; Model::ConditionItem *cond = nodeCast<Model::ConditionItem*>(node->mItem); if (cond) out << "("; generateTestCondition(node, out); if (reducesToEpsilon(node->mItem)) { out << " || "; generateCondition(globalSystem.follow(node->mSymbol), out); } if (cond) out << ") && (" << cond->mCode << ")"; out << ") {" << endl; GenerateLocalDeclarations gen_locals(out, mNames); gen_locals(node->mItem); out << node->mCode; visitNode(node->mItem); if (globalSystem.start.contains(node->mSymbol)) out << "if (Token_EOF != yytoken) { return false; }" << endl; out << "}" << endl;}
开发者ID:KDE,项目名称:kdevelop-pg-qt,代码行数:34,
示例12: invokeNativept_value invokeNative(pt_native *native, pt_node *node) { extern pt_value UNDEF; extern pt_value visitNode(pt_node *node); extern pt_value visitTerminal(pt_node *node); if(native == NULL || node == NULL) return UNDEF; switch(native->type) { case PNT_FUNCTION: { pt_node *args = node->next; int idx, count = node->count; pt_value *values = malloc(sizeof(pt_value) * count); if(values == NULL) return UNDEF; values[0] = visitTerminal(node); for(idx = 1; idx < count; idx++) { values[idx] = visitNode(args); if(values[idx].type == PT_UNDEF) { /* TODO */ free(values); return UNDEF; } args = args->next; } return native->u.function(values, count); } case PNT_EXTENSION: return native->u.extension(node, node->count); default: /* TODO */ return UNDEF; }}
开发者ID:Winter-M,项目名称:Trot,代码行数:35,
示例13: _inorderTreeWalkstatic void _inorderTreeWalk(TreeNode * curNode, void (visitNode)(TreeNode * node)) { if (curNode) { _inorderTreeWalk(curNode->left, visitNode); visitNode(curNode); _inorderTreeWalk(curNode->right, visitNode); }}
开发者ID:ColdOrange,项目名称:DataStructures,代码行数:7,
示例14: visitNodevoid AnnotationVisitor::visitNode(AnnotationNode* const node) { if (node == 0) return; if (AnnotationTags* const n = dynamic_cast<AnnotationTags* const>(node)) visitNode(n); else if (AnnotationTagName* const n = dynamic_cast<AnnotationTagName* const>(node)) visitNode(n); else if (AnnotationTagValues* const n = dynamic_cast<AnnotationTagValues* const>(node)) { try { visitNode(n); } catch (std::runtime_error& e) { log_ << " Exception: " << e.what() << "/n"; } }}
开发者ID:151706061,项目名称:Voreen,代码行数:16,
示例15: switchint PreprocessorVisitor::visitNode(UnaryExpression* const n) { switch (n->getSymbolID()) { case PreprocessorTerminals::ID_PLUS: return visitNode(n->getExpression()); case PreprocessorTerminals::ID_DASH: return (-visitNode(n->getExpression())); case PreprocessorTerminals::ID_OP_COMPLEMENT: return (~ visitNode(n->getExpression())); case PreprocessorTerminals::ID_OP_NOT: return (! visitNode(n->getExpression())); } throw std::runtime_error("unknown unary operator!");}
开发者ID:alvatar,项目名称:smartmatter,代码行数:17,
注:本文中的visitNode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ visitNodes函数代码示例 C++ visitChildren函数代码示例 |