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); }
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); }
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; }
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); }
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; } }
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); }
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()); }
public override void ReadHeader(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, HighCfgNodeHandle[] cfgNodes, List<HighSsaRegister> ssaRegisters, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader) { }
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); }
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); }
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(); }
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(); }
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); }
protected abstract void ReadHandlers(TagRepository rpa, CatalogReader catalog, HighMethodBodyParseContext methodBody, CodeLocationTag baseLocation, bool haveDebugInfo, BinaryReader reader);