Reko.Core.ImportResolver.ResolveGlobal C# (CSharp) Méthode

ResolveGlobal() public méthode

public ResolveGlobal ( string moduleName, int ordinal, IPlatform platform ) : Identifier
moduleName string
ordinal int
platform IPlatform
Résultat Identifier
        public Identifier ResolveGlobal(string moduleName, int ordinal, IPlatform platform)
        {
            foreach (var program in project.Programs)
            {
                ModuleDescriptor mod;
                if (!program.EnvironmentMetadata.Modules.TryGetValue(moduleName, out mod))
                    continue;

                DataType dt;
                if (mod.GlobalsByOrdinal.TryGetValue(ordinal, out dt))
                {
                    return new Identifier("ExportedGlobal_" + ordinal, dt, new MemoryStorage());
                }
            }

            return platform.LookupGlobalByOrdinal(moduleName, ordinal);
        }

Same methods

ImportResolver::ResolveGlobal ( string moduleName, string globalName, IPlatform platform ) : Identifier

Usage Example

Exemple #1
0
        public void Impres_GlobalByName()
        {
            var proj = new Project
            {
                MetadataFiles =
                {
                    new MetadataFile
                    {
                         ModuleName = "foo"
                    }
                },
                Programs =
                {
                    program
                }
            };

            var module = new ModuleDescriptor("foo")
            {
                GlobalsByName =
                {
                    {
                         "bar",
                         new StructureType
                         {
                             Fields =
                             {
                                 { 0, new Pointer(PrimitiveType.Char, 4), "name" },
                                 { 4, PrimitiveType.Int32, "age" }
                             }
                         }
                    }
                }
            };
            program.EnvironmentMetadata.Modules.Add(module.ModuleName, module);

            var impres = new ImportResolver(proj, program, new FakeDecompilerEventListener());
            var dt = impres.ResolveGlobal("foo", "bar", platform);
            Assert.AreEqual("bar", dt.ToString());
        }