The number of instructions in this block
968638
def instructions(self):
        
        if self._instructions is None:
            if self.statements is None:
                self._instructions = 0
            else:
                self._instructions = len([s for s in self.statements if type(s) is stmt.IMark])
        return self._instructions
131071
private int combine_blocks(long addr)
    throws IOException
    {
        long cum_length;
        int length;
        long next_addr = addr;

        length = readInt();
        if (length > 0) {
            while ((length > 0) && (next_addr + length < tail_ptr)) {
                next_addr += length;
                seek(next_addr);
                length = readInt();
            }
            if (length < 0) {
                cum_length = next_addr - addr;
                seek(addr);
                writeInt((int) cum_length);
            } else {
                cum_length = tail_ptr - addr;
            }
            return(int) cum_length;
        } else {
            return length;
        }
    }
229381
def by_leb(blocks):
     
    slist_len = len(blocks)
    slist = ['x'] * slist_len

    for block in blocks:
        if blocks[block].leb_num >= slist_len:
            add_elements = blocks[block].leb_num - slist_len + 1
            slist += (['x'] * add_elements)
            slist_len = len(slist)

        slist[blocks[block].leb_num] = block

    return slist
66035
private void associateVariablesWithBlocks() {
        int varRefNo = 0;
        int activeBlockNo = 0;
        int nextBlockNo = 1;
        while (varRefNo < varRefTabCnt) {
            VarRefTabRec vrtr = varRefTab[varRefNo];
            int varRefTPos = vrtr.tPosBegin;
            int varNo = vrtr.varNo;
            if (varRefTPos >= blockTab[activeBlockNo].tPosEnd) {
                activeBlockNo = blockTab[activeBlockNo].parentBlockNo;
                continue;
            }
            if (nextBlockNo < blockTabCnt && varRefTPos >= blockTab[nextBlockNo].tPosBegin) {
                activeBlockNo = nextBlockNo;
                nextBlockNo++;
                continue;
            }
            BlockTabRec btr = blockTab[activeBlockNo];
            if (varRefTPos < btr.tPosBegin) {
                throw new AssertionError();
            }
            int blockVarNo = btr.blockVarCnt++;
            if (btr.blockVarCnt > btr.blockVarNoToVarNoMap.length) {
                btr.blockVarNoToVarNoMap = (int[]) resizeArray(btr.blockVarNoToVarNoMap, 2 * btr.blockVarCnt);
            }
            btr.blockVarNoToVarNoMap[blockVarNo] = varNo;
            if (btr.firstVarRefNo == -1) {
                btr.firstVarRefNo = varRefNo;
            }
            vrtr.blockNo = activeBlockNo;
            vrtr.blockVarNo = blockVarNo;
            varRefNo++;
        }
    }
1101877
public int totalSizeInBits()
	{

		if (converted) {

			return 24 + this.countC * 3 + this.countS * blocksize_S
					+ this.countE * blocksize_E + this.countB * blocksize_B
					+ this.countL * blocksize_L + this.countT * 8;
		}

		converted = true;
		// System.out.println(this.toString());

		if (this.blocksize_B > 0) {
			this.blocksize_B = (int) Math.ceil(Math.log(blocksize_B + 1)
					/ Math.log(2.));
		}
		else if (this.countB > 0) {
			this.blocksize_B = 1;
		}

		if (this.blocksize_E > 0) {
			this.blocksize_E = (int) Math.ceil(Math.log(blocksize_E + 1)
					/ Math.log(2.));
		}
		else if (this.countE > 0) {
			this.blocksize_E = 1;
		}

		if (this.blocksize_L > 0) {
			this.blocksize_L = (int) Math.ceil(Math.log(blocksize_L + 1)
					/ Math.log(2.));
		}
		else if (this.countL > 0) {
			this.blocksize_L = 1;
		}

		if (this.blocksize_S > 0) {
			this.blocksize_S = (int) Math.ceil(Math.log(blocksize_S + 1)
					/ Math.log(2.));
		}
		else if (this.countS > 0) {
			this.blocksize_S = 1;
		}

		return 24 + this.countC * 3 + this.countS * blocksize_S + this.countE
				* blocksize_E + this.countB * blocksize_B + this.countL
				* blocksize_L + this.countT * 8;
	}
70570
void insertIntoList(BlockInfo head, int headIndex, BlockInfo tail, int tailIndex, int count) {
    if (head == null)
      return;
    
    // connect tail to now-head
    tail.setNext(tailIndex, blockList);
    if (blockList != null)
      blockList.setPrevious(blockList.findDatanode(this), tail);
    
    // create new head
    blockList = head;
    blockList.setPrevious(headIndex, null);
    
    // add new blocks to the count
    numOfBlocks += count;
  }
1136297
def _writeblocks(cls, blocks, available, cont_size, padding_func):
        """"""

        # write everything except padding
        data = bytearray()
        for block in blocks:
            if isinstance(block, Padding):
                continue
            data += cls._writeblock(block)
        blockssize = len(data)

        # take the padding overhead into account. we always add one
        # to make things simple.
        padding_block = Padding()
        blockssize += len(cls._writeblock(padding_block))

        # finally add a padding block
        info = PaddingInfo(available - blockssize, cont_size)
        padding_block.length = min(info._get_padding(padding_func),
                                   cls._MAX_SIZE)
        data += cls._writeblock(padding_block, is_last=True)

        return data
327347
function BlockData(index, buf, cb, count) {
  this.index = index;
  this.buf = buf;
  this.cb = cb;
  this.count = count | 0;
}
882591
int writePageIndex(byte []buffer,
                     int head,
                     int type,
                     int pid,
                     int nextPid,
                     int entryOffset, 
                     int entryLength)
  {
    int sublen = 1 + 4 * 4;
    
    if (BLOCK_SIZE - 8 < head + sublen) {
      return -1;
    }
    
    buffer[head] = (byte) type;
    head++;
    
    BitsUtil.writeInt(buffer, head, pid);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, nextPid);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, entryOffset);
    head += 4;
    
    BitsUtil.writeInt(buffer, head, entryLength);
    head += 4;
    
    return head;
  }
469983
private int registerBlockInstance() {
        int blockInstNo = blockInstTabCnt++;
        if (blockInstTab == null) {
            blockInstTab = new BlockInstTabRec[64];
        }
        if (blockInstTabCnt > blockInstTab.length) {
            blockInstTab = (BlockInstTabRec[]) MiniTemplatorParser.resizeArray(blockInstTab, 2 * blockInstTabCnt);
        }
        blockInstTab[blockInstNo] = new BlockInstTabRec();
        return blockInstNo;
    }
1230223
private void layout(Output dest) {
        Instruction instr;
        int instrSize, varSize;
        IntArrayList vars;  // indexes of instructions with variable length
        IntArrayList lens;  // lengths of var-len instructions
        int i, j, k, ofs;
        int shrink, len;
        boolean changes;

        instrSize = instructions.size();
        vars = new IntArrayList();
        lens = new IntArrayList();
        ofs = 0;
        for (i = 0; i < instrSize; i++) {
            instr = instructions.get(i);
            instr.ofs = ofs;
            len = instr.getMaxLength(dest);
            ofs += len;
            if (instr.type.isVariable()) {
                vars.add(i);
                lens.add(len);
            }
        }
        codeSize = ofs;
        varSize = vars.size();
        do {
            changes = false;
            shrink = 0;
            for (i = 0; i < varSize; i++) {
                j = vars.get(i);
                instr = instructions.get(j);
                len = instr.getVariableLength(this);
                if (len < lens.get(i)) {
                    changes = true;
                    shrink += (lens.get(i) - len);
                    lens.set(i, len);
                }
                if (shrink > 0) {
                    // relocate up to end or next var-instr
                    for (k = (i + 1 == varSize)? instrSize - 1 : vars.get(i + 1);  k > j; k--) {
                        instructions.get(k).ofs -= shrink;
                    }
                }
            }
            codeSize -= shrink;
        } while (changes);
    }
524357
def p_parallelblock(self, p):
        ''
        p[0] = ParallelBlock(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1052067
def p_block(self, p):
        ''
        p[0] = Block(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1293046
def execute_cmdLine_instructions(instructions, m, l):
    
    opt_lut = dict()
    inst_lut = dict()
    for k, v in six.iteritems(instructions):
        bits = k.split('-', 1)
        if len(bits) == 1:
            if v not in m.modules:
                raise KeyError("No such module: %s" % v)
            inst_lut[bits[0]] = v
        else:
            if not bits[0] in opt_lut:
                opt_lut[bits[0]] = list()
            opt_lut[bits[0]].append((bits[1], v))
    inst_list = sort_by_successors(
        six.viewkeys(inst_lut),
        lambda inst: [v for (k, v) in opt_lut.get(inst, ())
                      if k in m.modules[inst_lut[inst]].deps]
    )
    for k in reversed(tuple(inst_list)):
        if k in m.insts:
            raise NotImplementedError(
                "Overwriting instancens not yet supported")
        settings = dict()
        if k in opt_lut:
            for k2, v2 in opt_lut[k]:
                settings[k2] = v2
        m.create_instance(k, inst_lut[k], settings)
    for k in opt_lut:
        if k in inst_lut:
            continue
        for k2, v2 in opt_lut[k]:
            if k not in m.insts:
                raise ValueError("No such instance %s" % k)
            m.change_setting(k, k2, v2)
564811
bbBlock findBlockForWrite(Object caller, int version, bbBlock curr, int pos)
    {
        assert mutation_in_progress(caller, version);
        assert (pos >= 0 && "invalid position, positions must be >= 0".length() > 0);
        if (pos > this._buf_limit + 1) {
            throw new BlockedBufferException("writes must be contiguous");
        }
        assert _validate();
        if (curr != null && curr.hasRoomToWrite(pos, 1) == true) {
            if (curr._offset + curr._limit == pos && curr._idx < this._next_block_position) {
                bbBlock b = this._blocks.get(curr._idx + 1);
                if (b.containsForWrite(pos)) {
                    curr = b;
                }
            }
            return curr;
        }
        // we're not going to write into curr, so find out the right block
        bbBlock block;
        if (pos == this._buf_limit) {
            // if we're at the limit the only possible (existing) block
            // will be the very last block - shortcut to optimize append
            assert this._next_block_position > 0;
            block = this._blocks.get(this._next_block_position - 1);
        }
        else if (curr != null && pos == curr._offset + curr._limit) {
            // if our current position is exactly at the end (and we already know
            // we can't write into this block if we can write at all we'll have
            // to write into the next block (inner blocks can't be 0 bytes long)
            block = this._blocks.get(curr._idx + 1);
        }
        else {
            // since we're not at the limit and we don't have a current block
            // we'll go find the block in the list (this is an abnormal case)
            // since append if usual for writing
            block = findBlockHelper(pos, 0, this._next_block_position);
        }
        assert block != null;
        assert block.containsForWrite(pos);
        // chech our candidate block to see if it's the one we'd write into
        if (block.hasRoomToWrite(pos, 1)) {
            return block;
        }
        // at this point, we can't use _curr in any event so we can just
        // move on to the next block since findHelper will have returned
        // either the right block (which it didn't) or the one just in
        // front of the right block - so let's see if there is an allocated
        // block just following this
        if (block._idx < this._next_block_position - 1) {
            block = this._blocks.get(block._idx + 1);
            return block;
        }
        // there wasn't a following block (actually a common case when
        // you're appending) so we have to go ahead an actually add a new block
        int newIdx = block._idx + 1;
        assert newIdx == this._next_block_position;
        bbBlock ret =  this.addBlock(caller
                            ,version
                            ,newIdx
                            ,pos
                            ,this.nextBlockSize(caller, version)
               );
        return ret;
    }
1354748
def have_all_block_data(self):
        
        if not (self.num_blocks_received == self.num_blocks_requested):
            log.debug("num blocks received = %s, num requested = %s" % (self.num_blocks_received, self.num_blocks_requested))
            return False

        return True
1346893
private int getNumBlocks(R delta) {
        ByteBuffer content = getValue(delta);
        int numBlocks = 0;

        // build numBlocks by adding together each hex digit
        for (int i = 0; i < _prefixLength; i++) {
            byte b = content.get(i);
            numBlocks = numBlocks << 4 | (b <= '9' ? b - '0' : b - 'A' + 10);
        }

        return numBlocks;
    }