// Traverse a block node.
void TIntermTraverser::traverseBlock(TIntermBlock *node)
{
    bool visit = true;

    TIntermSequence *sequence = node->getSequence();

    if (preVisit)
        visit = visitBlock(PreVisit, node);

    if (visit)
    {
        incrementDepth(node);
        pushParentBlock(node);

        for (auto *child : *sequence)
        {
            child->traverse(this);
            if (visit && inVisit)
            {
                if (child != sequence->back())
                    visit = visitBlock(InVisit, node);
            }

            incrementParentBlockPos();
        }

        popParentBlock();
        decrementDepth();
    }

    if (visit && postVisit)
        visitBlock(PostVisit, node);
}
Beispiel #2
0
static void DumpVisitor_visitIfStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	DUMPER(self)->indent++;
	emit_string("If", "", "", DUMPER(self)->indent - 1);
	handleExpr(kctx, self, Stmt_getFirstExpr(kctx, stmt));
	emit_string("Then", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getFirstBlock(kctx, stmt));
	emit_string("Else", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getElseBlock(kctx, stmt));
	DUMPER(self)->indent--;
}
Beispiel #3
0
static void DumpVisitor_visitLoopStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	DUMPER(self)->indent++;
	emit_string("Loop", "", "", DUMPER(self)->indent - 1);
	handleExpr(kctx, self, Stmt_getFirstExpr(kctx, stmt));
	emit_string("Body", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getFirstBlock(kctx, stmt));
	DUMPER(self)->indent--;
}
Beispiel #4
0
void ClastVisitor::visit(const clast_stmt *stmt) {
  if (CLAST_STMT_IS_A(stmt, stmt_root))
    assert(false && "No second root statement expected");
  else if (CLAST_STMT_IS_A(stmt, stmt_ass))
    return visitAssignment((const clast_assignment *)stmt);
  else if (CLAST_STMT_IS_A(stmt, stmt_user))
    return visitUser((const clast_user_stmt *)stmt);
  else if (CLAST_STMT_IS_A(stmt, stmt_block))
    return visitBlock((const clast_block *)stmt);
  else if (CLAST_STMT_IS_A(stmt, stmt_for))
    return visitFor((const clast_for *)stmt);
  else if (CLAST_STMT_IS_A(stmt, stmt_guard))
    return visitGuard((const clast_guard *)stmt);

  if (stmt->next)
    visit(stmt->next);
}
Beispiel #5
0
std::string UAPN::visit(QDAS::DispatchAction * a, std::string continuationPlace, std::string scope) {
    const QDAS::Queue * q = qdas->getQueueNamed(a->queue);
    if (!q->isSerial()) {
        return QPN::visit(a, continuationPlace, scope);
    }
    std::string startPlace;
    if (a->label.empty()) {
        startPlace = getUniqueScopedPlaceNameFrom("DISP", scope);
    } else {
        startPlace = a->label + "_FROM_" + scope;
    }
    addPlace(startPlace, 0);
    std::string blockVersion = getBlockVersionNameOnSQ(a->block, a->queue);
    if (!isBlockVersionAlreadyEncoded(blockVersion)) {
        visitBlock(qdas->getBlockNamed(a->block), q);
    }
    // if the queue is already full: one token is produced in QUEUE_OVERFLOW
    Transition * trans = new Transition();
    trans->guards.push_back(startPlace);
    for (unsigned i = 0; i < queueSize; ++i) {
        trans->guards.push_back(getQueueWaitingSlotPlace(q->name, i, false));
    }
    trans->incEffects.push_back("QUEUE_OVERFLOW");
    addTransition(trans);

    // if the last waiting slot is free, take it and create the new instance of the block
    trans = new Transition();
    trans->guards.push_back(startPlace);
    trans->guards.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, true));
    trans->decEffects.push_back(startPlace);
    trans->decEffects.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, true));
    trans->incEffects.push_back(blockVersion); //start place of the block
    trans->incEffects.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, false));
    addTransition(trans);
    return startPlace;
}
Beispiel #6
0
static void DumpVisitor_visitBlockStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	visitBlock(kctx, self, Stmt_getFirstBlock(kctx, stmt));
}
Beispiel #7
0
static void DumpVisitor_visitBlockExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	emit_string("BLOCK", "", "", DUMPER(self)->indent);
	visitBlock(kctx, self, expr->block);
}