当前位置: 首页>>代码示例>>C++>>正文


C++ AstNode::isIfNode方法代码示例

本文整理汇总了C++中AstNode::isIfNode方法的典型用法代码示例。如果您正苦于以下问题:C++ AstNode::isIfNode方法的具体用法?C++ AstNode::isIfNode怎么用?C++ AstNode::isIfNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AstNode的用法示例。


在下文中一共展示了AstNode::isIfNode方法的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';
    }
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:28,代码来源:printer.cpp

示例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';
    }
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:11,代码来源:ast_analyzer.cpp

示例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;
	}
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:20,代码来源:SourceByASTPrinter.cpp

示例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());
}
开发者ID:kamanov,项目名称:Shared,代码行数:21,代码来源:bytecode_visitor.cpp

示例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();
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:22,代码来源:typechecker.cpp


注:本文中的AstNode::isIfNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。