From 18f0ccc2f6304d7f68cf70bb8ad267f7ce143625 Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Tue, 15 Nov 2022 01:21:46 -0500 Subject: [PATCH] Fix tail opcode convertion --- src/XamlX.IL.Cecil/CecilEmitter.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/XamlX.IL.Cecil/CecilEmitter.cs b/src/XamlX.IL.Cecil/CecilEmitter.cs index f3e1064e..c5011852 100644 --- a/src/XamlX.IL.Cecil/CecilEmitter.cs +++ b/src/XamlX.IL.Cecil/CecilEmitter.cs @@ -49,12 +49,17 @@ static CecilEmitter() { var sre = (SreOpCode) sreField.GetValue(null); - var cecilField = typeof(OpCodes).GetField(sreField.Name); - if(cecilField == null) + + var cecil = sreField.Name switch + { + nameof(SreOpCodes.Tailcall) => OpCodes.Tail, + string name => (OpCode?)typeof(OpCodes).GetField(name)?.GetValue(null), + _ => null + }; + if(cecil == null) continue; - var cecil = (OpCode)cecilField.GetValue(null); - Dic[sre] = cecil; - } + Dic[sre] = cecil.Value; + } }