SharpDisasm.Tests/OpTableGeneration.cs
/// <summary>
/// Merge sse tables with only one entry for /sse=none
/// </summary>
Merge sse tables with only one entry for /sse=none
Merge sse tables with only one entry for / sse = none
private void MergeSSENone()
            {
                foreach (var table in _tables)
                {
                    List<string> keys = new List<String>();
                    List<object> sse = new List<object>();
                    foreach (var kv in table.Entries)
                    {
                        var e = kv.Value as UdOpcodeTable;
                        if (e != null && e.Type == "/sse")
                        {
                            if (e.NumEntries == 1)
                            {
                                var sseTbl = e.Lookup("/sse=none");
                                if (sseTbl != null)
                                {
                                    sse.Add(sseTbl);
                                    keys.Add(kv.Key);
                                }
                            }
                        }
                    }
                    for (var i = 0; i < keys.Count; i++)
                    {
                        table.Entries[keys[i]] = sse[i];
                    }
                }
                List<UdOpcodeTable> uniqTables = new List<UdOpcodeTable>();
                Action<UdOpcodeTable> genTableList = null;
                genTableList = (tbl) =>
                {
                    if (!uniqTables.Contains(tbl))
                    {
                        _tables.Add(tbl);
                    }
                    uniqTables.Add(tbl);
                    var keys = tbl.Entries.Keys.OrderBy(k => Int32.Parse(k, System.Globalization.NumberStyles.HexNumber)).ToArray();
                    foreach (var k in keys)
                    {
                        var e = tbl.Entries[k] as UdOpcodeTable;
                        if (e != null)
                            genTableList(e);
                    }
                };
                _tables = new List<UdOpcodeTable>();
                genTableList(Root);
            }
private void MergeSSENone ( ) { foreach ( var table in _tables ) { List < string > keys = new List < String > ( ) ; List < object > sse = new List < object > ( ) ; foreach ( var kv in table . Entries ) { var e = kv . Value as UdOpcodeTable ; if ( e != null && e . Type == " " ) { if ( e . NumEntries == 1 ) { var sseTbl = e . Lookup ( " " ) ; if ( sseTbl != null ) { sse . Add ( sseTbl ) ; keys . Add ( kv . Key ) ; } } } } for ( var i = 0 ; i < keys . Count ; i ++ ) { table . Entries [ keys [ i ] ] = sse [ i ] ; } } List < UdOpcodeTable > uniqTables = new List < UdOpcodeTable > ( ) ; Action < UdOpcodeTable > genTableList = null ; genTableList = ( tbl ) => { if ( ! uniqTables . Contains ( tbl ) ) { _tables . Add ( tbl ) ; } uniqTables . Add ( tbl ) ; var keys = tbl . Entries . Keys . OrderBy ( k => Int32 . Parse ( k , System . Globalization . NumberStyles . HexNumber ) ) . ToArray ( ) ; foreach ( var k in keys ) { var e = tbl . Entries [ k ] as UdOpcodeTable ; if ( e != null ) genTableList ( e ) ; } } ; _tables = new List < UdOpcodeTable > ( ) ; genTableList ( Root ) ; }
Merge sse tables with only one entry for /sse=none
Merge sse tables with only one entry for / sse = none