Exemplo n.º 1
0
        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;
            }


        }
Exemplo n.º 2
0
void BytecodeTranslatorVisitor::processBlockNode(BlockNode* node) {
    for (uint32_t i = 0; i < node->nodes(); i++) {
        AstNode* ith = node->nodeAt(i);

        warningIf(isUnused(ith), "unused result of statement");

        VISIT(ith);
        VarType result = popType();

        if (result != VT_VOID && !ith->isReturnNode())
            EMIT(BC_POP);
    }
}
Exemplo n.º 3
0
    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;
        }
    }