예제 #1
0
size_t ScobsStream::write(uint8_t b)
{
	if(b == 0)
	{
		finishBlock(true);
	}
	else
	{
		buffer[buffered++] = b;
		if(buffered == BUF_SIZE)
			finishBlock(false);
	}
	return 1;
}
예제 #2
0
// Try to add transaction to the block peer is providing.
// Returns true if tx belonged to block
bool ThinBlockManager::addTx(const uint256& block, const CTransaction& tx) {
    ThinBlockBuilder& b = builders[block].builder;

    if (!b.isValid())
        return false;

    ThinBlockBuilder::TXAddRes res = b.addTransaction(tx);

    if (res == ThinBlockBuilder::TX_UNWANTED) {
        LogPrint("thin", "tx %s does not belong to block %s\n",
                tx.GetHash().ToString(), block.ToString());
        return false;
    }

    else if (res == ThinBlockBuilder::TX_DUP)
        LogPrint("thin2", "already had tx %s\n",
                tx.GetHash().ToString());

    else if (res == ThinBlockBuilder::TX_ADDED)
        LogPrint("thin2", "added transaction %s\n", tx.GetHash().ToString());

    else { assert(!"unknown addTransaction response"); }

    if (b.numTxsMissing() == 0)
        finishBlock(block);

    return true;
}
예제 #3
0
void JitWriter::writeOp1(const FrameState* frame, const uint8_t *pc,
                         AbcOpcode abcop, uint32_t opd1, Traits*) {
  analyze(abcop, pc, frame);
  if (needSavedScopes(pc, abcop))
    abc_->abc_instrs.put(pc, new (abc_->alloc_) AbcInstr(abcop, opd1));
  if (isBranchOpcode(abcop)) {
    const uint8_t* nextpc = pc + 4;
    int offset = int32_t(opd1);
    if (abcop == OP_jump) {
      abc_->analyzeEnd(current_block_, nextpc + offset);
      finishBlock(nextpc);
    } else {
      abc_->analyzeBranch(current_block_, abcop, nextpc, offset);
      finishBlock(nextpc);
      newBlock(nextpc, frame);
    }
  }
}
예제 #4
0
void JitWriter::writeBlockStart(const FrameState* frame) {
  AvmAssert((!current_block_ || current_block_->start <= frame->abc_pc) &&
         "didn't expect blocks out of order");
  const uint8_t* pc = frame->abc_pc;
  if (current_block_ && current_block_->start < pc) {
    abc_->analyzeEnd(current_block_, pc);
    finishBlock(pc);
  }
  startBlock(frame);
  analyze(OP_label, pc, frame);
}
예제 #5
0
void JitWriter::write(const FrameState* frame, const uint8_t* pc,
                      AbcOpcode abcop, Traits*) {
  analyze(abcop, pc, frame);
  if (needSavedScopes(pc, abcop))
    abc_->abc_instrs.put(pc, new (abc_->alloc_) AbcInstr(abcop));
  if (abcop == OP_lookupswitch || isEndOpcode(abcop)) {
    uint32_t imm30 = 0, imm30b = 0;
    int imm8 = 0, imm24 = 0;
    const uint8_t* nextpc = pc;
    AvmCore::readOperands(nextpc, imm30, imm24, imm30b, imm8);
    if (abcop == OP_lookupswitch)
      abc_->analyzeSwitch(current_block_, pc, nextpc, imm24, imm30b + 1);
    finishBlock(nextpc);
  }
}
예제 #6
0
void JitWriter::analyze(AbcOpcode abcop, const uint8_t* pc,
                        const FrameState* frame) {
  AvmAssert(pc == frame->abc_pc);
  (void) frame;

#ifdef AVMPLUS_VERBOSE
  if (enable_verbose) {
    console_ << "analyze " << opcodeInfo[abcop].name << '\n';
  }
#else
  (void) abcop;
#endif

  if (current_block_ && pc > current_block_->start && abc_->haveBlock(pc)) {
#ifdef AVMPLUS_VERBOSE
    if (enable_verbose)
      console_ << "surprise\n";
#endif
    abc_->analyzeEnd(current_block_, pc);
    finishBlock(pc);
    newBlock(pc, frame);
  }
}
예제 #7
0
void ScobsStream::flush()
{
	finishBlock(false);
	stream->flush();
}
예제 #8
0
파일: Race.cpp 프로젝트: papay0/NanoBots
std::shared_ptr<Entity> Race::createFinishBlock(float positionX, float positionY, float angle, b2Body* body)
{
     std::shared_ptr<Entity> finishBlock(new Entity{positionX, positionY, angle, "finish_block", body});
     finishBlock->addActionOnCollide("player", 1);
     return finishBlock;
}