Ignore:
Timestamp:
Nov 14, 2015, 5:38:36 PM (4 years ago)
Author:
nmedfort
Message:

Bug fix for Multiplexing. Added ability to set the body of a If/While? node after creation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r4868 r4870  
    66
    77#include <pablo/codegenstate.h>
     8#include <iostream>
     9#include <pablo/printer_pablos.h>
    810
    911namespace pablo {
     
    482484}
    483485
    484 If * PabloBlock::createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock & body) {
     486If * PabloBlock::createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock * body) {
    485487    assert (condition);
    486488    return insertAtInsertionPoint(new If(condition, definedVars, body));
    487489}
    488490
    489 If * PabloBlock::createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body) {
     491If * PabloBlock::createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock * body) {
    490492    assert (condition);
    491493    return insertAtInsertionPoint(new If(condition, definedVars, body));
    492494}
    493495
    494 If * PabloBlock::createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
     496If * PabloBlock::createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock * body) {
    495497    assert (condition);
    496498    return insertAtInsertionPoint(new If(condition, definedVars, body));
    497499}
    498500
    499 While * PabloBlock::createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock & body) {
     501While * PabloBlock::createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock * body) {
    500502    assert (condition);
    501503    return insertAtInsertionPoint(new While(condition, nextVars, body));
    502504}
    503505
    504 While * PabloBlock::createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock & body) {
     506While * PabloBlock::createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock * body) {
    505507    assert (condition);
    506508    return insertAtInsertionPoint(new While(condition, nextVars, body));
    507509}
    508510
    509 While * PabloBlock::createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock & body) {
     511While * PabloBlock::createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock * body) {
    510512    assert (condition);
    511513    return insertAtInsertionPoint(new While(condition, nextVars, body));
    512514}
     515
     516/** ------------------------------------------------------------------------------------------------------------- *
     517 * @brief eraseFromParent
     518 ** ------------------------------------------------------------------------------------------------------------- */
     519void PabloBlock::eraseFromParent(const bool recursively) {
     520    Statement * stmt = front();
     521    // Note: by erasing the scope block, any Assign/Next nodes will be replaced with Zero and removed from
     522    // the If/While node
     523    while (stmt) {
     524        stmt = stmt->eraseFromParent(recursively);
     525    }
     526    mAllocator.deallocate(reinterpret_cast<Allocator::pointer>(this));
     527}
     528
    513529
    514530// Assign sequential scope indexes, returning the next unassigned index   
     
    519535    for (Statement * stmt : *this) {
    520536        if (If * ifStatement = dyn_cast<If>(stmt)) {
    521             nextScopeIndex = ifStatement->getBody().enumerateScopes(nextScopeIndex);
     537            nextScopeIndex = ifStatement->getBody()->enumerateScopes(nextScopeIndex);
    522538        }
    523539        else if (While * whileStatement = dyn_cast<While>(stmt)) {
    524             nextScopeIndex = whileStatement->getBody().enumerateScopes(nextScopeIndex);
     540            nextScopeIndex = whileStatement->getBody()->enumerateScopes(nextScopeIndex);
    525541        }
    526542    }
     
    530546/// CONSTRUCTOR
    531547
    532 PabloBlock::PabloBlock(SymbolGenerator * symbolGenerator)
     548PabloBlock::PabloBlock(SymbolGenerator * symbolGenerator) noexcept
    533549: PabloAST(PabloAST::ClassTypeId::Block)
    534550, mSymbolGenerator(symbolGenerator)
     
    539555}
    540556
    541 PabloBlock::PabloBlock(PabloBlock * predecessor)
    542 : PabloAST(PabloAST::ClassTypeId::Block)
    543 , mSymbolGenerator(predecessor->mSymbolGenerator)
    544 , mParent(predecessor)
    545 , mScopeIndex(0)
    546 {
    547 
    548 }
    549 
    550557PabloBlock::~PabloBlock() {
    551558
Note: See TracChangeset for help on using the changeset viewer.