Ejemplo n.º 1
0
 /**
  * In case no mapped channel use the given @a label, an error is sent to the logger. Thus, the channel @a sig will be not assigned.
  */
 void Hardware::setChannel(const std::string& label, TimeSequence* sig)
 {
   using vvt = std::pair<std::string, TimeSequence*>;
   auto optr = this->pimpl();
   auto it = std::find_if(optr->MappedChannels.begin(), optr->MappedChannels.end(), [&](const vvt& v){return v.first == label;});
   if (it != optr->MappedChannels.end())
   {
     auto old = it->second;
     if (old == sig)
       return;
     auto parent = this->channels();
     if (old != nullptr)
     {
       old->removeParent(parent);
       if (!old->hasParents())
         delete old;
     }
     if (sig != nullptr)
       sig->addParent(parent);
     it->second = sig;
     // this->modified(); // removeParent and addParent calls modified
   }
   else
     error("No mapped channel with the label: %s", label.c_str());
 };
Ejemplo n.º 2
0
static int shiftToSingleReduce( a_state *state, a_shift_action *saction )
{
    a_state *sub_state;
    a_sym *new_lhs;
    int made_change;

    /*
        requirements:
        (1) state (s1) must have a shift on token (t) into a state (s2)
            that only has one action and it must be a reduction by
            an unit production
            (after which state (s1) will shift into state (s3))

        action:
            change shift action for token (t) to shift into state (s3)
    */
    made_change = 0;
    for( sub_state = saction->state; (new_lhs = onlyOneReduction( sub_state )) != NULL; sub_state = saction->state ) {
        saction->state = findNewShiftState( state, new_lhs );
        removeParent( sub_state, state );
        made_change = 1;
        ++changeOccurred;
    }
    saction->units_checked = true;
    return( made_change );
}
Ejemplo n.º 3
0
    /**
     * @brief Class::addParent
     * @param typeId
     * @param section
     * @return
     */
    Parent Class::addParent(const QString &typeId, Section section)
    {
        auto parent = Parent(typeId, section);
        if (containsParent(typeId))
            removeParent(typeId);
        m_Parents.append(parent);

        return parent;
    }
Ejemplo n.º 4
0
 void Hardware::setChannel(unsigned idx, TimeSequence* sig)
 {
   auto optr = this->pimpl();
   if (idx >= optr->MappedChannels.size())
   {
     error("Index out of range. Impossible to assign the signal '%s' in the hardware '%s'.", (sig != nullptr ? sig->name().c_str() : "NULL"), this->name().c_str());
     return;
   }
   auto old = optr->MappedChannels[idx].second;
   if (old == sig)
     return;
   auto parent = this->channels();
   if (old != nullptr)
   {
     old->removeParent(parent);
     if (!old->hasParents())
       delete old;
   }
   if (sig != nullptr)
     sig->addParent(parent);
   optr->MappedChannels[idx].second = sig;
   // this->modified(); // removeParent and addParent calls modified
 };