Skip to content

Instantly share code, notes, and snippets.

@sgaliamov
Last active May 2, 2021 15:16
Show Gist options
  • Select an option

  • Save sgaliamov/bf2d391c2aad0d4f31dd29b966a992b0 to your computer and use it in GitHub Desktop.

Select an option

Save sgaliamov/bf2d391c2aad0d4f31dd29b966a992b0 to your computer and use it in GitHub Desktop.

Revisions

  1. sgaliamov revised this gist May 2, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion wer
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    were
  2. sgaliamov revised this gist May 2, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions wer
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    were
  3. sgaliamov created this gist May 2, 2021.
    16 changes: 16 additions & 0 deletions illuminator-sample-3.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    var method = new DynamicMethod("Foo", typeof(int), new[] { typeof(int) });
    var generator = method.GetILGenerator();
    var label = generator.DefineLabel();
    var il = generator.UseIlluminator(); // Creates wrapper
    il.Ldarg_0()
    .Ldc_I4_2()
    .Ceq()
    .Brfalse_S(label) // if (value == 2)
    .Ldc_I4_1()
    .Ret() // return 1
    .MarkLabel(label)
    .Ldarg_0()
    .Ldc_I4_3()
    .Add()
    .Ret(); // return value + 3
    var foo = method.CreateDelegate<Func<int, int>>();