2
Copyright (C) 2012 Jeroen Frijters
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
25
using System.Collections.Generic;
27
namespace IKVM.Reflection.Emit
29
public struct ExceptionHandler : IEquatable<ExceptionHandler>
31
private readonly int tryOffset;
32
private readonly int tryLength;
33
private readonly int filterOffset;
34
private readonly int handlerOffset;
35
private readonly int handlerLength;
36
private readonly ExceptionHandlingClauseOptions kind;
37
private readonly int exceptionTypeToken;
39
public ExceptionHandler(int tryOffset, int tryLength, int filterOffset, int handlerOffset, int handlerLength, ExceptionHandlingClauseOptions kind, int exceptionTypeToken)
41
if (tryOffset < 0 || tryLength < 0 || filterOffset < 0 || handlerOffset < 0 || handlerLength < 0)
43
throw new ArgumentOutOfRangeException();
45
this.tryOffset = tryOffset;
46
this.tryLength = tryLength;
47
this.filterOffset = filterOffset;
48
this.handlerOffset = handlerOffset;
49
this.handlerLength = handlerLength;
51
this.exceptionTypeToken = exceptionTypeToken;
56
get { return tryOffset; }
61
get { return tryLength; }
64
public int FilterOffset
66
get { return filterOffset; }
69
public int HandlerOffset
71
get { return handlerOffset; }
74
public int HandlerLength
76
get { return handlerLength; }
79
public ExceptionHandlingClauseOptions Kind
84
public int ExceptionTypeToken
86
get { return exceptionTypeToken; }
89
public bool Equals(ExceptionHandler other)
91
return tryOffset == other.tryOffset
92
&& tryLength == other.tryLength
93
&& filterOffset == other.filterOffset
94
&& handlerOffset == other.handlerOffset
95
&& handlerLength == other.handlerLength
97
&& exceptionTypeToken == other.exceptionTypeToken;
100
public override bool Equals(object obj)
102
ExceptionHandler? other = obj as ExceptionHandler?;
103
return other != null && Equals(other);
106
public override int GetHashCode()
108
return tryOffset ^ tryLength * 33 ^ filterOffset * 333 ^ handlerOffset * 3333 ^ handlerLength * 33333;
111
public static bool operator ==(ExceptionHandler left, ExceptionHandler right)
113
return left.Equals(right);
116
public static bool operator !=(ExceptionHandler left, ExceptionHandler right)
118
return !left.Equals(right);