Beispiel #1
0
        public void TycoUserSegmentedData()
        {
            var addrUserData = Address.SegPtr(0xC30, 0x0042);
            var addrSeg      = Address.SegPtr(0xC30, 0);
            var seg          = new ImageSegment("seg0C30", addrSeg, new ByteMemoryArea(addrSeg, new byte[0x100]), AccessMode.ReadWriteExecute);

            seg.Identifier = new Identifier("seg0C30", PrimitiveType.SegmentSelector, MemoryStorage.Instance);
            var program = new ProgramBuilder().BuildProgram();

            program.SegmentMap.AddSegment(seg);
            program.User = new UserData
            {
                Globals =
                {
                    {
                        addrUserData, new GlobalDataItem_v2
                        {
                            Name     = "myGlobal",
                            DataType = PrimitiveType_v1.Real32(),
                        }
                    }
                }
            };
            var eqb = new EquivalenceClassBuilder(program.TypeFactory, program.TypeStore, eventListener);

            eqb.EnsureSegmentTypeVariables(program.SegmentMap.Segments.Values);
            var tyco = Given_TypeCollector(program);

            tyco.CollectUserGlobalVariableTypes();

            Assert.AreEqual("42: myGlobal: real32", program.TypeStore.SegmentTypes[seg].Fields.First().ToString());
        }
 public void EqSegmentConstantsWithAllocatedSegment()
 {
     var tmp = new TemporaryStorage("seg1234", 0, PrimitiveType.SegmentSelector);
     var segment = new ImageSegment(
             "seg1234",
             new ByteMemoryArea(Address.SegPtr(0x1234, 0), new byte[100]),
             AccessMode.ReadWriteExecute)
     {
         Identifier = new Identifier(tmp.Name, PrimitiveType.SegmentSelector, tmp)
     };
     eqb.EnsureSegmentTypeVariables(new[] { segment });
     Constant seg1 = Constant.Create(PrimitiveType.SegmentSelector, 0x1234);
     seg1.Accept(eqb);
     Assert.AreSame(seg1.TypeVariable.Class, segment.Identifier.TypeVariable.Class);
 }