コード例 #1
0
ファイル: Operators.cpp プロジェクト: Sumith1896/precimonious
bool Operators::runOnModule(Module &module) {

	doInitialization(module);

	// iterate through operator set
	
	vector<Change*>::iterator it;
	for (it = changes[OP].begin(); it != changes[OP].end(); it++) {
		Change *change = *it;
		Value *target = change->getValue();
		Type *new_type = change->getType().at(0);

		if (target) {
			if (FCmpInst* old_target = dyn_cast<FCmpInst>(target)) {
				changeFCmpInst(old_target, new_type);
			} else if (BinaryOperator* old_target = dyn_cast<BinaryOperator>(target)) {
				changeBinaryOperator(old_target, new_type);
			}
		}
	}

	return true;
}
コード例 #2
0
void OsmApiDbSqlChangesetFileWriter::write(const QString path,
                                           ChangesetProviderPtr changesetProvider)
{
  LOG_DEBUG("Writing changeset to " << path);

  LOG_VARD(path);
  LOG_VARD(changesetProvider->hasMoreChanges());

  _changesetBounds.init();

  _outputSql.setFileName(path);
  if (_outputSql.open(QIODevice::WriteOnly | QIODevice::Text) == false)
  {
    throw HootException(QObject::tr("Error opening %1 for writing").arg(path));
  }

  int changes = 0;
  _createChangeSet();

  while (changesetProvider->hasMoreChanges())
  {
    LOG_TRACE("Reading next SQL change...");
    Change change = changesetProvider->readNextChange();
    switch (change.getType())
    {
      case Change::Create:
        _createNewElement(change.getElement());
        break;
      case Change::Modify:
        _updateExistingElement(change.getElement());
        break;
      case Change::Delete:
        _deleteExistingElement(change.getElement());
        break;
      case Change::Unknown:
        //see comment in ChangesetDeriver::_nextChange() when
        //_fromE->getElementId() < _toE->getElementId() as to why we do a no-op here.
        break;
      default:
        throw IllegalArgumentException("Unexpected change type.");
    }

    if (change.getType() != Change::Unknown)
    {
      if (change.getElement()->getElementType().getEnum() == ElementType::Node)
      {
        ConstNodePtr node = boost::dynamic_pointer_cast<const Node>(change.getElement());
        _changesetBounds.expandToInclude(node->getX(), node->getY());
      }
      changes++;
    }

    if (changes > _changesetMaxSize)
    {
      _updateChangeset(changes);
      _createChangeSet();
      changes = 0;
    }
  }

  _updateChangeset(changes);

  _outputSql.close();
}