public static bool FindOpcodeInfo(OpCount count, byte opnum, out OpcodeInfo result) { Dictionary <byte, OpcodeInfo> dict; switch (count) { case OpCount.Zero: dict = zeroOpInfos; break; case OpCount.One: dict = oneOpInfos; break; case OpCount.Two: dict = twoOpInfos; break; case OpCount.Var: dict = varOpInfos; break; case OpCount.Ext: dict = extOpInfos; break; default: throw new ArgumentOutOfRangeException("count"); } return(dict.TryGetValue(opnum, out result)); }
public static bool FindOpcodeInfo(OpCount count, byte opnum, byte zversion, out OpcodeInfo result) { Dictionary <byte, OpcodeInfo[]> dict; switch (count) { case OpCount.Zero: dict = zeroOpInfos; break; case OpCount.One: dict = oneOpInfos; break; case OpCount.Two: dict = twoOpInfos; break; case OpCount.Var: dict = varOpInfos; break; case OpCount.Ext: dict = extOpInfos; break; default: throw new ArgumentOutOfRangeException("count"); } OpcodeInfo[] array; if (dict.TryGetValue(opnum, out array)) { foreach (OpcodeInfo info in array) { if (zversion >= info.Attr.MinVersion && zversion <= info.Attr.MaxVersion) { result = info; return(true); } } } result = default(OpcodeInfo); return(false); }
private static void InitOpcodeTable() { MethodInfo[] mis = typeof(Opcode).GetMethods( BindingFlags.NonPublic | BindingFlags.Instance); foreach (MethodInfo mi in mis) { OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false); if (attrs.Length > 0) { OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate( typeof(OpcodeCompiler), null, mi); OpcodeAttribute a = attrs[0]; OpcodeInfo info = new OpcodeInfo(a, del); switch (a.OpCount) { case OpCount.Zero: zeroOpInfos.Add((byte)(a.Number - 176), info); break; case OpCount.One: oneOpInfos.Add((byte)(a.Number - 128), info); break; case OpCount.Two: twoOpInfos.Add(a.Number, info); break; case OpCount.Var: varOpInfos.Add((byte)(a.Number - 224), info); break; case OpCount.Ext: extOpInfos.Add(a.Number, info); break; } } } }
public static bool FindOpcodeInfo(OpCount count, byte opnum, out OpcodeInfo result) { Dictionary<byte, OpcodeInfo> dict; switch (count) { case OpCount.Zero: dict = zeroOpInfos; break; case OpCount.One: dict = oneOpInfos; break; case OpCount.Two: dict = twoOpInfos; break; case OpCount.Var: dict = varOpInfos; break; case OpCount.Ext: dict = extOpInfos; break; default: throw new ArgumentOutOfRangeException("count"); } return dict.TryGetValue(opnum, out result); }
private static void InitOpcodeTable() { MethodInfo[] mis = typeof(Opcode).GetMethods( BindingFlags.NonPublic|BindingFlags.Instance); foreach (MethodInfo mi in mis) { OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false); if (attrs.Length > 0) { OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate( typeof(OpcodeCompiler), null, mi); OpcodeAttribute a = attrs[0]; OpcodeInfo info = new OpcodeInfo(a, del); switch (a.OpCount) { case OpCount.Zero: zeroOpInfos.Add((byte)(a.Number - 176), info); break; case OpCount.One: oneOpInfos.Add((byte)(a.Number - 128), info); break; case OpCount.Two: twoOpInfos.Add(a.Number, info); break; case OpCount.Var: varOpInfos.Add((byte)(a.Number - 224), info); break; case OpCount.Ext: extOpInfos.Add(a.Number, info); break; } } } }
private static void InitOpcodeTable() { MethodInfo[] mis = typeof(Opcode).GetMethods( BindingFlags.NonPublic | BindingFlags.Instance); foreach (MethodInfo mi in mis) { OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false); if (attrs.Length > 0) { OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate( typeof(OpcodeCompiler), null, mi); foreach (OpcodeAttribute a in attrs) { OpcodeInfo info = new OpcodeInfo(a, del); byte num; Dictionary <byte, OpcodeInfo[]> dict; switch (a.OpCount) { case OpCount.Zero: dict = zeroOpInfos; num = (byte)(a.Number - 176); break; case OpCount.One: dict = oneOpInfos; num = (byte)(a.Number - 128); break; case OpCount.Two: dict = twoOpInfos; num = a.Number; break; case OpCount.Var: dict = varOpInfos; num = (byte)(a.Number - 224); break; case OpCount.Ext: dict = extOpInfos; num = a.Number; break; default: throw new Exception("BUG:BADOPCOUNT"); } OpcodeInfo[] array; if (dict.TryGetValue(num, out array) == false) { array = new OpcodeInfo[] { info }; dict.Add(num, array); } else { OpcodeInfo[] newArray = new OpcodeInfo[array.Length + 1]; Array.Copy(array, newArray, array.Length); newArray[newArray.Length - 1] = info; dict[num] = newArray; } } } } }