internal bool IsInner(__ExceptionInfo exc) { int index = exc.m_currentCatch - 1; int num2 = this.m_currentCatch - 1; return((exc.m_catchEndAddr[index] < this.m_catchEndAddr[num2]) || ((exc.m_catchEndAddr[index] == this.m_catchEndAddr[num2]) && (exc.GetEndAddress() > this.GetEndAddress()))); }
// Token: 0x060049D4 RID: 18900 RVA: 0x0010AD44 File Offset: 0x00108F44 internal bool IsInner(__ExceptionInfo exc) { int num = exc.m_currentCatch - 1; int num2 = this.m_currentCatch - 1; return(exc.m_catchEndAddr[num] < this.m_catchEndAddr[num2] || (exc.m_catchEndAddr[num] == this.m_catchEndAddr[num2] && exc.GetEndAddress() > this.GetEndAddress())); }
public virtual void BeginFinallyBlock() { if (this.m_currExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo info = this.m_currExcStack[this.m_currExcStackCount - 1]; int currentState = info.GetCurrentState(); Label endLabel = info.GetEndLabel(); int endCatchAddr = 0; if (currentState != 0) { this.Emit(OpCodes.Leave, endLabel); endCatchAddr = this.m_length; } this.MarkLabel(endLabel); Label lbl = this.DefineLabel(); info.SetFinallyEndLabel(lbl); this.Emit(OpCodes.Leave, lbl); if (endCatchAddr == 0) { endCatchAddr = this.m_length; } info.MarkFinallyAddr(this.m_length, endCatchAddr); }
public override void BeginCatchBlock(Type exceptionType) { if (base.CurrExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo info = base.CurrExcStack[base.CurrExcStackCount - 1]; if (info.GetCurrentState() == 1) { if (exceptionType != null) { throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); } this.Emit(OpCodes.Endfilter); } else { if (exceptionType == null) { throw new ArgumentNullException("exceptionType"); } if (!exceptionType.GetType().IsRuntimeType) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } Label endLabel = info.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); base.UpdateStackSize(OpCodes.Nop, 1); } info.MarkCatchAddr(this.ILOffset, exceptionType); info.m_filterAddr[info.m_currentCatch - 1] = this.m_scope.GetTokenFor(exceptionType.TypeHandle); }
public virtual Label BeginExceptionBlock() { if (this.m_exceptions == null) { this.m_exceptions = new __ExceptionInfo[8]; } if (this.m_currExcStack == null) { this.m_currExcStack = new __ExceptionInfo[8]; } if (this.m_exceptionCount >= this.m_exceptions.Length) { this.m_exceptions = EnlargeArray(this.m_exceptions); } if (this.m_currExcStackCount >= this.m_currExcStack.Length) { this.m_currExcStack = EnlargeArray(this.m_currExcStack); } Label endLabel = this.DefineLabel(); __ExceptionInfo info = new __ExceptionInfo(this.m_length, endLabel); this.m_exceptions[this.m_exceptionCount++] = info; this.m_currExcStack[this.m_currExcStackCount++] = info; return(endLabel); }
public virtual void BeginCatchBlock(Type exceptionType) { if (this.m_currExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo info = this.m_currExcStack[this.m_currExcStackCount - 1]; if (info.GetCurrentState() == 1) { if (exceptionType != null) { throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); } this.Emit(OpCodes.Endfilter); } else { if (exceptionType == null) { throw new ArgumentNullException("exceptionType"); } Label endLabel = info.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); } info.MarkCatchAddr(this.m_length, exceptionType); }
static internal int CalculateNumberOfExceptions(__ExceptionInfo [] excp) { int num=0; if (excp==null) return 0; for (int i=0; i<excp.Length; i++) num+=excp[i].GetNumberOfCatches(); return num; }
// // // Exception related generation // // public override void BeginExceptFilterBlock() { // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (CurrExcStackCount == 0) { throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } __ExceptionInfo current = CurrExcStack ![CurrExcStackCount - 1];
public virtual void BeginFaultBlock() { if (this.m_currExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo info = this.m_currExcStack[this.m_currExcStackCount - 1]; Label endLabel = info.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); info.MarkFaultAddr(this.m_length); }
private static int CalculateNumberOfExceptions(__ExceptionInfo[] excp) { int num = 0; if (excp == null) { return 0; } for (int i = 0; i < excp.Length; i++) { num += excp[i].GetNumberOfCatches(); } return num; }
public override void BeginCatchBlock(Type exceptionType) { if (CurrExcStackCount == 0) { throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } Contract.EndContractBlock(); __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; RuntimeType rtType = exceptionType as RuntimeType; if (current.GetCurrentState() == __ExceptionInfo.State_Filter) { if (exceptionType != null) { throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType); } this.Emit(OpCodes.Endfilter); current.MarkCatchAddr(ILOffset, null); } else { // execute this branch if previous clause is Catch or Fault if (exceptionType == null) { throw new ArgumentNullException(nameof(exceptionType)); } if (rtType == null) { throw new ArgumentException(SR.Argument_MustBeRuntimeType); } Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); // if this is a catch block the exception will be pushed on the stack and we need to update the stack info UpdateStackSize(OpCodes.Nop, 1); current.MarkCatchAddr(ILOffset, exceptionType); // this is relying on too much implementation details of the base and so it's highly breaking // Need to have a more integrated story for exceptions current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType); } }
internal __ExceptionInfo[] GetExceptions() { if (this.m_currExcStackCount != 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_UnclosedExceptionBlock")); } if (this.m_exceptionCount == 0) { return(null); } __ExceptionInfo[] destinationArray = new __ExceptionInfo[this.m_exceptionCount]; Array.Copy(this.m_exceptions, destinationArray, this.m_exceptionCount); SortExceptions(destinationArray); return(destinationArray); }
public override void BeginCatchBlock(Type exceptionType) { if (m_currExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; if (current.GetCurrentState() == __ExceptionInfo.State_Filter) { if (exceptionType != null) { throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); } this.Emit(OpCodes.Endfilter); } else { // execute this branch if previous clause is Catch or Fault if (exceptionType == null) { throw new ArgumentNullException("exceptionType"); } if (exceptionType.GetType() != typeof(RuntimeType)) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); // if this is a catch block the exception will be pushed on the stack and we need to update the stack info UpdateStackSize(OpCodes.Nop, 1); } current.MarkCatchAddr(m_length, exceptionType); // this is relying on too much implementation details of the base and so it's highly breaking // Need to have a more integreted story for exceptions current.m_filterAddr[current.m_currentCatch - 1] = m_scope.GetTokenFor(exceptionType.TypeHandle); }
// // // Exception related generation // // public override void BeginExceptFilterBlock() { // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (CurrExcStackCount == 0) { throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; Label endLabel = current.GetEndLabel(); Emit(OpCodes.Leave, endLabel); UpdateStackSize(OpCodes.Nop, 1); current.MarkFilterAddr(ILOffset); }
private static void SortExceptions(__ExceptionInfo[] exceptions) { int length = exceptions.Length; for (int i = 0; i < length; i++) { int index = i; for (int j = i + 1; j < length; j++) { if (exceptions[index].IsInner(exceptions[j])) { index = j; } } __ExceptionInfo info = exceptions[i]; exceptions[i] = exceptions[index]; exceptions[index] = info; } }
public virtual void EndExceptionBlock() { if (this.m_currExcStackCount == 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); } __ExceptionInfo info = this.m_currExcStack[this.m_currExcStackCount - 1]; this.m_currExcStack[this.m_currExcStackCount - 1] = null; this.m_currExcStackCount--; Label endLabel = info.GetEndLabel(); switch (info.GetCurrentState()) { case 1: case 0: throw new InvalidOperationException(Environment.GetResourceString("Argument_BadExceptionCodeGen")); case 2: this.Emit(OpCodes.Leave, endLabel); break; case 3: case 4: this.Emit(OpCodes.Endfinally); break; } if (this.m_labelList[endLabel.GetLabelValue()] == -1) { this.MarkLabel(endLabel); } else { this.MarkLabel(info.GetFinallyEndLabel()); } info.Done(this.m_length); }
internal __ExceptionInfo[] GetExceptions() { __ExceptionInfo []temp; if (m_currExcStackCount != 0) { throw new NotSupportedException(Environment.GetResourceString(ResId.Argument_UnclosedExceptionBlock)); } if (m_exceptionCount == 0) { return null; } temp = new __ExceptionInfo[m_exceptionCount]; Array.Copy(m_exceptions, temp, m_exceptionCount); SortExceptions(temp); return temp; }
internal __ExceptionInfo[] GetExceptions() { if (this.m_currExcStackCount != 0) { throw new NotSupportedException(Environment.GetResourceString("Argument_UnclosedExceptionBlock")); } if (this.m_exceptionCount == 0) { return null; } __ExceptionInfo[] destinationArray = new __ExceptionInfo[this.m_exceptionCount]; Array.Copy(this.m_exceptions, destinationArray, this.m_exceptionCount); SortExceptions(destinationArray); return destinationArray; }
private static __ExceptionInfo[] EnlargeArray(__ExceptionInfo[] incoming) { __ExceptionInfo[] destinationArray = new __ExceptionInfo[incoming.Length * 2]; Array.Copy(incoming, destinationArray, incoming.Length); return destinationArray; }
public virtual Label BeginExceptionBlock() { if (this.m_exceptions == null) { this.m_exceptions = new __ExceptionInfo[8]; } if (this.m_currExcStack == null) { this.m_currExcStack = new __ExceptionInfo[8]; } if (this.m_exceptionCount >= this.m_exceptions.Length) { this.m_exceptions = EnlargeArray(this.m_exceptions); } if (this.m_currExcStackCount >= this.m_currExcStack.Length) { this.m_currExcStack = EnlargeArray(this.m_currExcStack); } Label endLabel = this.DefineLabel(); __ExceptionInfo info = new __ExceptionInfo(this.m_length, endLabel); this.m_exceptions[this.m_exceptionCount++] = info; this.m_currExcStack[this.m_currExcStackCount++] = info; return endLabel; }
private static __ExceptionInfo[] EnlargeArray(__ExceptionInfo[] incoming) { __ExceptionInfo[] destinationArray = new __ExceptionInfo[incoming.Length * 2]; Array.Copy(incoming, destinationArray, incoming.Length); return(destinationArray); }
private static __ExceptionInfo[] EnlargeArray(__ExceptionInfo[] incoming) { __ExceptionInfo[] temp = new __ExceptionInfo[incoming.Length*2]; Array.Copy(incoming, temp, incoming.Length); return temp; }
// Specifies whether exc is an inner exception for "this". The way // its determined is by comparing the end address for the last catch // clause for both exceptions. If they're the same, the start address // for the exception is compared. // WARNING: This is not a generic function to determine the innerness // of an exception. This is somewhat of a mis-nomer. This gives a // random result for cases where the two exceptions being compared do // not having a nesting relation. internal bool IsInner(__ExceptionInfo exc) { Contract.Requires(exc != null); Contract.Assert(m_currentCatch > 0,"m_currentCatch > 0"); Contract.Assert(exc.m_currentCatch > 0,"exc.m_currentCatch > 0"); int exclast = exc.m_currentCatch - 1; int last = m_currentCatch - 1; if (exc.m_catchEndAddr[exclast] < m_catchEndAddr[last]) return true; else if (exc.m_catchEndAddr[exclast] == m_catchEndAddr[last]) { Contract.Assert(exc.GetEndAddress() != GetEndAddress(), "exc.GetEndAddress() != GetEndAddress()"); if (exc.GetEndAddress() > GetEndAddress()) return true; } return false; }
// In order to call exceptions properly we have to sort them in ascending order by their end position. // Just a cheap insertion sort. We don't expect many exceptions (<10), where InsertionSort beats QuickSort. // If we have more exceptions that this in real life, we should consider moving to a QuickSort. internal virtual void SortExceptions(__ExceptionInfo []exceptions) { int least; __ExceptionInfo temp; int length = exceptions.Length; for (int i=0; i<length; i++) { least = i; for (int j=i+1; j<length; j++) { if (exceptions[least].IsInner(exceptions[j])) { least = j; } } temp = exceptions[i]; exceptions[i]=exceptions[least]; exceptions[least]=temp; } }
private static void SortExceptions(__ExceptionInfo []exceptions) { // In order to call exceptions properly we have to sort them in ascending order by their end position. // Just a cheap insertion sort. We don't expect many exceptions (<10), where InsertionSort beats QuickSort. // If we have more exceptions than this in real life, we should consider moving to a QuickSort. int least; __ExceptionInfo temp; int length = exceptions.Length; for (int i =0; i < length; i++) { least = i; for (int j =i + 1; j < length; j++) { if (exceptions[least].IsInner(exceptions[j])) { least = j; } } temp = exceptions[i]; exceptions[i] = exceptions[least]; exceptions[least] = temp; } }
// Begin an Exception block. Creating an Exception block records some information, // but does not actually emit any IL onto the stream. Exceptions should be created and // marked in the following form: // // Emit Some IL // BeginExceptionBlock // Emit the IL which should appear within the "try" block // BeginCatchBlock // Emit the IL which should appear within the "catch" block // Optional: BeginCatchBlock (this can be repeated an arbitrary number of times // EndExceptionBlock // /// <include file='doc\ILGenerator.uex' path='docs/doc[@for="ILGenerator.BeginExceptionBlock"]/*' /> public virtual Label BeginExceptionBlock() { // Delay init if (m_exceptions == null) { m_exceptions = new __ExceptionInfo[DefaultExceptionArraySize]; } if (m_currExcStack == null) { m_currExcStack = new __ExceptionInfo[DefaultExceptionArraySize]; } if (m_exceptionCount>=m_exceptions.Length) { m_exceptions=EnlargeArray(m_exceptions); } if (m_currExcStackCount>=m_currExcStack.Length) { m_currExcStack = EnlargeArray(m_currExcStack); } Label endLabel = DefineLabel(); __ExceptionInfo exceptionInfo = new __ExceptionInfo(m_length, endLabel); // add the exception to the tracking list m_exceptions[m_exceptionCount++] = exceptionInfo; // Make this exception the current active exception m_currExcStack[m_currExcStackCount++] = exceptionInfo; return endLabel; }
public virtual Label BeginExceptionBlock() { // Begin an Exception block. Creating an Exception block records some information, // but does not actually emit any IL onto the stream. Exceptions should be created and // marked in the following form: // // Emit Some IL // BeginExceptionBlock // Emit the IL which should appear within the "try" block // BeginCatchBlock // Emit the IL which should appear within the "catch" block // Optional: BeginCatchBlock (this can be repeated an arbitrary number of times // EndExceptionBlock // Delay init if (m_exceptions == null) { m_exceptions = new __ExceptionInfo[DefaultExceptionArraySize]; } if (m_currExcStack == null) { m_currExcStack = new __ExceptionInfo[DefaultExceptionArraySize]; } if (m_exceptionCount>=m_exceptions.Length) { m_exceptions=EnlargeArray(m_exceptions); } if (m_currExcStackCount>=m_currExcStack.Length) { m_currExcStack = EnlargeArray(m_currExcStack); } Label endLabel = DefineLabel(); __ExceptionInfo exceptionInfo = new __ExceptionInfo(m_length, endLabel); // add the exception to the tracking list m_exceptions[m_exceptionCount++] = exceptionInfo; // Make this exception the current active exception m_currExcStack[m_currExcStackCount++] = exceptionInfo; return endLabel; }
internal bool IsInner(__ExceptionInfo exc) { int index = exc.m_currentCatch - 1; int num2 = this.m_currentCatch - 1; return ((exc.m_catchEndAddr[index] < this.m_catchEndAddr[num2]) || ((exc.m_catchEndAddr[index] == this.m_catchEndAddr[num2]) && (exc.GetEndAddress() > this.GetEndAddress()))); }