Ignore:
Timestamp:
Jul 8, 2015, 2:59:03 PM (4 years ago)
Author:
nmedfort
Message:

Partial roll back of Trie structure. Seemed to introduce the potential of generating a cycle in the AST. More analysis is needed here before mixing together multiple Advance DAG traversals.

File:
1 edited

Legend:

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

    r4611 r4650  
    88#include <pablo/codegenstate.h>
    99#include <llvm/Support/Compiler.h>
     10#include <pablo/printer_pablos.h>
     11
    1012#ifndef NDEBUG
    1113#include <queue>
     
    122124
    123125void Statement::insertBefore(Statement * const statement) {
    124     assert (statement);
    125     assert (statement != this);
    126     assert (statement->mParent);
     126    if (LLVM_UNLIKELY(statement == this)) {
     127        return;
     128    }
     129    else if (LLVM_UNLIKELY(statement == nullptr)) {
     130        throw std::runtime_error("Cannot insert before Null statement!");
     131    }
     132    else if (LLVM_UNLIKELY(statement->mParent == nullptr)) {
     133        throw std::runtime_error("Cannot insert before before statement in Null AST!");
     134    }
    127135    removeFromParent();
    128136    mParent = statement->mParent;
     
    143151
    144152void Statement::insertAfter(Statement * const statement) {
    145     assert (statement);
    146     assert (statement != this);
    147     assert (statement->mParent);
     153    if (LLVM_UNLIKELY(statement == this)) {
     154        return;
     155    }
     156    else if (LLVM_UNLIKELY(statement == nullptr)) {
     157        throw std::runtime_error("Cannot insert before Null statement!");
     158    }
     159    else if (LLVM_UNLIKELY(statement->mParent == nullptr)) {
     160        throw std::runtime_error("Cannot insert before before statement in Null AST!");
     161    }
    148162    removeFromParent();
    149163    mParent = statement->mParent;
     
    172186            mParent->mLast = mPrev;
    173187        }
    174         if (mParent->mInsertionPoint == this) {
    175             mParent->mInsertionPoint = mParent->mInsertionPoint->mPrev;
     188        if (LLVM_UNLIKELY(mParent->mInsertionPoint == this)) {
     189            mParent->mInsertionPoint = mPrev;
    176190        }
    177191        if (LLVM_LIKELY(mPrev != nullptr)) {
     
    264278#endif
    265279
    266 void StatementList::insert(Statement * const statement) {
    267     if (LLVM_UNLIKELY(mInsertionPoint == nullptr)) {
    268         statement->mNext = mFirst;
    269         if (mFirst) {
    270             assert (mFirst->mPrev == nullptr);
    271             mFirst->mPrev = statement;
    272         }
    273         mLast = (mLast == nullptr) ? statement : mLast;
    274         mInsertionPoint = mFirst = statement;
    275     }
    276     else {
    277         statement->insertAfter(mInsertionPoint);
    278         mLast = (mLast == mInsertionPoint) ? statement : mLast;
    279         assert (statement->mPrev == mInsertionPoint);
    280         mInsertionPoint = statement;
    281     }
    282 }
    283 
    284280StatementList::~StatementList() {
    285281
Note: See TracChangeset for help on using the changeset viewer.