static void Main(string[] args) { Debug.Assert(pop.Length == StackBehaviourPopCount); Debug.Assert(push.Length == StackBehaviourPushCount); CheckEnumRange(typeof(FlowControl), FlowControlCount); CheckEnumRange(typeof(OpCodeType), OpCodeTypeCount); CheckEnumRange(typeof(OperandType), OperandTypeCount); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); IKVM.Reflection.Emit.OpCode opc2 = new IKVM.Reflection.Emit.OpCode(Pack(opc1)); Debug.Assert(opc1.Value == opc2.Value); Debug.Assert(opc1.Size == opc2.Size); Debug.Assert((int)opc1.FlowControl == (int)opc2.FlowControl); Debug.Assert((int)opc1.OpCodeType == (int)opc2.OpCodeType); Debug.Assert((int)opc1.OperandType == (int)opc2.OperandType); Debug.Assert((int)opc1.StackBehaviourPop == (int)opc2.StackBehaviourPop); Debug.Assert((int)opc1.StackBehaviourPush == (int)opc2.StackBehaviourPush); Console.WriteLine("\t\tpublic static readonly OpCode {0} = new OpCode({1});", field.Name, Pack(opc1)); } Console.WriteLine(); Console.WriteLine("\t\tinternal static string GetName(int value)"); Console.WriteLine("\t\t{"); Console.WriteLine("\t\t\tswitch (value)"); Console.WriteLine("\t\t\t{"); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); Console.WriteLine("\t\t\t\t\treturn \"{0}\";", opc1.Name); } Console.WriteLine("\t\t\t}"); Console.WriteLine("\t\t\tthrow new ArgumentOutOfRangeException();"); Console.WriteLine("\t\t}"); Console.WriteLine(); Console.WriteLine("\t\tpublic static bool TakesSingleByteArgument(OpCode inst)"); Console.WriteLine("\t\t{"); Console.WriteLine("\t\t\tswitch (inst.Value)"); Console.WriteLine("\t\t\t{"); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); if (System.Reflection.Emit.OpCodes.TakesSingleByteArgument(opc1)) { Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); } } Console.WriteLine("\t\t\t\t\treturn true;"); Console.WriteLine("\t\t\t\tdefault:"); Console.WriteLine("\t\t\t\t\treturn false;"); Console.WriteLine("\t\t\t}"); Console.WriteLine("\t\t}"); }
static void Main(string[] args) { Debug.Assert(pop.Length == StackBehaviourPopCount); Debug.Assert(push.Length == StackBehaviourPushCount); CheckEnumRange(typeof(FlowControl), FlowControlCount); CheckEnumRange(typeof(OpCodeType), OpCodeTypeCount); CheckEnumRange(typeof(OperandType), OperandTypeCount); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); IKVM.Reflection.Emit.OpCode opc2 = new IKVM.Reflection.Emit.OpCode(Pack(opc1)); Debug.Assert(opc1.Value == opc2.Value); Debug.Assert(opc1.Size == opc2.Size); Debug.Assert((int)opc1.FlowControl == (int)opc2.FlowControl); Debug.Assert((int)opc1.OpCodeType == (int)opc2.OpCodeType); Debug.Assert((int)opc1.OperandType == (int)opc2.OperandType); Debug.Assert((int)opc1.StackBehaviourPop == (int)opc2.StackBehaviourPop); Debug.Assert((int)opc1.StackBehaviourPush == (int)opc2.StackBehaviourPush); Console.WriteLine("\t\tpublic static readonly OpCode {0} = new OpCode({1});", field.Name, Pack(opc1)); } Console.WriteLine(); Console.WriteLine("\t\tinternal static string GetName(int value)"); Console.WriteLine("\t\t{"); Console.WriteLine("\t\t\tswitch (value)"); Console.WriteLine("\t\t\t{"); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); Console.WriteLine("\t\t\t\t\treturn \"{0}\";", opc1.Name); } Console.WriteLine("\t\t\t}"); Console.WriteLine("\t\t\tthrow new ArgumentOutOfRangeException();"); Console.WriteLine("\t\t}"); Console.WriteLine(); Console.WriteLine("\t\tpublic static bool TakesSingleByteArgument(OpCode inst)"); Console.WriteLine("\t\t{"); Console.WriteLine("\t\t\tswitch (inst.Value)"); Console.WriteLine("\t\t\t{"); foreach (var field in typeof(System.Reflection.Emit.OpCodes).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { System.Reflection.Emit.OpCode opc1 = (System.Reflection.Emit.OpCode)field.GetValue(null); if (System.Reflection.Emit.OpCodes.TakesSingleByteArgument(opc1)) { Console.WriteLine("\t\t\t\tcase {0}:", opc1.Value); } } Console.WriteLine("\t\t\t\t\treturn true;"); Console.WriteLine("\t\t\t\tdefault:"); Console.WriteLine("\t\t\t\t\treturn false;"); Console.WriteLine("\t\t\t}"); Console.WriteLine("\t\t}"); }