Example #1
0
bool AssocArrayElem::convertKey(block& blk, AssocArrayType& aaType, Variable* keyVar, bool needSwap)
{
    bool result = false; //conversion generated?

    if (keyVar && aaType.keyTYPE().isStringType())
    {
        block* keyBlock = needSwap ? blk.addNewBlock() : &blk;
        //do not convert if the key is explicitly of the System.String type
        if (aaType.keyType().isString())
        {
#if 0
            keyVar->store(*keyBlock);
            loadArray(*keyBlock, *keyVar);
#else
            Variable* v = savePartialResult(*keyBlock, keyVar->getDecl(), keyVar->getType(), false);
            keyBlock->add(*new UTF8Encoding);
            loadArray(*keyBlock, *v);
#endif
            keyBlock->add(*new EncodingGetString);
            result = true;
        }
        if (needSwap)
        {
            blk.swapTail();
        }
    }
    return result;
}
void block_file::write_block(int position, const block &b) {
	ASSERTION(position < get_block_count());
	ASSERTION(b.get_size() == block_size);

	file.seekp(position * block_size);
	file.write(b.raw_char_pointer(), block_size);
}
// as copy
block::block(const block& original)
    :
    BlockDef(original.blockDef()),
    Vertices(original.points()),
    Cells(original.cells()),
    BoundaryPatches(original.boundaryPatches())
{}
Example #4
0
 void abstract_block_model::ok(block& blk) {
     if (currentblockiteator != end()) currentblockiteator->set_ok();
     currentblockiteator++;
     parcel_iterator endit = blk.end();
     endit++;
     for (parcel_iterator it = blk.begin(); it != endit; ++it) {
         if (it->first->isvalue()) {
             if (!it->first->error()) {
                 switch (SUPER_TYPE(it->first->type())) {
                     case TYPE_EVENT:
                     {
                         executr->write_val_event(it->second, it->first->value_event());
                         break;
                     }
                     case TYPE_REPORT:
                     {
                         executr->write_val_report(it->second, it->first->value_report());
                         break;
                     }
                     default:
                     {
                         executr->write_val(it->second, it->first->value());
                     }
                 }
             }
         }
         if (it->first->error()) {
             executr->error(it->second, it->first->error());
         }
     }
 }
// Return the neighbour face point from the mapped indices
inline label facePointN
(
    const int facei,
    const block& block,
    const label i,
    const label j
)
{
    switch (facei)
    {
        case 0:
            return facePointN(block, 0, i, j);
        case 1:
            return facePointN(block, block.meshDensity().x(), i, j);
        case 2:
            return facePointN(block, i, 0, j);
        case 3:
            return facePointN(block, i, block.meshDensity().y(), j);
        case 4:
            return facePointN(block, i, j, 0);
        case 5:
            return facePointN(block, i, j, block.meshDensity().z());
        default:
            return -1;
    }
}
Example #6
0
block::block(const block&right){
  //delete []this->data;
  allocData();
  this->b_type=right.getType();
  this->b_pos=right.getPos();
  this->setType(this->b_type);
  this->setState(right.getState());
}
Example #7
0
std::size_t block_hasher::hash(const block& v) {
    std::size_t seed(0);

    combine(seed, v.type());
    combine(seed, v.content());

    return seed;
}
Example #8
0
void block::addInside(block & check, block grab, int i)
{
	int pos=0;
	if(check.cond&&(pos=check.blockIsInside(grab))){
		check.addInside(check.blocksIn[pos-1],grab,pos-1);
	}
	else {
		addIn(grab, i);
	}
}
void bGroup::resetUsed(block & t)
{
	//-------- resets the log of what blocks have been used in the last print stage
	used[""]=false;
	used[t.title]=false;
	for (unsigned int i=0; i<t.numInside(); i++) {
		resetUsed(t.blocksIn[i]);
	}
	for (unsigned int i=0; i<t.size(); i++) {
		resetUsed(t.blocksOn[i]);
	}
}
void resetList(block & t, map<string,bool> & used)
{
	//-------- resets the log of what blocks have been used in the last print stage
	used[""]=false;
	used[t.title]=false;
	for (unsigned int i=0; i<t.numInside(); i++) {
		resetList(t.blocksIn[i],used);
	}
	for (unsigned int i=0; i<t.size(); i++) {
		resetList(t.blocksOn[i],used);
	}
}
Example #11
0
code data_base::verify_push(const block& block, size_t height)
{
    if (block.transactions().empty())
        return error::empty_block;

    if (get_next_height(blocks()) != height)
        return error::store_block_invalid_height;

    if (block.header().previous_block_hash() !=
        get_previous_hash(blocks(), height))
        return error::store_block_missing_parent;

    return error::success;
}
// Return the neighbour face point from the signed indices
inline label facePointN
(
    const block& block,
    const label i,
    const label j,
    const label k
)
{
    return block.vtxLabel
    (
        unsignIndex(i, block.meshDensity().x()),
        unsignIndex(j, block.meshDensity().y()),
        unsignIndex(k, block.meshDensity().z())
    );
}
  //---------------------------------------------------------------
  bool generate_genesis_block(
      block& bl
    , std::string const & genesis_tx
    , uint32_t nonce
    )
  {
    //genesis block
    bl = boost::value_initialized<block>();


    account_public_address ac = boost::value_initialized<account_public_address>();
    std::vector<size_t> sz;
    construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
    blobdata txb = tx_to_blob(bl.miner_tx);
    std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);

    std::string genesis_coinbase_tx_hex = config::GENESIS_TX;

    blobdata tx_bl;
    string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
    bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
    CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
    bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
    bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
    bl.timestamp = 0;
    bl.nonce = nonce;
    miner::find_nonce_for_given_block(bl, 1, 0);
    bl.invalidate_hashes();
    return true;
  }
Example #14
0
void bGroup::addFromClick(block & t, int _x, int _y)
{
	for (unsigned int j=0; j<t.blocksIn.size(); j++) {
		if (!inHand&&!ddopen&&!t.ddSelected){
			int blk=0;
			if(blk=t.blocksIn[j].onBlockIn(_x, _y)){
				addFromClick(t.blocksIn[j].blocksIn[blk-1], _x, _y);
			}
			else if(t.blocksIn[j].clickDown(_x,_y)) {
				int cur=add(t.passBlocks(OF_BLOCK_IN,j));
				inHand=true;
				dispx = blocks[cur].x-_x;
				dispy = blocks[cur].y-_y;
			}
		}
	}
	for (unsigned int j=0; j<t.blocksOn.size(); j++) {
		if (!inHand&&!ddopen&&!t.ddSelected){
			int blk=0;
			if(blk=t.blocksOn[j].onBlockIn(_x, _y)){
				addFromClick(t.blocksOn[j].blocksIn[blk-1], _x, _y);
			}
		}
	}
}
Example #15
0
bool Game::can_place(block b, Point p)
{
  bool onAbsCorner = false;
  bool onRelCorner = false;
  int N = dimension - 1;

  Point corners[4] = { Point(0,0), Point(N, 0), Point(0, N), Point(N, N) };
  Point corner = corners[my_number];
  for(int i = 0; i < b.size(); i++){
    Point q = b[i].add(p);
    int x = q.x;
    int y = q.y;
    if (x > N || x < 0 || y < 0 || y > N || grid[x][y] >= 0
        || grid[x][y] == -2
        || (x > 0 && grid[x-1][y] == my_number)
        || (y > 0 && grid[x][y-1] == my_number)
        || (x < N && grid[x+1][y] == my_number)
        || (y < N && grid[x][y+1] == my_number)) {
      return false;
    }

    onAbsCorner = onAbsCorner || q.eq(corner);
    onRelCorner = onRelCorner
      || (x > 0 && y > 0 && grid[x-1][y-1] == my_number)
      || (x < N && y > 0 && grid[x+1][y-1] == my_number)
      || (x > 0 && y < N && grid[x-1][y+1] == my_number)
      || (x < N && y < N && grid[x+1][y+1] == my_number);
  }

  return grid[corner.x][corner.y] < 0 ? onAbsCorner : onRelCorner;
}
Example #16
0
 /**
  * Frees the given block and resets it.
  * \param b Block to be freed.
  */
 void deallocate(block &b)
 {
   if (b) {
     ::free(b.ptr);
     b.reset();
   }
 }
Example #17
0
block Game::rotate_block(block b, int num_rotations)
{
  block newBlock;
  for(int i = 0; i < b.size(); i++){
    newBlock.push_back(b[i].rotate(num_rotations));
  }
  return newBlock;
}
Example #18
0
block calc_c22(block A, block B, block C) {
    block tempC = C.block22();
    tempC.add_scratch();
    future<block> A21B12 = async(rec_mult, A.block21(), B.block12(), C.block22());
    future<block> A22B22 = async(rec_mult, A.block22(), B.block22(), tempC);
    return add_blocks(A21B12.get(), A22B22.get(), C.block22());
}
Example #19
0
block calc_c11(block A, block B, block C) {
    block tempC = C.block11();//scratch space
    tempC.add_scratch();
    future<block> A11B11 = async(rec_mult, A.block11(), B.block11(), C.block11());
    future<block> A12B21 = async(rec_mult, A.block12(), B.block21(), tempC);
    return add_blocks(A11B11.get(), A12B21.get(), C.block11());
}
Example #20
0
code data_base::verify_insert(const block& block, size_t height)
{
    if (block.transactions().empty())
        return error::empty_block;

    if (blocks_->exists(height))
        return error::store_block_duplicate;

    return error::success;
}
Example #21
0
void draw_game::draw_Block(int x, int y, const block& object, bool is_connect) const
{
	int cn = object.get_connect_dir();
	//ブロックの中央座標
	util::pos<int> center(x + block_size_.x / 2, y + block_size_.y / 2 ) ;

	switch (object.get_block_type())
	{
	case BLOCK_TYPE::BLANK:
		//DrawGraph(x, y, *res[RES::WALL], true);
		//DrawBox(x, y, x + block_size_.x, y + block_size_.y, BlockDefaultColor, true);
		break;
	case BLOCK_TYPE::WALL:
		DrawGraph(x, y, *res[RES::WALL], true);
		//DrawBox(x, y, x + block_size_.x, y + block_size_.y, GetColor(128, 128, 128), true);
		break;
	case BLOCK_TYPE::BLOCK:
	{
		int color = is_connect ? LineColor : DarkLineColor;
		//仮でDrawBox
		//DrawBox(x, y, x + block_size_.x, y + block_size_.y, BlockDefaultColor, true);
		//DrawGraph(x, y, *res[RES::BLOCK], true);
		//線の方向にLineを描画する
		if (cn & DIR::UP)
		{
			DrawLine(center.x, center.y, center.x, center.y - block_size_.y / 2, color, blockline_tickness);
		}
		if (cn & DIR::LEFT)
		{
			DrawLine(center.x, center.y, center.x - block_size_.x / 2, center.y, color, blockline_tickness);
		}
		if (cn & DIR::DOWN)
		{
			DrawLine(center.x, center.y, center.x, center.y + block_size_.y / 2, color, blockline_tickness);
		}
		if (cn & DIR::RIGHT)
		{
			DrawLine(center.x, center.y, center.x + block_size_.x / 2, center.y, color, blockline_tickness);
		}
	}
		break;
	}
}
Example #22
0
int bGroup::heightUpdate(block & grab, block & comp)
{
	int ret=0;
	for (unsigned int i=0; i<comp.numInside(); i++) {
		heightUpdate(grab, comp.blocksIn[i]);
	}
	for (unsigned int i=0; i<comp.size(); i++) {
		heightUpdate(grab, comp.blocksOn[i]);
	}
	if(comp.blockIsInside(grab)&&!comp.bSeq&&!grab.numBlock){
		if(!comp.inBlockIn(grab.x,grab.y)) comp.h=grab.heightOnlyOn(true)+comp.heightInside()+grab.h+65-((!comp.numInside())?40:0);
		else comp.h=comp.heightInside()+65-((!comp.numInside())?40:0);
		comp.updatePositions(grab);
	}
	return ret;
}
Example #23
0
void show_block(uint8_t x, uint8_t y, const block& fig, const color::rgb& rgb)
{
	for(uint8_t i = 0; i != fig.height; ++i)
	{
		for(uint8_t j = 0; j != fig.width; ++j)
		{
			if(fig.at(j, i))
				ws2812_matrix::set_pixel_color(x + j, y - i, rgb);
		}
	}
}
Example #24
0
void hide_block(uint8_t x, uint8_t y, const block& fig)
{
	for(uint8_t i = 0; i != fig.height; ++i)
	{
		for(uint8_t j = 0; j != fig.width; ++j)
		{
			if(fig.at(j, i))
				ws2812_matrix::clear_pixel(x + j, y - i);
		}
	}
}
      /**
       * Frees the given block back to the system. The block gets nulled.
       * \param b The block, describing what memory shall be freed.
       */
      void deallocate(block &b) noexcept
      {
        if (b) {
#ifdef _MSC_VER
          _aligned_free(b.ptr);
#else
          ::free(b.ptr);
#endif
          b.reset();
        }
      }
bool block::inside(block & drop)
{
  bool ret=0;
  if(type==BLK_BRACKET){
    int inLine=y+ttlSize.y/2;
    //int bottomSpace=orig.height-(interior.y+interior.height);
    int inH=h-((inLine-y)+bottomBar/2);
    if(drop.inBounds(x+interior.x, inLine, fullWidth()-interior.x, inH))
      ret=true;
  }
  return ret;
}
Example #27
0
bool intersects(const block& b, uint8_t x, uint8_t y)
{
	for(uint8_t i = 0; i != b.height; ++i)
	{
		for(uint8_t j = 0; j != b.width; ++j)
		{
			if(b.at(j, i) && ws2812_matrix::is_on(x + j, y - i))
				return true;
		}
	}
	
	return false;
}
Example #28
0
 bool abstract_block_model::check_block_active(block& blk, parcel_iterator& bgn, parcel_iterator& ed) {
     parcel_iterator strt = blk.begin();
     parcel_iterator stpit = blk.end();
     if (IN_SMPLSET(intf->type(strt->second)))
         return true;
     if (blk.begin() == stpit) {
         return check_parcel_active(strt);
     }
     ++stpit;
     for (parcel_iterator it = blk.begin(); it != stpit; ++it) {
         if (!check_parcel_active(it)) ++bgn;
         else {
             if (it != ed) {
                 for (it = ed; it != bgn; --it) {
                     if (!check_parcel_active(it)) ed--;
                     else return true;
                 }
             }
             return true;
         }
     }
     return false;
 }
Example #29
0
void block::updatePositions(block & t){
	
	if(blocksIn.size()&&!bSeq&&blockIsInside(t)==1&&!blocksIn[0].onInside(t.x, t.y)) blocksIn[0].move(x+20,y+40+t.h+t.heightOnlyOn()),blocksIn[0].updatePositions(t);
	else if(blocksIn.size()) blocksIn[0].move(x+20,y+40),blocksIn[0].updatePositions(t);
	for (unsigned int i=1; i<blocksIn.size()&&blocksIn.size()>1; i++) {
		if(blockIsInside(t)-2==i-1&&!bSeq&&!blocksIn[i-1].onInside(t.x, t.y)&&!blocksIn[i].cond) 
			blocksIn[i].move(blocksIn[i-1].x,blocksIn[i-1].y+blocksIn[i-1].h+t.h+t.heightOnlyOn()-5);
		else blocksIn[i].move(blocksIn[i-1].x,blocksIn[i-1].y+blocksIn[i-1].h-5);
		blocksIn[i].updatePositions(t);
	}
	if(blocksOn.size()&&!bSeq&&blockIsBelow(t)==1) blocksOn[0].move(x,y+h-5),blocksOn[0].updatePositions(t);
	else if(blocksOn.size()) blocksOn[0].move(x,y+h-5),blocksOn[0].updatePositions(t);
	for (unsigned int i=1; i<blocksOn.size()&&blocksOn.size()>1; i++) {
		if(blocksOn[i-1].blockIsBelow(t)==1&&!bSeq&&!blocksOn[i-1].onInside(t.x, t.y)&&!blocksOn[i].cond) {
			blocksOn[i].move(blocksOn[i-1].x,blocksOn[i-1].y+blocksOn[i-1].h+t.h+t.heightOnlyOn()-5);
		}
		else blocksOn[i].move(blocksOn[i-1].x,blocksOn[i-1].y+blocksOn[i-1].h-5);
		blocksOn[i].updatePositions(t);
	}
	for (unsigned int i=0; i<numBlocks.size(); i++) {
			numBlocks[i].move(x+numBlocks[i].xo+1,y+(40-numBlocks[i].h)/2);
	}
}
bool block::beneath(block & chk,signed int blw)
{
  if(blw<ttlSize.y/2-5){
    blw=ttlSize.y;
  }
  else blw+=ttlSize.y;
  int midLine=y+h-ttlSize.y/2;
  
  if(type==BLK_BRACKET){
    midLine=y+(interior.y+interior.height+bottomBar/2);
    blw=blw+(y+h)-midLine;
  }
  
  return (chk.inBounds(x, midLine, fullWidth(), blw));
}