private bool LookupInImportExportOrdinals <TType>(
            Func <ImportExportOrdinals, ReadOnlyDictionary <TType, uint> > getOrdinalDictionary,
            TType lookup,
            MrtImportNode node)
        {
            uint ordinal = 0;
            MrtProcessedImportAddressTableNode importTable = null;

            foreach (KeyValuePair <MrtProcessedImportAddressTableNode, ImportExportOrdinals> ordinalGroup in _importOrdinals)
            {
                if (getOrdinalDictionary(ordinalGroup.Value).TryGetValue(lookup, out ordinal))
                {
                    importTable = ordinalGroup.Key;
                    break;
                }
            }

            if (importTable == null)
            {
                throw new ArgumentException();
            }

            node.InitializeImport(importTable, (int)ordinal);
            return(true);
        }
Ejemplo n.º 2
0
 public void InitializeImport(MrtProcessedImportAddressTableNode importTable, int ordinal)
 {
     Debug.Assert(_importTable == null);
     Debug.Assert(importTable != null);
     Ordinal      = ordinal;
     _importTable = importTable;
 }
        public MrtImportImportedNodeProvider(TypeSystemContext context, KeyValuePair <string, ImportExportOrdinals>[] ordinals)
        {
            Dictionary <string, MrtProcessedImportAddressTableNode> importAddressTables = new Dictionary <string, MrtProcessedImportAddressTableNode>();

            _importOrdinals = new KeyValuePair <MrtProcessedImportAddressTableNode, ImportExportOrdinals> [ordinals.Length];

            for (int i = 0; i < ordinals.Length; i++)
            {
                string symbolName = "__imp_" + ordinals[i].Key + "ExportAddressTable";
                MrtProcessedImportAddressTableNode importTable = null;
                if (!importAddressTables.TryGetValue(symbolName, out importTable))
                {
                    importTable = new MrtProcessedImportAddressTableNode(symbolName, context);
                    importAddressTables.Add(symbolName, importTable);
                }

                _importOrdinals[i] = new KeyValuePair <MrtProcessedImportAddressTableNode, ImportExportOrdinals>(importTable, ordinals[i].Value);
            }
        }