Ejemplo n.º 1
0
 public ModuleDescriptor(ModuleDescriptor other)
 {
     this.ModuleName = other.ModuleName;
     this.ServicesByName = new Dictionary<string, SystemService>(other.ServicesByName);
     this.ServicesByVector = new Dictionary<int, SystemService>(other.ServicesByVector);
     this.GlobalsByName = new Dictionary<string, DataType>();
     this.GlobalsByOrdinal = new Dictionary<int, DataType>();
 }
Ejemplo n.º 2
0
        public void Impres_ProcedureByName()
        {
            var proj = new Project
            {
                MetadataFiles = 
                {
                    new MetadataFile
                    {
                         ModuleName = "foo"
                    }
                },
                Programs =
                {
                    program
                }
            };

            var module = new ModuleDescriptor("foo")
            {
                ServicesByName =
                {
                    {
                        "bar@4",
                         new SystemService
                         {
                            Name = "bar",
                            Signature = new ProcedureSignature()
                         }
                    }
                }
            };

            mockFactory.Given_UserDefinedMetafile("foo", null, null, module);

            var impres = new ImportResolver(proj);
            var ep = impres.ResolveProcedure("foo", "bar@4", platform);
            Assert.AreEqual("bar", ep.Name);
        }
Ejemplo n.º 3
0
        public void Impres_ProcedureByName()
        {
            var proj = new Project
            {
                MetadataFiles = 
                {
                    new MetadataFile
                    {
                         ModuleName = "foo"
                    }
                },
                Programs =
                {
                    program
                }
            };

            var module = new ModuleDescriptor("foo")
            {
                ServicesByName =
                {
                    {
                        "bar@4",
                         new SystemService
                         {
                            Name = "bar",
                            Signature = new FunctionType()
                         }
                    }
                }
            };
            program.EnvironmentMetadata.Modules.Add("foo", module);

            var impres = new ImportResolver(proj, program, new FakeDecompilerEventListener());
            var ep = impres.ResolveProcedure("foo", "bar@4", platform);
            Assert.AreEqual("bar", ep.Name);
        }
Ejemplo n.º 4
0
 public ModuleDescriptor(ModuleDescriptor other)
 {
     this.ModuleName       = other.ModuleName;
     this.ServicesByName   = new Dictionary <string, SystemService>(other.ServicesByName);
     this.ServicesByVector = new Dictionary <int, SystemService>(other.ServicesByVector);
 }
Ejemplo n.º 5
0
        public void Given_UserDefinedMetafile(
            string moduleName, Dictionary<string, DataType> types,
            Dictionary<string, ProcedureSignature> signatures,
            ModuleDescriptor module)
        {
            if (types == null)
                types = new Dictionary<string, DataType>();
            if (signatures == null)
                signatures = new Dictionary<string, ProcedureSignature>();
            var loaderMetadata = new TypeLibrary(types, signatures);
            if (module != null)
                loaderMetadata.Modules.Add(moduleName, module);

            var loader = CreateLoader();

            var metafileName = moduleName+".xml";

            CreateLoadMetadataStub(metafileName, platform, loaderMetadata);

            foreach(var program in programs)
            {
                program.LoadMetadataFile(loader, metafileName);
            }
        }
Ejemplo n.º 6
0
 public ModuleDescriptor(ModuleDescriptor other)
 {
     this.ModuleName = other.ModuleName;
     this.ServicesByName = new Dictionary<string, SystemService>(other.ServicesByName);
     this.ServicesByVector = new Dictionary<int, SystemService>(other.ServicesByVector);
 }
Ejemplo n.º 7
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());
        }