Пример #1
0
void KBBGraphic::slotInput()
{
    if ( !inputAccepted ) {
        return;
    }
    emit inputAt( curCol, curRow, LeftButton );
//  updateElement( curCol, curRow );
}
Пример #2
0
BB* BBTransform::clone(BB* src, Code* target, ClosureVersion* targetClosure) {
    std::vector<BB*> bbs;

    // Copy instructions and remember old -> new instruction map.
    std::unordered_map<Value*, Instruction*> relocation_table;
    Visitor::run(src, [&](BB* bb) {
        BB* theClone = BB::cloneInstrs(bb, target->nextBBId++, target);
        assert(bb->size() == theClone->size());
        if (bb->id >= bbs.size())
            bbs.resize(bb->id + 5);
        bbs[bb->id] = theClone;
        for (size_t i = 0; i < bb->size(); ++i)
            relocation_table[bb->at(i)] = theClone->at(i);
    });

    // Fixup CFG: next pointers of copied BB's need to be filled in.
    Visitor::run(src, [&](BB* bb) {
        bbs[bb->id]->next0 = bbs[bb->id]->next1 = nullptr;
        if (bb->next0)
            bbs[bb->id]->next0 = bbs[bb->next0->id];
        if (bb->next1)
            bbs[bb->id]->next1 = bbs[bb->next1->id];
    });

    std::unordered_map<Promise*, Promise*> promMap;
    // Relocate argument pointers using old -> new map
    BB* newEntry = bbs[src->id];
    Visitor::run(newEntry, [&](Instruction* i) {
        auto phi = Phi::Cast(i);
        if (phi) {
            for (size_t j = 0; j < phi->nargs(); ++j)
                phi->updateInputAt(j, bbs[phi->inputAt(j)->id]);
        }
        i->eachArg([&](InstrArg& arg) {
            if (arg.val()->isInstruction()) {
                assert(relocation_table.count(arg.val()));
                arg.val() = relocation_table.at(arg.val());
            }
        });
        if (auto mk = MkArg::Cast(i)) {
            Promise* p = mk->prom();
            if (p->owner != targetClosure) {
                if (promMap.count(p)) {
                    mk->updatePromise(promMap.at(p));
                } else {
                    auto c = targetClosure->createProm(p->srcPoolIdx());
                    c->entry = clone(p->entry, c, targetClosure);
                    mk->updatePromise(c);
                }
            }
        }
    });

    return newEntry;
}
Пример #3
0
void KBBGraphic::mouseMoveEvent( QMouseEvent* e ) {
    if (inputAccepted) {
        int oldRow = curRow;
        int oldCol = curCol;
        QPoint pos = e->pos();                 // extract pointer position
        int movRow = pos.y() / cellH;
        int movCol = pos.x() / cellW;
        // kdDebug(12009) << movRow << " " << curRow << endl;
        if ( (curRow != movRow) 			// if current cell has moved,
                || (curCol != movCol) ) {
            curRow = movRow;
            curCol = movCol;
            updateElement( oldCol, oldRow );
            emit inputAt( curCol, curRow, e->state() );
        }
    }
}
Пример #4
0
/*
   Handles mouse press events for the KBBGraphic widget.
*/
void KBBGraphic::mousePressEvent( QMouseEvent* e )
{
    if (inputAccepted) {
        /*
         * Middle click finishes the game.
         */
        if (e->button() == MidButton) {
            emit endMouseClicked();
            return;
        }
        int oldRow = curRow;
        int oldCol = curCol;
        QPoint pos = e->pos();		// extract pointer position
        curRow = pos.y() / cellH;
        curCol = pos.x() / cellW;
        //kdDebug(12009) << e->state() << " " << LeftButton << " " << e->state()&LeftButton << endl;
        updateElement( oldCol, oldRow );
        emit inputAt( curCol, curRow, e->button() );
    }
}
Пример #5
0
BB* BBTransform::split(size_t next_id, BB* src, BB::Instrs::iterator it,
                       Code* target) {
    BB* split = new BB(target, next_id);
    split->next0 = src->next0;
    split->next1 = src->next1;
    while (it != src->end()) {
        it = src->moveToEnd(it, split);
    }
    src->next0 = split;
    src->next1 = nullptr;
    Visitor::run(split, [&](Instruction* i) {
        auto phi = Phi::Cast(i);
        if (phi) {
            for (size_t j = 0; j < phi->nargs(); ++j)
                if (phi->inputAt(j) == src)
                    phi->updateInputAt(j, split);
        }
    });
    return split;
}
Пример #6
0
void KBBGraphic::keyPressEvent( QKeyEvent* e )
{
  if (inputAccepted) {
    int oldRow = curRow;
    int oldCol = curCol;
    switch( e->key() ) {	       	// Look at the key code
    case Key_Left:		       	// If 'left arrow'-key, 
      if( curCol > 0 ) {	       	// and cr't not in leftmost col
	curCol--;     			// set cr't to next left column
      }
      break;
    case Key_Right:		       	// Correspondingly...
      if( curCol < numCols-1 ) {
	curCol++;
      }
      break;
    case Key_Up:
      if( curRow > 0 ) {
	curRow--;
      } 
      break;
    case Key_Down:
      if( curRow < numRows-1 ) {
	curRow++;
      }
      break;
    case Key_Return:
    case Key_Enter:
      emit inputAt( curCol, curRow, LeftButton ); 
      break;
    default:				// If not an interesting key,
      e->ignore();			// we don't accept the event
      return;	
    }
    updateElement( oldCol, oldRow );
    updateElement( curCol, curRow );
  }
}
Пример #7
0
	Evaluatable * Action::inputVal() const
	{
		return element_cast<Evaluatable>(inputAt(InputPosition()));
	}