Fix null sessions in HttpContextWrapper.Session
[mono.git] / mcs / class / IKVM.Reflection / ExceptionHandlingClause.cs
1 /*
2   Copyright (C) 2009 Jeroen Frijters
3
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.
7
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:
11
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.
19
20   Jeroen Frijters
21   jeroen@frijters.net
22   
23 */
24 using System;
25 using IKVM.Reflection.Reader;
26
27 namespace IKVM.Reflection
28 {
29         [Flags]
30         public enum ExceptionHandlingClauseOptions
31         {
32                 Clause  = 0x0000,
33                 Filter  = 0x0001,
34                 Finally = 0x0002,
35                 Fault   = 0x0004,
36         }
37
38         public sealed class ExceptionHandlingClause
39         {
40                 private readonly int flags;
41                 private readonly int tryOffset;
42                 private readonly int tryLength;
43                 private readonly int handlerOffset;
44                 private readonly int handlerLength;
45                 private readonly Type catchType;
46                 private readonly int filterOffset;
47
48                 internal ExceptionHandlingClause(ModuleReader module, int flags, int tryOffset, int tryLength, int handlerOffset, int handlerLength, int classTokenOrfilterOffset, IGenericContext context)
49                 {
50                         this.flags = flags;
51                         this.tryOffset = tryOffset;
52                         this.tryLength = tryLength;
53                         this.handlerOffset = handlerOffset;
54                         this.handlerLength = handlerLength;
55                         this.catchType = flags == (int)ExceptionHandlingClauseOptions.Clause && classTokenOrfilterOffset != 0 ? module.ResolveType(classTokenOrfilterOffset, context) : null;
56                         this.filterOffset = flags == (int)ExceptionHandlingClauseOptions.Filter ? classTokenOrfilterOffset : 0;
57                 }
58
59                 public Type CatchType
60                 {
61                         get { return catchType; }
62                 }
63
64                 public int FilterOffset
65                 {
66                         get { return filterOffset; }
67                 }
68
69                 public ExceptionHandlingClauseOptions Flags
70                 {
71                         get { return (ExceptionHandlingClauseOptions)flags; }
72                 }
73
74                 public int HandlerLength
75                 {
76                         get { return handlerLength; }
77                 }
78
79                 public int HandlerOffset
80                 {
81                         get { return handlerOffset; }
82                 }
83
84                 public int TryLength
85                 {
86                         get { return tryLength; }
87                 }
88
89                 public int TryOffset
90                 {
91                         get { return tryOffset; }
92                 }
93         }
94 }