SharpDisasm.Tests/OpTableGeneration.cs
/// <summary>
/// Create a mapping from a given array of opcodes to an object in
/// the opcode tree. Constructs tree branches as needed.
/// </summary>
/// <param name="tbl"></param>
/// <param name="opcodes"></param>
/// <param name="obj"></param>
Create a mapping from a given array of opcodes to an object in
the opcode tree. Constructs tree branches as needed.
Create a mapping from a given array of opcodes to an object in the opcode tree . Constructs tree branches as needed .
private void Map(UdOpcodeTable tbl, string[] opcodes, object obj)
            {
                var opc = opcodes[0];
                var e = tbl.Lookup(opc);
                if (e == null)
                    tbl.Add(opc, MakeTree(opcodes.Skip(1).ToArray(), obj));
                else
                {
                    if (opcodes.Length <= 1 || !(e is UdOpcodeTable))
                        throw new CollisionException();
                    Map((UdOpcodeTable)e, opcodes.Skip(1).ToArray(), obj);
                }
            }
private void Map ( UdOpcodeTable tbl , string [ ] opcodes , object obj ) { var opc = opcodes [ 0 ] ; var e = tbl . Lookup ( opc ) ; if ( e == null ) tbl . Add ( opc , MakeTree ( opcodes . Skip ( 1 ) . ToArray ( ) , obj ) ) ; else { if ( opcodes . Length <= 1 || ! ( e is UdOpcodeTable ) ) throw new CollisionException ( ) ; Map ( ( UdOpcodeTable ) e , opcodes . Skip ( 1 ) . ToArray ( ) , obj ) ; } }
Create a mapping from a given array of opcodes to an object in
the opcode tree.
Create a mapping from a given array of opcodes to an object in the opcode tree .
tbl
UdOpcodeTable
None
opcodes
string[]
None
obj
object
None