Skip to content

Instantly share code, notes, and snippets.

@sgaliamov
Created May 2, 2021 15:30
Show Gist options
  • Save sgaliamov/1120fe9f2e939da470e681ff0da5f1bc to your computer and use it in GitHub Desktop.
Save sgaliamov/1120fe9f2e939da470e681ff0da5f1bc to your computer and use it in GitHub Desktop.
namespace CustomExtensions
{
public static class Functions
{
public static ILEmitterFunc If(
ILEmitterFunc condition,
ILEmitterFunc then,
ILEmitterFunc @else) => (in ILEmitter il) =>
il.Brfalse(condition, out var otherwise)
.Emit(then)
.Br(out var end)
.MarkLabel(otherwise)
.Emit(@else)
.MarkLabel(end);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment