Last active
May 2, 2021 15:16
-
-
Save sgaliamov/bf2d391c2aad0d4f31dd29b966a992b0 to your computer and use it in GitHub Desktop.
Revisions
-
sgaliamov revised this gist
May 2, 2021 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
sgaliamov revised this gist
May 2, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ were -
sgaliamov created this gist
May 2, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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>>();