Exemple #1
0
void KateBuffer::insertLine(uint i, KateTextLine::Ptr line)
{
  uint index = 0;
  KateBufBlock *buf;
  if (i == m_lines)
    buf = findBlock(i-1, &index);
  else
    buf = findBlock(i, &index);

  if (!buf)
    return;

  buf->insertLine(i -  buf->startLine(), line);

  if (m_lineHighlightedMax > i)
    m_lineHighlightedMax++;

  if (m_lineHighlighted > i)
    m_lineHighlighted++;

  m_lines++;

  // last sync block adjust
  if (m_lastInSyncBlock > index)
    m_lastInSyncBlock = index;

  // last found
  if (m_lastInSyncBlock < m_lastFoundBlock)
    m_lastFoundBlock = m_lastInSyncBlock;

  // mark buffer changed
  editChangesDone = true;

  // tag this line as inserted
  if (i < editTagLineStart)
    editTagLineStart = i;

  if (i <= editTagLineEnd)
    editTagLineEnd++;

  if (i > editTagLineEnd)
    editTagLineEnd = i;

  // line inserted
  editTagLineFrom = true;

  m_regionTree.lineHasBeenInserted (i);
}
Exemple #2
0
void MemoryManager<AllocatorType>::deallocate(Byte* address)
{
	if(address == nullptr)
		return;

	// Find the block corresponding to the address
	size_t index{0};
	typename BlockList::iterator it;
	while(index < _addressSize)
	{
		it = findBlock(_allocatedBlocks[index], address, index);
		if(it != _allocatedBlocks[index].end())
			break;
		index++;
	}

	if(it != _allocatedBlocks[index].end())
	{
		// Add the freed block to the free list
		_allocatedBlocks[index].erase(it);
		_freeBlocks[index].pushFront(address);
		tryMerge(_freeBlocks[index].begin(), index);
	}
	else
		out << "Error: MemoryMamanger::deallocate: invalid pointer argument (" << address << ")\n";
	if(_activateMemoryDump)
		memoryDump();
}
Exemple #3
0
void MemoryManager<AllocatorType>::tryMerge(typename BlockList::iterator blockToMergeIt, size_t index)
{
	const size_t blockSize{1UL << index};
	for(typename BlockList::iterator it{_freeBlocks[index].begin()}; it != _freeBlocks[index].end(); ++it)
	{
		// If we found a block...
		if(it != blockToMergeIt
			// that is adjacent to the block to merge...
			and static_cast<size_t>(abs(*it - *blockToMergeIt)) == blockSize
			// and that has a size corresponding to index
			and findBlock(_freeBlocks[index], *it, index) != _freeBlocks[index].end())

		{
			typename BlockList::iterator lowerBlockIt{*it < *blockToMergeIt ? it : blockToMergeIt};
			typename BlockList::iterator upperBlockIt{lowerBlockIt == blockToMergeIt ? it : blockToMergeIt};
			Byte* baseAddress{*lowerBlockIt};
			_freeBlocks[index].erase(lowerBlockIt);
			_freeBlocks[index].erase(upperBlockIt);
			_freeBlocks[index + 1].pushFront(baseAddress);
			// Recursively merge bigger blocks
			tryMerge(_freeBlocks[index + 1].begin(), index + 1);
			break;
		}
	}
}
Exemple #4
0
size_t BufferArray::read(size_t pos, void * dst, size_t len)
{
	char * c_dst(static_cast<char *>(dst));
	
	if (pos >= mLen)
		return 0;
	size_t len_limit(mLen - pos);
	len = (std::min)(len, len_limit);
	if (0 == len)
		return 0;
	
	size_t result(0), offset(0);
	const int block_limit(mBlocks.size());
	int block_start(findBlock(pos, &offset));
	if (block_start < 0)
		return 0;

	do
	{
		Block & block(*mBlocks[block_start]);
		size_t block_limit(block.mUsed - offset);
		size_t block_len((std::min)(block_limit, len));
		
		memcpy(c_dst, &block.mData[offset], block_len);
		result += block_len;
		len -= block_len;
		c_dst += block_len;
		offset = 0;
		++block_start;
	}
	while (len && block_start < block_limit);

	return result;
}
Exemple #5
0
size_t BufferArray::write(size_t pos, const void * src, size_t len)
{
	const char * c_src(static_cast<const char *>(src));
	
	if (pos > mLen || 0 == len)
		return 0;
	
	size_t result(0), offset(0);
	const int block_limit(mBlocks.size());
	int block_start(findBlock(pos, &offset));

	if (block_start >= 0)
	{
		// Some or all of the write will be on top of
		// existing data.
		do
		{
			Block & block(*mBlocks[block_start]);
			size_t block_limit(block.mUsed - offset);
			size_t block_len((std::min)(block_limit, len));
		
			memcpy(&block.mData[offset], c_src, block_len);
			result += block_len;
			c_src += block_len;
			len -= block_len;
			offset = 0;
			++block_start;
		}
		while (len && block_start < block_limit);
	}

	// Something left, see if it will fit in the free
	// space of the last block.
	if (len && ! mBlocks.empty())
	{
		Block & last(*mBlocks.back());
		if (last.mUsed < last.mAlloced)
		{
			// Some will fit...
			const size_t copy_len((std::min)(len, (last.mAlloced - last.mUsed)));

			memcpy(&last.mData[last.mUsed], c_src, copy_len);
			last.mUsed += copy_len;
			result += copy_len;
			llassert_always(last.mUsed <= last.mAlloced);
			mLen += copy_len;
			c_src += copy_len;
			len -= copy_len;
		}
	}
	
	if (len)
	{
		// Some or all of the remaining write data will
		// be an append.
		result += append(c_src, len);
	}

	return result;
}
Exemple #6
0
// Insert spills and copies that connect sub-intervals that were split
// between instructions. Do not assume SSA; insert a spill-store
// after every def, ignoring the interval's full live range.
void Vxls::resolveSplits() {
  if (dumpIREnabled(kRegAllocLevel)) dumpIntervals();
  for (auto i1 : intervals) {
    if (!i1) continue;
    auto slot = i1->slot;
    if (slot >= 0) insertSpill(i1);
    for (auto i2 = i1->next; i2; i1 = i2, i2 = i2->next) {
      if (slot >= 0) insertSpill(i2);
      auto pos = i2->start();
      if (i1->end() != pos) continue; // spans lifetime hole
      if (i2->reg == InvalidReg) continue; // no load necessary
      if (i2->reg == i1->reg) continue; // no copy necessary
      auto b = findBlock(pos);
      auto range = block_ranges[b];
      if (pos % 2 == 0) {
        // even position requiring a copy must be on edge
        assert(range.start == pos);
      } else {
        // odd position
        assert(pos > range.start); // implicit label position per block
        if (pos + 1 == range.end) continue; // copy belongs on successor edge
        if (i2->reg != i1->reg) {
          copies[pos][i2->reg] = i1;
        }
      }
    }
  }
}
Exemple #7
0
void KateBuffer::updatePreviousNotEmptyLine(KateBufBlock *blk,uint current_line,bool addindent,uint deindent)
{
  KateTextLine::Ptr textLine;
  do {
    if (current_line>0) current_line--;
    else
    {
      uint line=blk->startLine()+current_line;
      if (line==0) return;
      line--;
      blk=findBlock(line);
      if (!blk) {
        kdDebug(13020)<<"updatePreviousNotEmptyLine: block not found, this must not happen"<<endl;
        return;
      }
      current_line=line-blk->startLine();
    }
    textLine = blk->line(current_line);
  } while (textLine->firstChar()==-1);
  kdDebug(13020)<<"updatePreviousNotEmptyLine: updating line:"<<(blk->startLine()+current_line)<<endl;
  TQMemArray<uint> foldingList=textLine->foldingListArray();
  while ( (foldingList.size()>0)  && ( abs(foldingList[foldingList.size()-2])==1)) {
    foldingList.resize(foldingList.size()-2,TQGArray::SpeedOptim);
  }
  addIndentBasedFoldingInformation(foldingList,addindent,deindent);
  textLine->setFoldingList(foldingList);
  bool retVal_folding = false;
  m_regionTree.updateLine (current_line + blk->startLine(), &foldingList, &retVal_folding, true,false);
  emit tagLines (blk->startLine()+current_line, blk->startLine()+current_line);
}
Exemple #8
0
void Solve::findBlock(int u, int f)
{
	vis[u] = true;
	stack[top ++] = u;
	dfn[u] = low[u] = idx ++;
	for(Edge *e = begin[u]; e; e = e->next)
	{
		int v = e->vtx;
		if(! vis[v])
		{
			findBlock(v, u);
			if(dfn[u] <= low[v])
			{
				int tmp;
				do
				{
					tmp = stack[-- top];
					belong[tmp][nBCC] = true;
				}
				while(tmp != v);
				belong[u][nBCC ++] = true;
			}
			low[u] = MIN(low[u], low[v]);
		}
		else if(v != f)
			low[u] = MIN(low[u], dfn[v]);
	}
}
vector<int> BufferManager::getTableBlocks(string tableName) {
	//转换tableName为char[]
	hash_map<string, int>::iterator i;
	int offset;

	//从firstBlock中查找tableName的第一块地址
	for( i = firstBlock.begin(); i != firstBlock.end(); i ++ ) {
		if( tableName == i->first ) {
			offset = i->second;
			break;
		}
	}

	if( i == firstBlock.end() ) {
		return vector<int>();
		// TODO 未找到错误
	}

	//建立vector,查找各块中不是index的块
	vector<int> result;

	do {
		Block &block = findBlock(offset);
		if( block.isAlive ) {
			result.push_back(offset);
		}
		offset = block.nextOffset;
	} while(offset != 0);
	
	return result;
}
template<> void
QConsoleWidget::_pf<void, UpdateAfterEditorBlockFormat>(
        QConsoleWidget * thisp
        ) {
    //TODO: UpdateAfterEditorBlockFormat
    auto doc_ = thisp->document();
    auto block_ = doc_->findBlock(thisp->promptEndPos_);
    block_ = block_.next();
    while (block_.isValid()){
        {
            QTextCursor cursor_(block_);
            cursor_.setPosition(block_.position());
            cursor_.select(QTextCursor::BlockUnderCursor);
            cursor_.mergeCharFormat(thisp->thisp->textCharFormat);
            thisp->setTextCursor(cursor_);
        }
        {
            QTextCursor cursor_(block_);
            auto bf_ = block_.blockFormat();
            bf_.setTextIndent(0);
            cursor_.setBlockFormat(bf_);
            thisp->setTextCursor(cursor_);
            block_ = block_.next();
        }
    }

}
Exemple #11
0
 named_prop_t *model_reader::findProp(const std::string &b, const std::string &e, const std::string &p) const {
   block_t *block = findBlock(b);
   if (!block) return NULL;
   named_element_t *elem = block->findElem(e);
   if (!elem) return NULL;
   return elem->findProp(p);
 }
Exemple #12
0
void makeFlowGraph()
{
    int a,s,t,n;
    char *b,*res,*tokens;;
    for(a=0;a<j;a++)
    {
        graph[a][a+1]=1;

        s=blocks[a][0];
        t=blocks[a][s];
        s=findLastLine(t);
        b=l[s];

        res=strstr(b,"goto");
        if(res!=NULL)
        {
            tokens=strtok(res," ");
            while(tokens!=NULL)
            {
                if(n>0)
                {
                    t=findBlock(atoi(tokens));
                    graph[a][t]=1;
                }
                n++;
                tokens=strtok(NULL," ");
            }
        }
    }
    printFlowGraph();
}
Exemple #13
0
// static
int BibTeXFile::readEntry(Entry & e, const QByteArray & content, int curPos, const QTextCodec * codec)
{
	QList<QString> delims;
	curPos = content.indexOf('@', curPos);
	if (curPos < 0)
		return -1;
	++curPos;
	int start = content.indexOf('{', curPos);
	if (start < 0)
		return -1;
	e._type = codec->toUnicode(content.mid(curPos, start - curPos));

	int end = findBlock(content, start);
	if (end < 0) return -1;
	++start;
	QByteArray block = content.mid(start, end - start);

	switch (e.type()) {
	case Entry::COMMENT:
		e._key = codec->toUnicode(block);
		break;
	case Entry::PREAMBLE:
		e._key = codec->toUnicode(block);
		break;
	case Entry::STRING:
		// FIXME
		e._key = codec->toUnicode(block);
		break;
	case Entry::NORMAL:
		parseEntry(e, codec->toUnicode(block));
		break;
	}

	return end + 1;
}
Exemple #14
0
 block_t &model_reader::findOrCreateBlock(const std::string &n) {
   block_t *b = findBlock(n);
   if (b == NULL) {
     blocks.push_back(block_t(n));
     b = &blocks.back();
   }
   return *b;
 }
QString TextDocument::tooltip(const QPoint& point) const
{
    const int pos = documentLayout()->hitTest(point, Qt::FuzzyHit);
    const QTextBlock block = findBlock(pos);
    TextBlockMessageData* blockData = static_cast<TextBlockMessageData*>(block.userData());
    if (blockData)
        return formatEvents(blockData->data.getEvents());
    return QString();
}
void CfgFile::removeBlock(const std::string &sBlock)
{
    if (findBlock(sBlock) != 0)
        throw std::invalid_argument("The Block " + sBlock + " was not found in the config file " + sFilename);

    std::ofstream f;
    copyFirstPart(f, cfgfile.tellg());
    findKey("");
    copySecondPart(f, cfgfile.tellg());
}
Exemple #17
0
//Emulation heap malloc function
unsigned int EmuHeap::malloc(unsigned int size) {
   size = (size + 3) & 0xFFFFFFFC;  //round up to word boundary
   //find a gap that we can fit in
   unsigned int addr = findBlock(size);
   if (addr != HEAP_ERROR) {
      //create and insert a new malloc node into the allocation list
      insert(new MallocNode(size, addr));
   }
   return addr;
}
Block& BufferManager::newBlock(string tableName) {
	//转换tableName为char[]
	const char *tableChar = tableName.c_str();
	hash_map<string, int>::iterator i;

	//新建空Block,table为tableName, offset为db文件末尾,并直接写到文件末尾
	Block block;
	memcpy(block.tableName, tableChar, MAX_TABLE_NAME);
	dbFile.seekp(0, ios_base::end);
	block.offset = dbFile.tellp();
	writeBlock(block);
	
	//从firstBlock中查找tableName的第一块地址
	for( i = firstBlock.begin(); i != firstBlock.end(); i ++ ) {
		if( tableName == i->first ) {
			break;
		}
	}
	if( i == firstBlock.end() ) {
		// 没找到,添加一条
		firstBlock.insert(pair<string, int>(block.tableName, block.offset));
	}

	//查找LastOffset,读最后一块,设置它的nextoffset为新块的offset,设置dirty
	for( i = lastBlock.begin(); i != lastBlock.end(); i ++ ) {
		if( tableName == i->first ) {
			break;
		}
	}
	if( i == lastBlock.end() ) {
		// 没找到,添加一条
		lastBlock.insert(pair<string, int>(block.tableName, block.offset));
	} else {
		Block& temp = findBlock(i->second);
		temp.nextOffset = block.offset;
		temp.dirty();
		writeBlock(temp);
	}
	/*- - -*/
	int offset = block.offset;
	return findBlock(offset);
}
Exemple #19
0
uint ControlFlowAnalysis::findFunctionStart(BasicBlock* block, ControlFlowAnalysis::UintSet* parents)
{
    if(!block)
        return 0;
    if(block->function)
        return block->function;
    BasicBlock* left = findBlock(block->left);
    if(left && left->function)
        return left->function;
    BasicBlock* right = findBlock(block->right);
    if(right && right->function)
        return right->function;
    for(auto start : *parents)
    {
        BasicBlock* parent = findBlock(start);
        if(parent->function)
            return parent->function;
    }
    return 0;
}
Exemple #20
0
Chunk::~Chunk()
{
    logger.info() << "Unloading chunk" << *this;

    unsigned int index = 0;
    BlockCoord chunk_x, chunk_y, chunk_z;

    while (index < CHUNK_INDEX_MAX)
    {
        Chunk::getBlockPositionByIndex(index, &chunk_x, &chunk_y, &chunk_z);

        if (chunk_x > 0 && chunk_x < CHUNK_SIZE_XZ - 1 && chunk_z > 0 && chunk_z < CHUNK_SIZE_XZ - 1)
        {
            index++;
            continue;
        }

        BlockInWorld block_pos(*this, chunk_x, chunk_y, chunk_z);
        Chunk *temp_chunk;
        unsigned int temp_index;
        if (findBlock(block_pos.getSide(RIGHT), temp_chunk, temp_index)) temp_chunk->hideTile(temp_index, LEFT);
        if (findBlock(block_pos.getSide(LEFT), temp_chunk, temp_index)) temp_chunk->hideTile(temp_index, RIGHT);
        if (findBlock(block_pos.getSide(BACK), temp_chunk, temp_index)) temp_chunk->hideTile(temp_index, FRONT);
        if (findBlock(block_pos.getSide(FRONT), temp_chunk, temp_index)) temp_chunk->hideTile(temp_index, BACK);
        index++;
    }

    if (m_NeedSave)
    {
        save();
    }

    delete[] m_pBlocks;
    delete[] m_SkyLight;
    delete[] m_TorchLight;

    delete[] m_pDisplayedTiles;
    delete[] m_pDisplayedWaterTiles;

    glDeleteLists(m_RenderList, 2);
}
void CfgFile::addBlock(const std::string &sBlock, const blockMap &block)
{
    if (findBlock(sBlock) == 0)
    {
        std::ofstream f;
        copyFirstPart(f, cfgfile.tellg());
        for (auto item : block)
        {
            std::string sValue = item.second;

            if (sValue.find_first_of("\n\r") != std::string::npos)
                throw std::invalid_argument("I can't write a string containing a 'new line' to the config file!");

            escapeString(sValue, "\"#", '\\');
            if (sValue.find_first_of(" \t") != std::string::npos)
                sValue = "\"" + sValue + "\"";

            f << '\t' << item.first << " = " << sValue << "\n";
        }
        findKey("");
        copySecondPart(f, cfgfile.tellg());
    }
    else
    {
        cfgfile.seekg(biggestBlockPosition);

        if (findKey("") != 2)
            throw std::logic_error(
                    "unhandled return value of findKey(). Or something is very wrong with your cfg file.");

        // now we are at eof, but empty lines or comments at the end of the file do not matter
        cfgfile.unget();
        if (cfgfile.get() != '\n')
            cfgfile << '\n';
        cfgfile.clear();

        cfgfile << "\n[" << sBlock << "]\n";
        for (auto item : block)
        {
            std::string sValue = item.second;

            if (sValue.find_first_of("\n\r") != std::string::npos)
                throw std::invalid_argument("I can't write a string containing a 'new line' to the config file!");

            escapeString(sValue, "\"#", '\\');
            if (sValue.find_first_of(" \t") != std::string::npos)
                sValue = "\"" + sValue + "\"";

            cfgfile << '\t' << item.first << " = " << sValue << "\n";
        }
        cfgfile.flush();
    }
}
void insertLine(DissassemblyData* data, uint64_t address, const char* text) {
    Block* block = 0;

    // first find the block which this address should be in

    uint64_t blockId = address / BlockSize;

    if (!(block = findBlock(data, blockId)))
        block = createBlock(data, address, blockId);

    insertLineBlock(block, address, text);
}
Exemple #23
0
bool Chunk::unplaceBlock(const BlockInChunk &pos)
{
    unsigned int index = getIndexByPosition(pos);
    if (index >= CHUNK_INDEX_MAX)
    {
        return false;
    }
    Chunk *temp_chunk = nullptr;
    unsigned int temp_index;
    Block *p_block = m_pBlocks + index;
    BlockInWorld wpos(*this, pos);

    if (!findBlock(wpos.getSide(TOP), temp_chunk, temp_index)|| m_pBlocks[index].material == MAT_WATER) hideTile(p_block, TOP);
    else { temp_chunk->showTile(temp_index, BOTTOM); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, TOP); }
    if (!findBlock(wpos.getSide(BOTTOM), temp_chunk, temp_index)) hideTile(p_block, BOTTOM);
    else { temp_chunk->showTile(temp_index, TOP); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, BOTTOM); }
    if (!findBlock(wpos.getSide(RIGHT), temp_chunk, temp_index)) hideTile(p_block, RIGHT);
    else { temp_chunk->showTile(temp_index, LEFT); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, RIGHT); }
    if (!findBlock(wpos.getSide(LEFT), temp_chunk, temp_index)) hideTile(p_block, LEFT);
    else { temp_chunk->showTile(temp_index, RIGHT); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, LEFT); }
    if (!findBlock(wpos.getSide(BACK), temp_chunk, temp_index)) hideTile(p_block, BACK);
    else { temp_chunk->showTile(temp_index, FRONT); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, BACK); }
    if (!findBlock(wpos.getSide(FRONT), temp_chunk, temp_index)) hideTile(p_block, FRONT);
    else { temp_chunk->showTile(temp_index, BACK); if (temp_chunk->m_pBlocks[temp_index].material == MAT_WATER) hideTile(p_block, FRONT); }

    removeBlock(wpos.bx, wpos.by, wpos.bz);

    m_NeedToRender[0] = RENDER_NEED;
    m_NeedToRender[1] = RENDER_NEED;

    return true;
}
Exemple #24
0
//static
void BibTeXFile::parseEntry(Entry & e, const QString & block)
{
	int pos = block.indexOf(QChar::fromLatin1(','));
	e._key = block.mid(0, pos).trimmed();
	if (pos == -1) return;

	int i;
	QChar startDelim, endDelim;

	do {
		int start = pos + 1;
		pos = block.indexOf(QChar::fromLatin1('='), start);
		if (pos < 0) break;
		QString key = block.mid(start, pos - start).trimmed();
		QString val;

		start = -1;

		// Skip initial whitespace
		for (i = pos + 1; i < block.size() && start < 0; ++i) {
			if (!block[i].isSpace()) start = i;
		}

		for (i = start; i < block.size(); ++i) {
			if (block[i] == QChar::fromLatin1(',')) break;
			else if (block[i] == QChar::fromLatin1('{')) {
				startDelim = QChar::fromLatin1('{');
				endDelim = QChar::fromLatin1('}');
			}
			else if (block[i] == QChar::fromLatin1('"')) {
				startDelim = QChar::fromLatin1('"');
				endDelim = QChar::fromLatin1('"');
			}
			else {
				val += block[i];
				continue;
			}

			int end = findBlock(block, i, startDelim, endDelim);
			if (end < 0) {
				val += block.mid(i);
				i = block.size();
			}
			else {
				val += block.mid(i, end - i + 1);
				i = end;
			}
		}
		e._fields[key] = val.trimmed();
		pos = i;
	} while (pos >= 0 && pos + 1 < block.size());
}
void CfgFile::removeKey(const std::string &sBlock, const std::string &sKey)
{
    if (findBlock(sBlock) != 0)
        throw std::invalid_argument("The Block " + sBlock + " was not found in the config file " + sFilename);
    if (findKey(sKey) != 0)
        throw std::invalid_argument(
                "The Key " + sKey + " in Block " + sBlock + " was not found in the config file " + sFilename);

    std::ofstream f;
    copyFirstPart(f, cfgfile.tellg());
    cfgfile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    copySecondPart(f, cfgfile.tellg());
}
Exemple #26
0
void KateBuffer::editEnd ()
{
  if (editSessionNumber == 0)
    return;

  editSessionNumber--;

  if (editSessionNumber > 0)
    return;

  if (editChangesDone)
  {
    // hl update !!!
    if ( m_highlight && !m_highlight->noHighlighting()
        && (editTagLineStart <= editTagLineEnd)
        && (editTagLineEnd <= m_lineHighlighted))
    {
      // look one line too far, needed for linecontinue stuff
      editTagLineEnd++;

      // look one line before, needed nearly 100% only for indentation based folding !
      if (editTagLineStart > 0)
        editTagLineStart--;

      KateBufBlock *buf2 = 0;
      bool needContinue = false;
      while ((buf2 = findBlock(editTagLineStart)))
      {
        needContinue = doHighlight (buf2,
          (editTagLineStart > buf2->startLine()) ? editTagLineStart : buf2->startLine(),
          (editTagLineEnd > buf2->endLine()) ? buf2->endLine() : editTagLineEnd,
          true);

        editTagLineStart = (editTagLineEnd > buf2->endLine()) ? buf2->endLine() : editTagLineEnd;

        if ((editTagLineStart >= m_lines) || (editTagLineStart >= editTagLineEnd))
          break;
      }

      if (needContinue)
        m_lineHighlighted = editTagLineStart;

      if (editTagLineStart > m_lineHighlightedMax)
        m_lineHighlightedMax = editTagLineStart;
    }
    else if (editTagLineStart < m_lineHighlightedMax)
      m_lineHighlightedMax = editTagLineStart;
  }

  editIsRunning = false;
}
void QConsoleWidget::endEvals() {
	/* 
	当此函栈反解的时候eval才结束
	提前结束eval会出现逻辑错误
	*/
	class EndEvalsLock__ {
		QConsoleWidget * __this_0_;
	public:
		EndEvalsLock__(QConsoleWidget * _t_):
			__this_0_(_t_){
			__this_0_->isEvaling_ = true;
		}
		~EndEvalsLock__() {
			__this_0_->isEvaling_ = false;
		}
	};
	EndEvalsLock__ __lock__this__(this);

	bool need_update_charFormate__ = false;
    do{//: get all command information here
        auto doc_ = this->document();
        doc_->clearUndoRedoStacks();
        auto block_ = doc_->findBlock( this->promptEndPos_);
		
		/*
		当clear and save 时调用
		*/
		if (block_.isValid() == false) { 
			need_update_charFormate__ = true;
			break; 
		}
		
		{
			QTextCursor tc_( block_ );
			auto bf_ = block_.blockFormat();
			bf_.setTextIndent(0);
			tc_.setBlockFormat( bf_ );
			this->setTextCursor(tc_);
		}

	} while (0);

    setPrompt( getPrompt() );
    this->setUndoRedoEnabled(true);
	_pf<void, EnableActions>(this);

	if ( need_update_charFormate__ ) {
		this->updateCharFormat();
	}
}
int TestAppBlockBuilder::changeBlock( Uint8 ix, Uint8 iy, Uint8 iz, Uint8 orientation, Uint16 shape ){
    int i = findBlock ( ix, iy, iz );
    if( i < 0 ){
        if( nBlocks >= nMaxBlocks ) return -1;
        i=nBlocks;
        nBlocks++;
        blocks[i].ix = ix;
        blocks[i].iy = iy;
        blocks[i].iz = iz;
    };
    blocks[i].orientation = orientation;
    blocks[i].shape = shape;
    return i;
};
void Motogame::onReadAvailable()
{
    while (true)
    {
        QByteArray Msg = m_Motogame.readLine();
        if (Msg.size() == 0)
            break;

        MotoWork Work;
        MotoPoW PoW;
        if (motoParseMessage(Msg.data(), Work))
        {
            auto iter = findBlock(Work);
            if (iter != m_Templates.end())
                m_Templates.erase(iter);
        }
        else if (motoParseMessage(Msg.data(), Work, PoW))
        {
            auto iter = findBlock(Work);
            if (iter != m_Templates.end())
            {
                CBlock *pBlock = &(*iter)->block;
                pBlock->Nonce = PoW;
                CheckWork(pBlock, *m_pWallet, m_ReserveKey);
            }
            updateBlock();
        }
        else if (strncmp(Msg.data(), "***Config:*", 11) == 0)
        {
            QString Controls(Msg.data() + 11);
            Controls.remove("\n");
            QSettings settings;
            settings.setValue("GameControls", Controls);
        }
    }
}
Exemple #30
0
// Insert a spill after every def-position in ivl.
void Vxls::insertSpill(Interval* ivl) {
  auto DEBUG_ONLY checkPos = [&](unsigned pos) {
    assert(pos % 2 == 1);
    DEBUG_ONLY auto b = findBlock(pos);
    DEBUG_ONLY auto range = block_ranges[b];
    assert(pos - 1 > range.start);
    assert(pos + 1 < range.end);
    return true;
  };
  for (auto& u : ivl->uses) {
    if (!u.def) continue;
    auto pos = u.pos + 1;
    assert(checkPos(pos));
    spills[pos][ivl->reg] = ivl; // store ivl->reg => ivl->slot
  }
}