/// <summary> /// Mark this position as the end of the last started block and /// make it a catch block. This catch block is associated with the /// specified try block. /// </summary> /// <param name="exceptType">the exception type to be caught</param> /// <param name="tryBlock">the try block associated with this catch block</param> public void EndCatchBlock(Class exceptType, TryBlock tryBlock) { Catch catchBlock = new Catch(exceptType, (CILLabel)blockStack[0], NewCodedLabel()); tryBlock.AddHandler(catchBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a try block. This try block is added to the current /// instructions (ie do not need to call AddTryBlock) /// </summary> /// <returns>The try block just ended</returns> public TryBlock EndTryBlock() { TryBlock tBlock = new TryBlock((CILLabel)blockStack[0], NewCodedLabel()); blockStack.RemoveAt(0); AddTryBlock(tBlock); return(tBlock); }
public void AddTryBlock(TryBlock tryBlock) { if (exceptions == null) { exceptions = new ArrayList(); } else if (exceptions.Contains(tryBlock)) { return; } exceptions.Add(tryBlock); tryBlock.ResolveCatchBlocks(metaData); }
internal void Write(FileImage output) { // Console.WriteLine("Writing header flags = " + Hex.Short(headerFlags)); if (tinyFormat) { // Console.WriteLine("Writing tiny code"); output.Write((byte)headerFlags); } else { // Console.WriteLine("Writing fat code"); output.Write(headerFlags); output.Write((ushort)maxStack); output.Write(offset); output.Write(localSigIx); } // Console.WriteLine(Hex.Int(tide) + " CIL instructions"); // Console.WriteLine("starting instructions at " + output.Seek(0,SeekOrigin.Current)); for (int i = 0; i < tide; i++) { buffer[i].Write(output); } // Console.WriteLine("ending instructions at " + output.Seek(0,SeekOrigin.Current)); for (int i = 0; i < paddingNeeded; i++) { output.Write((byte)0); } if (exceptions != null) { // Console.WriteLine("Writing exceptions"); // Console.WriteLine("header = " + Hex.Short(exceptHeader) + " exceptSize = " + Hex.Int(exceptSize)); output.Write(exceptHeader); output.Write3Bytes((uint)exceptSize); for (int i = 0; i < exceptions.Count; i++) { TryBlock tryBlock = (TryBlock)exceptions[i]; tryBlock.Write(output, fatExceptionFormat); } } }
/// <summary> /// Mark this position as the end of the last started block and /// make it a fault block. This fault block is associated with the /// specified try block. /// </summary> /// <param name="tryBlock">the try block associated with this fault block</param> public void EndFaultBlock(TryBlock tryBlock) { Fault fBlock= new Fault((CILLabel)blockStack[0],NewCodedLabel()); tryBlock.AddHandler(fBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a finally block. This finally block is associated with the /// specified try block. /// </summary> /// <param name="tryBlock">the try block associated with this finally block</param> public void EndFinallyBlock(TryBlock tryBlock) { Finally finBlock= new Finally((CILLabel)blockStack[0],NewCodedLabel()); tryBlock.AddHandler(finBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a filter block. This filter block is associated with the /// specified try block. /// </summary> /// <param name="filterLab">the label where the filter code is</param> /// <param name="tryBlock">the try block associated with this filter block</param> public void EndFilterBlock(CILLabel filterLab, TryBlock tryBlock) { Filter filBlock = new Filter(filterLab,(CILLabel)blockStack[0],NewCodedLabel()); tryBlock.AddHandler(filBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a catch block. This catch block is associated with the /// specified try block. /// </summary> /// <param name="exceptType">the exception type to be caught</param> /// <param name="tryBlock">the try block associated with this catch block</param> public void EndCatchBlock(Class exceptType, TryBlock tryBlock) { Catch catchBlock = new Catch(exceptType,(CILLabel)blockStack[0], NewCodedLabel()); tryBlock.AddHandler(catchBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a try block. This try block is added to the current /// instructions (ie do not need to call AddTryBlock) /// </summary> /// <returns>The try block just ended</returns> public TryBlock EndTryBlock() { TryBlock tBlock = new TryBlock((CILLabel)blockStack[0],NewCodedLabel()); blockStack.RemoveAt(0); AddTryBlock(tBlock); return tBlock; }
public void AddTryBlock(TryBlock tryBlock) { if (exceptions == null) exceptions = new ArrayList(); else if (exceptions.Contains(tryBlock)) return; exceptions.Add(tryBlock); tryBlock.ResolveCatchBlocks (metaData); }
public void AddTryBlock(TryBlock tryBlock) { if (exceptions == null) exceptions = new ArrayList(); else if (exceptions.Contains(tryBlock)) return; exceptions.Add(tryBlock); }
internal void CheckCode(uint locSigIx, bool initLocals, int maxStack) { if (tide == 0) { return; } bool changed = true; while (changed) { changed = false; for (int i = 0; i < tide; i++) { changed = buffer[i].Check(metaData) || changed; } if (changed) { for (int i = 1; i < tide; i++) { buffer[i].offset = buffer[i - 1].offset + buffer[i - 1].size; } offset = buffer[tide - 1].offset + buffer[tide - 1].size; } } codeSize = offset; // Console.WriteLine("codeSize before header added = " + codeSize); if ((offset < smallSize) && (maxStack <= 8) && (locSigIx == 0) && (exceptions == null)) { // can use tiny header //Console.WriteLine("Tiny Header"); tinyFormat = true; headerFlags = (ushort)(TinyFormat | ((ushort)codeSize << 2)); codeSize++; if ((codeSize % 4) != 0) { paddingNeeded = 4 - (codeSize % 4); } } else { //Console.WriteLine("Fat Header"); tinyFormat = false; localSigIx = locSigIx; this.maxStack = (short)maxStack; headerFlags = FatFormat; if (exceptions != null) { // Console.WriteLine("Got exceptions"); headerFlags |= MoreSects; uint numExceptClauses = 0; for (int i = 0; i < exceptions.Count; i++) { TryBlock tryBlock = (TryBlock)exceptions[i]; tryBlock.SetSize(); numExceptClauses += (uint)tryBlock.NumHandlers(); if (tryBlock.isFat()) { fatExceptionFormat = true; } } uint data_size = ExHeaderSize + numExceptClauses * (fatExceptionFormat ? FatExClauseSize : SmlExClauseSize); if (data_size > 255) { fatExceptionFormat = true; } // Console.WriteLine("numexceptclauses = " + numExceptClauses); if (fatExceptionFormat) { // Console.WriteLine("Fat exception format"); exceptHeader = FatExceptTable; exceptSize = ExHeaderSize + numExceptClauses * FatExClauseSize; } else { // Console.WriteLine("Tiny exception format"); exceptHeader = SmlExceptTable; exceptSize = ExHeaderSize + numExceptClauses * SmlExClauseSize; } // Console.WriteLine("exceptSize = " + exceptSize); } if (initLocals) { headerFlags |= InitLocals; } if ((offset % 4) != 0) { paddingNeeded = 4 - (offset % 4); } codeSize += FatSize; } // Console.WriteLine("codeSize = " + codeSize + " headerFlags = " + // Hex.Short(headerFlags)); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a fault block. This fault block is associated with the /// specified try block. /// </summary> /// <param name="tryBlock">the try block associated with this fault block</param> public void EndFaultBlock(TryBlock tryBlock) { Fault fBlock = new Fault((CILLabel)blockStack[0], NewCodedLabel()); tryBlock.AddHandler(fBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a finally block. This finally block is associated with the /// specified try block. /// </summary> /// <param name="tryBlock">the try block associated with this finally block</param> public void EndFinallyBlock(TryBlock tryBlock) { Finally finBlock = new Finally((CILLabel)blockStack[0], NewCodedLabel()); tryBlock.AddHandler(finBlock); }
/// <summary> /// Mark this position as the end of the last started block and /// make it a filter block. This filter block is associated with the /// specified try block. /// </summary> /// <param name="filterLab">the label where the filter code is</param> /// <param name="tryBlock">the try block associated with this filter block</param> public void EndFilterBlock(CILLabel filterLab, TryBlock tryBlock) { Filter filBlock = new Filter(filterLab, (CILLabel)blockStack[0], NewCodedLabel()); tryBlock.AddHandler(filBlock); }