# BasicBlock

Class in [Yarn.Compiler](https://docs.yarnspinner.dev/2.2/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.2/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.commandelement)                           | A command that will be executed.                                            |
| [LineElement](https://docs.yarnspinner.dev/2.2/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.2/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.2/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.2/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.condition) | The conditions under which a [Destination](https://docs.yarnspinner.dev/2.2/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.2/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.2/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.2/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.2/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.2/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.2/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.2/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.2/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.instructions)                                               | Gets the Instructions that form this block.                                                                                                        |
| [LabelName](https://docs.yarnspinner.dev/2.2/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.2/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.name)                                                               | Gets a descriptive name for the block.                                                                                                             |
| [NodeName](https://docs.yarnspinner.dev/2.2/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.2/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.2/api/csharp/yarn.compiler/yarn.compiler.basicblock/yarn.compiler.basicblock.destination) | A destination represents a [BasicBlock](https://docs.yarnspinner.dev/2.2/api/csharp/yarn.compiler/yarn.compiler.basicblock) or node that may be run, following the execution of a [BasicBlock](https://docs.yarnspinner.dev/2.2/api/csharp/yarn.compiler/yarn.compiler.basicblock) . |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yarnspinner.dev/2.2/api/csharp/yarn.compiler/yarn.compiler.basicblock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
