本文整理汇总了C++中AstNode::isWhileNode方法的典型用法代码示例。如果您正苦于以下问题:C++ AstNode::isWhileNode方法的具体用法?C++ AstNode::isWhileNode怎么用?C++ AstNode::isWhileNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode::isWhileNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printBlockContents
void Printer::printBlockContents(BlockNode* node) {
// functions delcarations
Scope::FunctionIterator funIt(node->scope());
while (funIt.hasNext()) {
funIt.next()->node()->visit(this);
out << '\n';
}
// variables declarations
Scope::VarIterator varIt(node->scope());
while (varIt.hasNext()) {
AstVar* var = varIt.next();
out << typeToName(var->type())
<< " " << var->name() << ";\n";
}
// nodes
for (size_t i = 0; i < node->nodes(); ++i) {
AstNode* subNode = node->nodeAt(i);
subNode->visit(this);
if (!subNode->isIfNode() &&
!subNode->isWhileNode() &&
!subNode->isForNode()) {
out << ';';
}
out << '\n';
}
}
示例2: printBlock
void ASTAnalyzer::printBlock (BlockNode* node) {
for (unsigned int i = 0; i < node->nodes(); ++i) {
AstNode* innerNode = node->nodeAt(i);
innerNode->visit(this);
if (!innerNode->isIfNode() && !innerNode->isWhileNode()
&& !innerNode->isForNode()) {
output << ';';
}
output << '\n';
}
}
示例3: visitBlockNodeWithoutBraces
void SourceByASTPrinter::visitBlockNodeWithoutBraces(BlockNode *node){
Scope::VarIterator vIt(node->scope());
while(vIt.hasNext()) {
AstVar *var = vIt.next();
cout<<typeToName(var->type())<<" "<< var->name()<< ";"<<endl;
}
Scope::FunctionIterator fIt(node->scope());
while(fIt.hasNext()) {
fIt.next()->node()->visit(this);
}
int nodesNumber = node->nodes();
for (int i = 0; i < nodesNumber; ++i) {
AstNode *nodeAt = node->nodeAt(i);
nodeAt->visit(this);
if(!nodeAt->isForNode() && !nodeAt->isIfNode() && !nodeAt->isWhileNode())
cout<<";"<<endl;
}
}
示例4: initLocals
void ByteCodeVisitor::initLocals(BlockNode *blockNode) {
if (blockNode == 0) return;
initVars(blockNode->scope());
for (uint32_t i = 0; i < blockNode->nodes(); ++i) {
AstNode *n = blockNode->nodeAt(i);
if (n->isBlockNode()) {
initLocals(blockNode);
} else if (n->isIfNode()) {
IfNode *ifNode = n->asIfNode();
initLocals(ifNode->thenBlock());
initLocals(ifNode->elseBlock());
} else if (n->isWhileNode()) {
WhileNode *whileNode = n->asWhileNode();
initLocals(whileNode->loopBlock());
} else if (n->isForNode()) {
ForNode *forNode = n->asForNode();
initLocals(forNode->body());
}
}
initChildFunctions(blockNode->scope());
}
示例5: visitBlockNode
void TypeCheckerVisitor::visitBlockNode(BlockNode* node) {
_current_scope = node->scope();
Scope::FunctionIterator funcIt(_current_scope);
while (funcIt.hasNext()) {
AstFunction* func = funcIt.next();
func->node()->visit(this);
}
int nodes_count = node->nodes();
VarType commonType = VT_VOID;
for (int i = 0; i != nodes_count; ++i) {
AstNode* currentNode = node->nodeAt(i);
currentNode->visit(this);
bool isBlockNode = currentNode->isForNode() || currentNode->isWhileNode() || currentNode->isIfNode();
VarType currentNodeType = getNodeType(currentNode);
bool hasType = currentNodeType != VT_VOID;
if ((isBlockNode && hasType) || (i == nodes_count - 1)) {
commonType = getUpperCommonType(commonType, currentNodeType);
}
}
setNodeType(node, commonType);
_current_scope = node->scope()->parent();
}