# Class: com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock

This class represents a basic block of generic instructions.

## Constructor: BasicBlock
- parameter: `base`, type: `long`

Description: Create a new empty basic block.
parameter: base: block base address

## Constructor: BasicBlock
- parameter: `base`, type: `long`
- parameter: `insns`, type: `java.util.List<InsnType>`
- parameter: `dstOffsets`, type: `java.util.List<java.lang.Long>`
- parameter: `irrdstOffsets`, type: `java.util.List<java.lang.Long>`
- parameter: `unknownDst`, type: `boolean`

Description: Create a new basic block.
parameter: base: block base address
parameter: insns: instructions
parameter: dstOffsets: regular destination offsets
parameter: irrdstOffsets: irregular destination offsets
parameter: unknownDst: true if the block has at least one unknown destination

## Method: add
- parameter: `insn`, type: `InsnType`

Description: **DANGEROUS METHOD.** Append an instruction to the block. 

 The instruction is appended to the block. The edges are not updated.
 The caller is responsible for verifying the instruction \(no null, no dup., etc.\).
 The caller is responsible for maintaining the consistency of the block and of the CFG.
parameter: insn: the instruction to be appended

## Method: add
- parameter: `index`, type: `int`
- parameter: `insn`, type: `InsnType`

Description: **DANGEROUS METHOD.** Add an instruction into the block.
parameter: index: insertion index
parameter: insn: instruction to add

## Method: addAll
- parameter: `coll`, type: `java.util.Collection<InsnType>`

Description: **DANGEROUS METHOD.** Append instructions to the block. 

 The instructions are appended to the block. The edges are not updated.
 The caller is responsible for verifying the instructions \(no null, no dup., etc.\).
 The caller is responsible for maintaining the consistency of the block and of the CFG.
parameter: coll: instructions to append

## Method: addAll
- parameter: `index`, type: `int`
- parameter: `coll`, type: `java.util.Collection<InsnType>`

Description: **DANGEROUS METHOD.** Add instructions into the block.
parameter: index: insertion index
parameter: coll: instructions to add

## Method: addressableInstructions
- return type: `java.lang.Iterable<com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType>>`

Description: Iterate over addressable instructions.
return: addressable instructions

## Method: allinsize
- return type: `int`


## Method: alloutsize
- return type: `int`


## Method: canThrow
- return type: `boolean`


## Method: compareTo
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`
- return type: `int`


## Method: get
- parameter: `index`, type: `int`
- return type: `InsnType`


## Method: get2
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType>`

Description: Get the instruction at the specified index, in an addressable form.
parameter: index: instruction index
return: addressable instruction

## Method: getAddress
- return type: `long`

Description: Get the block address.
return: block base address

## Method: getAddressOfInstruction
- parameter: `index`, type: `int`
- return type: `long`


## Method: getAddresses
- return type: `long[]`

Description: Get a list of the addresses of each instruction in the block.
return: instruction addresses

## Method: getAllInputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getAllInputs
- return type: `java.lang.Iterable<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getAllOutputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getAllOutputs
- return type: `java.lang.Iterable<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getBase
- return type: `long`


## Method: getBranchingInstruction2
- parameter: `includeBreaking`, type: `boolean`
- parameter: `includeCalling`, type: `boolean`
- return type: `com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType>`

Description: Retrieve the branching instruction, if any. In the general case, it should not be assumed that the branching instruction must be the last instruction of a block. Example: on delay\-slot architectures, a number of instructions may follow the branching instructions. They are included in the block. That means that the branching instruction, when there is one, may be the one/two/Nth\-before\-last.
parameter: includeBreaking: if true, include flow\-breaking instructions
parameter: includeCalling: if true, include routine\-call instructions
return: the branching instruction\+address, or null if none

## Method: getBranchingInstruction2
- return type: `com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType>`

Description: Same as [getBranchingInstruction2\(true, true\)](#getBranchingInstruction2(boolean, boolean)).
return: the branching instruction and address, or null if none

## Method: getData
- parameter: `name`, type: `java.lang.String`
- return type: `java.lang.Object`

Description: Get custom data.
parameter: name: data key
return: data value, or null

## Method: getEndAddress
- return type: `long`


## Method: getFirstAddress
- return type: `long`


## Method: getIndexOfInstruction
- parameter: `address`, type: `long`
- return type: `int`


## Method: getIndexOfInstruction
- parameter: `insn`, type: `InsnType`
- return type: `int`

Description: Locate an instruction in the block. Comparison is done by identity.
parameter: insn: instruction to locate
return: the instruction index, \-1 if not found

## Method: getInputBlock
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`


## Method: getInputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getInputOffsets
- return type: `java.util.List<java.lang.Long>`

Description: Get regular input block addresses.
return: regular input offsets

## Method: getInputs
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`

Description: Retrieve a read\-only list of input blocks \(regular\). 

 NOTE: This method is faster than [#getInputBlocks()](#getInputBlocks()) since it does not provide a copy of the list.
return: read\-only regular input blocks

## Method: getInstruction
- parameter: `address`, type: `long`
- return type: `InsnType`


## Method: getInstructions
- return type: `java.util.List<InsnType>`


## Method: getIrregularInputBlock
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`


## Method: getIrregularInputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getIrregularInputOffsets
- return type: `java.util.List<java.lang.Long>`

Description: Get irregular input block addresses.
return: irregular input offsets

## Method: getIrregularInputs
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`

Description: Retrieve a read\-only list of irregular input blocks. 

 NOTE: This method is faster than [#getIrregularInputBlocks()](#getIrregularInputBlocks()) since it does not provide a copy of the list.
return: read\-only irregular input blocks

## Method: getIrregularOutputBlock
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`


## Method: getIrregularOutputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getIrregularOutputOffsets
- return type: `java.util.List<java.lang.Long>`

Description: Get irregular output block addresses.
return: irregular output offsets

## Method: getIrregularOutputs
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getLast
- return type: `InsnType`

Description: Get the last instruction of the block. 

 **Keep in mind that a branching instruction may NOT be the last instruction of a basic block if it supports delay\-slots.**
return: last instruction

## Method: getLast2
- return type: `com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType>`

Description: Get the last instruction of the block, in an addressable form. 

 **Keep in mind that a branching instruction may NOT be the last instruction of a basic block if it supports delay\-slots.**
return: last addressable instruction

## Method: getLastAddress
- return type: `long`


## Method: getOutputBlock
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`


## Method: getOutputBlocks
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getOutputOffsets
- return type: `java.util.List<java.lang.Long>`

Description: Get regular output block addresses.
return: regular output offsets

## Method: getOutputs
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>>`


## Method: getSizeOfInstructions
- return type: `int`


## Method: hasUnknownDst
- return type: `boolean`

Description: Determine whether this block has an unknown destination.
return: true if this block has an unknown destination

## Method: insize
- return type: `int`


## Method: irrinsize
- return type: `int`


## Method: irroutsize
- return type: `int`


## Method: isEmpty
- return type: `boolean`


## Method: isInfiniteLoop
- return type: `boolean`

Description: Check if the block has a single regular out\-edge which points to itself.
return: true if the block is an infinite loop

## Method: isSelfReferencing
- return type: `boolean`

Description: Check if the block has at least one regular out\-edge pointing to itself.
return: true if the block has a regular out\-edge to itself

## Method: iterator
- return type: `java.util.Iterator<InsnType>`


## Method: outsize
- return type: `int`


## Method: remove
- parameter: `index`, type: `int`
- return type: `boolean`

Description: Remove an instruction from the block as well as associated chains. **Usage is not recommended for public clients.** 

 This method may have the nasty side\-effect of making the block empty. In that case, it returns true, and it is the caller's responsibility to refresh the CFG at their earliest convenience. 

 Another issue the client needs to take care of is the removal of the last instruction, which should only happen on very specific conditions, since the trailing instruction typically conditions the out\-edges of the block.
parameter: index: instruction index
return: true if the CFG need refreshing

## Method: removeData
- parameter: `name`, type: `java.lang.String`
- return type: `boolean`

Description: Remove custom data.
parameter: name: data key
return: true if custom data was removed

## Method: set
- parameter: `index`, type: `int`
- parameter: `insn`, type: `InsnType`
- return type: `InsnType`

Description: **DANGEROUS METHOD.** Replace an instruction. Sizes must match. 

 Edges are not updated.
 The caller is responsible for maintaining the consistency of the block and of the CFG.
parameter: index: instruction index
parameter: insn: the instruction
return: the instruction that was replaced

## Method: setData
- parameter: `name`, type: `java.lang.String`
- parameter: `object`, type: `java.lang.Object`

Description: Set custom data. Custom data is reset when a DFA is invalidated.
parameter: name: data key
parameter: object: data value

## Method: setLast
- parameter: `insn`, type: `InsnType`
- return type: `InsnType`

Description: Replace the last instruction.
parameter: insn: replacement instruction
return: previous last instruction

## Method: setUnknownDst
- parameter: `unknownDst`, type: `boolean`

Description: Set whether this block has an unknown destination.
parameter: unknownDst: true if the block has an unknown destination

## Method: shallowCopy
- parameter: `copyBlockReferences`, type: `boolean`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType>`

Description: Shallow duplication of a basic block. USE THE RESULTING BLOCK WITH CAUTION. \- Instructions references are copied
 \- Block references \(edges\) are optionally copied \(the blocks are not\)
 \- DFA data is not copied
parameter: copyBlockReferences: if true, copy block edge references
return: a new block

## Method: size
- return type: `int`


## Method: toString
- return type: `java.lang.String`


