Exemplo n.º 1
0
        public static HighEscapePathTerminator Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, BinaryReader reader)
        {
            uint escapePath = reader.ReadUInt32();
            HighCfgNodeHandle cfgNode = cfgNodes[reader.ReadUInt32()];

            return new HighEscapePathTerminator(escapePath, cfgNode);
        }
Exemplo n.º 2
0
        public static HighRegion Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
        {
            uint numCfgNodes = reader.ReadUInt32();

            if (numCfgNodes == 0)
                throw new Exception("Region has no CFG nodes");

            HighCfgNodeHandle[] cfgNodes = new HighCfgNodeHandle[numCfgNodes];
            for (uint i = 0; i < numCfgNodes; i++)
                cfgNodes[i] = new HighCfgNodeHandle();

            for (uint i = 0; i < numCfgNodes; i++)
                cfgNodes[i].Value = HighCfgNode.Read(rpa, catalog, methodBody, cfgNodes, baseLocation, haveDebugInfo, reader);

            RegionPhiResolver phiResolver = new RegionPhiResolver(cfgNodes);
            for (uint i = 0; i < numCfgNodes; i++)
            {
                foreach (HighPhi phi in cfgNodes[i].Value.Phis)
                    phi.Resolve(phiResolver);
            }

            HighCfgNodeHandle entryNode = cfgNodes[0];

            if (entryNode.Value.Phis.Length != 0)
                throw new RpaLoadException("Region entry node has phis");

            return new HighRegion(entryNode);
        }
Exemplo n.º 3
0
        public static HighProtectedRegion Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
        {
            HighProtectedRegion region;

            RegionTypeEnum regionType = (RegionTypeEnum)reader.ReadByte();

            HighRegion tryRegion = HighRegion.Read(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);

            switch (regionType)
            {
                case RegionTypeEnum.TryCatch:
                    region = new HighTryCatchRegion(tryRegion);
                    break;
                case RegionTypeEnum.TryFault:
                    region = new HighTryFaultRegion(tryRegion);
                    break;
                case RegionTypeEnum.TryFinally:
                    region = new HighTryFinallyRegion(tryRegion);
                    break;
                default:
                    throw new Exception("Invalid protected region type");
            }

            region.ReadHandlers(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);

            return region;
        }
Exemplo n.º 4
0
        public static HighPhi Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, uint[] predecessors, BinaryReader reader)
        {
            HighSsaRegister dest = HighSsaRegister.ReadDestinationDef(rpa, catalog, reader);
            if (dest == null)
                throw new Rpa.RpaLoadException("Phi has no destination");

            HighUnresolvedPhiCollection unresolvedCollection = HighUnresolvedPhiCollection.Read(rpa, catalog, cfgNodes, predecessors, reader);

            return new HighPhi(dest, unresolvedCollection);
        }
Exemplo n.º 5
0
        protected override void ReadHandlers(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
        {
            uint numCatchHandlers = reader.ReadUInt32();
            m_catchHandlers = new HighCatchHandler[numCatchHandlers];

            for (uint i = 0; i < numCatchHandlers; i++)
            {
                HighCatchHandler hdl = new HighCatchHandler();
                hdl.Read(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);
                m_catchHandlers[i] = hdl;
            }
        }
Exemplo n.º 6
0
        public static HighEHCluster Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
        {
            uint numTerminators = reader.ReadUInt32();

            HighEscapePathTerminator[] escapePathTerminators = new HighEscapePathTerminator[numTerminators];
            for (uint i = 0; i < numTerminators; i++)
            {
                HighEscapePathTerminator terminator = HighEscapePathTerminator.Read(rpa, catalog, methodBody, cfgNodes, reader);
                escapePathTerminators[i] = terminator;
            }

            HighProtectedRegion protRegion = HighProtectedRegion.Read(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);

            return new HighEHCluster(protRegion, escapePathTerminators);
        }
Exemplo n.º 7
0
        public static HighCfgNode Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
        {
            uint numPredecessors = reader.ReadUInt32();
            uint numPhis = reader.ReadUInt32();
            uint numInstructions = reader.ReadUInt32();
            uint numConstants = reader.ReadUInt32();

            List<HighPhi> phis = new List<HighPhi>();
            List<HighInstruction> instructions = new List<HighInstruction>();
            List<HighSsaRegister> ssaRegisters = new List<HighSsaRegister>();
            List<uint> predecessors = new List<uint>();
            List<HighCfgNodeHandle> realPreds = new List<HighCfgNodeHandle>();

            // WARNING: SSA indexes from phis and constants must match CollectRegsFromNode
            for (uint i = 0; i < numPredecessors; i++)
            {
                uint predIndex = reader.ReadUInt32();
                predecessors.Add(predIndex);
                realPreds.Add(cfgNodes[predIndex]);
            }

            uint[] predecessorsArray = predecessors.ToArray();
            for (uint i = 0; i < numPhis; i++)
            {
                HighPhi phi = HighPhi.Read(rpa, catalog, methodBody, cfgNodes, predecessorsArray, reader);
                phis.Add(phi);

                ssaRegisters.Add(phi.Dest);
            }

            for (uint i = 0; i < numConstants; i++)
            {
                HighSsaRegister constant = HighSsaRegister.ReadConstant(rpa, catalog, reader);
                ssaRegisters.Add(constant);
            }

            if (numInstructions == 0)
                throw new RpaLoadException("Empty CFG node");

            for (uint i = 0; i < numInstructions; i++)
            {
                HighInstruction instr = HighInstruction.Read(rpa, catalog, methodBody, cfgNodes, ssaRegisters, baseLocation, haveDebugInfo, reader);
                instructions.Add(instr);
            }

            return new HighCfgNode(realPreds.ToArray(), phis.ToArray(), instructions.ToArray());
        }
Exemplo n.º 8
0
 public override void ReadHeader(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, List<HighSsaRegister> ssaRegisters, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
 {
 }
Exemplo n.º 9
0
 public void Read(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
 {
     m_catchType = catalog.GetTypeSpec(reader.ReadUInt32());
     m_region = HighRegion.Read(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);
 }
Exemplo n.º 10
0
 protected override void ReadHandlers(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
 {
     m_finallyRegion = HighRegion.Read(rpa, catalog, methodBody, baseLocation, haveDebugInfo, reader);
 }
Exemplo n.º 11
0
 public override void ReadHeader(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, List<HighSsaRegister> ssaRegisters, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
 {
     m_fieldIndex = reader.ReadUInt32();
     m_isStatic = reader.ReadBoolean();
 }
Exemplo n.º 12
0
 public override void ReadHeader(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, List<HighSsaRegister> ssaRegisters, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader)
 {
     m_conversionType = (NumConversionType)reader.ReadByte();
     m_destPrecision = reader.ReadUInt32();
     m_sourcePrecision = reader.ReadUInt32();
 }
Exemplo n.º 13
0
        public static HighMethodBody Read(TagRepository rpa, CatalogReader catalog, MethodDeclTag methodDecl, BinaryReader reader)
        {
            bool haveInstanceLocal = reader.ReadBoolean();
            uint numArgs = reader.ReadUInt32();
            uint numLocals = reader.ReadUInt32();
            bool haveDebugInfo = reader.ReadBoolean();

            HighLocal instanceLocal;

            if (haveInstanceLocal)
            {
                instanceLocal = new HighLocal();
                instanceLocal.Read(rpa, catalog, reader);
            }
            else
                instanceLocal = null;

            HighLocal[] args = new HighLocal[numArgs];
            HighLocal[] locals = new HighLocal[numLocals];

            for (uint i = 0; i < numArgs; i++)
            {
                HighLocal arg = new HighLocal();
                arg.Read(rpa, catalog, reader);
                args[i] = arg;
            }

            for (uint i = 0; i < numLocals; i++)
            {
                HighLocal local = new HighLocal();
                local.Read(rpa, catalog, reader);
                locals[i] = local;
            }

            HighMethodBodyParseContext parseContext = new HighMethodBodyParseContext(instanceLocal, args, locals);

            CodeLocationTag baseLocation = new CodeLocationTag(methodDecl, 0);

            HighRegion region = HighRegion.Read(rpa, catalog, parseContext, baseLocation, haveDebugInfo, reader);

            return new HighMethodBody(region, instanceLocal, args, locals, haveDebugInfo);
        }
Exemplo n.º 14
0
 protected abstract void ReadHandlers(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader);