virtual void visitBlockNode(BlockNode * node) { if (currentTabNum >= 0) { out<< "{"<< endl; } ++currentTabNum; visitScope(node->scope()); for (size_t i = 0; i < node->nodes(); ++i) { addIndent(); AstNode * currentNode = node->nodeAt(i); currentNode->visit(this); if (currentNode->isCallNode() || currentNode->isLoadNode() || currentNode->isNativeCallNode() || currentNode->isPrintNode() || currentNode->isReturnNode() || currentNode->isStoreNode()) { out<< ";"<< endl; } } --currentTabNum; if (currentTabNum >= 0) { addIndent(); out<< "}"<< endl; } }
void insideBlock(BlockNode* node) { variableDeclaration(node->scope()); functionDeclaration(node->scope()); for (uint32_t i = 0; i < node->nodes(); i++) { indent(); AstNode* current = node->nodeAt(i); current->visit(this); if (current->isCallNode() || current->isBinaryOpNode() || current->isUnaryOpNode() || current->isStringLiteralNode() || current->isDoubleLiteralNode() || current->isIntLiteralNode() || current->isLoadNode()) _output << ";"; _output << endl; } }
virtual void visitBlockNode(BlockNode *node) { bool topLevel = node->scope()->parent()->parent() == NULL; if (!topLevel) { out << "{" << endl; } printVars(node->scope()); for (uint32_t i = 0; i < node->nodes(); i++) { AstNode *currentNode = node->nodeAt(i); currentNode->visit(this); if (currentNode->isLoadNode() || currentNode->isStoreNode() || currentNode->isReturnNode() || currentNode->isCallNode() || currentNode->isNativeCallNode() || currentNode->isPrintNode()) { out << ";" << endl; } } if (!topLevel) { out << "}" << endl; } }