# BasicBlock

Class in [Yarn.Compiler](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler)

Inherits from `System.Object`

## Summary

A basic block is a run of instructions inside a Node. Basic blocks group instructions up into segments such that execution only ever begins at the start of a block (that is, a program never jumps into the middle of a block), and execution only ever leaves at the end of a block.

```csharp
public class BasicBlock
```

## Classes

| Name                                                                                                                                                                   | Description                                                                 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [CommandElement](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.commandelement)                           | A command that will be executed.                                            |
| [LineElement](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.lineelement)                                 | A line of dialogue that should be shown to the player.                      |
| [OptionsElement](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.optionselement)                           | A collection of options that should be shown to the player.                 |
| [PlayerVisibleContentElement](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.playervisiblecontentelement) | An abstract class that represents some content that is shown to the player. |

## Enums

| Name                                                                                                                               | Description                                                                                                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Condition](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.condition) | The conditions under which a [Destination](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.destination) may be reached at the end of a BasicBlock. |

## Methods

| Name                                                                                                                                                                 | Description                                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [AddDestination(string,Condition)](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.adddestination-2)     | Adds a new destination to this block, that points to a node.        |
| [AddDestination(BasicBlock,Condition)](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.adddestination-1) | Adds a new destination to this block, that points to another block. |

## Properties

| Name                                                                                                                                                                                   | Description                                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Ancestors](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.ancestors)                                                     | Get the ancestors of this block - that is, blocks that may run immediately before this block.                                                      |
| [Descendants](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.descendants)                                                 | Gets all descendants (that is, destinations, and destinations of those destinations, and so on), recursively.                                      |
| [DescendantsWithPlayerVisibleContent](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.descendantswithplayervisiblecontent) | Gets all descendants (that is, destinations, and destinations of those destinations, and so on) that have any player-visible content, recursively. |
| [Destinations](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.destinations)                                               | Gets the destinations of this block - that is, blocks or nodes that may run immediately after this block.                                          |
| [FirstInstructionIndex](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.firstinstructionindex)                             | Gets the index of the first instruction of the node that this block is in.                                                                         |
| [Instructions](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.instructions)                                               | Gets the Instructions that form this block.                                                                                                        |
| [LabelName](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.labelname)                                                     | Gets the name of the label that this block begins at, or null if this basic block does not begin at a labelled instruction.                        |
| [Name](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.name)                                                               | Gets a descriptive name for the block.                                                                                                             |
| [NodeName](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.nodename)                                                       | Gets the name of the node that this block is in.                                                                                                   |
| [PlayerVisibleContent](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.playervisiblecontent)                               | Gets the collection of player-visible content that will be delivered when this block is run.                                                       |

## Structs

| Name                                                                                                                                   | Description                                                                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Destination](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.destination) | A destination represents a [BasicBlock](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock) or node that may be run, following the execution of a [BasicBlock](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.compiler/yarn.compiler.basicblock) . |
