Ignore:
Timestamp:
Jul 7, 2015, 4:11:50 PM (4 years ago)
Author:
nmedfort
Message:

Fixed Multiplexing for new While structure/logic + Potential bug fix for PabloBuilder::Create.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/expression_map.hpp

    r4641 r4646  
    1313    typedef ExpressionMap<Args...> Type;
    1414    typedef std::tuple<PabloAST::ClassTypeId, Args...> Key;
     15    friend struct ExpressionTable;
    1516
    16     inline explicit ExpressionMap(Type * predecessor) : mPredecessor(predecessor) { }
     17    explicit ExpressionMap(Type * predecessor = nullptr) : mPredecessor(predecessor) { }
    1718
    18     ExpressionMap(const Type &) = default;
     19    explicit ExpressionMap(Type && other) noexcept
     20    : mPredecessor(other.mPredecessor)
     21    , mMap(std::move(other.mMap)) {
    1922
    20     ExpressionMap(Type &&) = default;
     23    }
     24
     25    ExpressionMap & operator=(Type && other) {
     26        mPredecessor = other.mPredecessor;
     27        mMap = std::move(other.mMap);
     28        return *this;
     29    }
    2130
    2231    template <class Functor, typename... Params>
     
    7988
    8089private:
    81     Type *                      mPredecessor;
     90    const Type *                mPredecessor;
    8291    std::map<Key, PabloAST *>   mMap;
    8392};
     
    8695struct ExpressionTable {
    8796
    88     ExpressionTable() noexcept
    89     : mUnary(nullptr)
    90     , mBinary(nullptr)
    91     , mTernary(nullptr) {
     97    explicit ExpressionTable(const ExpressionTable * predecessor = nullptr) noexcept {
     98        if (predecessor) {
     99            mUnary.mPredecessor = &(predecessor->mUnary);
     100            mBinary.mPredecessor = &(predecessor->mBinary);
     101            mTernary.mPredecessor = &(predecessor->mTernary);
     102        }
     103    }
     104
     105    explicit ExpressionTable(ExpressionTable & other) = delete;
     106
     107    explicit ExpressionTable(ExpressionTable && other) noexcept
     108    : mUnary(std::move(other.mUnary))
     109    , mBinary(std::move(other.mBinary))
     110    , mTernary(std::move(other.mTernary)) {
    92111
    93112    }
    94113
    95     explicit ExpressionTable(ExpressionTable * predecessor) noexcept
    96     : mUnary(predecessor ? &(predecessor->mUnary) : nullptr)
    97     , mBinary(predecessor ? &(predecessor->mBinary) : nullptr)
    98     , mTernary(predecessor ? &(predecessor->mTernary) : nullptr) {
    99 
     114    ExpressionTable & operator=(ExpressionTable && other) {
     115        mUnary = std::move(other.mUnary);
     116        mBinary = std::move(other.mBinary);
     117        mTernary = std::move(other.mTernary);
     118        return *this;
    100119    }
    101120
    102     ExpressionTable(const ExpressionTable &) = default;
    103 
    104     ExpressionTable(ExpressionTable &&) = default;
    105121
    106122    template <class Functor, typename... Params>
Note: See TracChangeset for help on using the changeset viewer.