1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.DynamicProxy
.Generators
.Emitters
18 using System
.Collections
;
19 using System
.Reflection
.Emit
;
22 /// Provides appropriate Ldind.X opcode for
23 /// the type of primitive value to be loaded indirectly.
25 public sealed class LdindOpCodesDictionary
: DictionaryBase
27 private static readonly LdindOpCodesDictionary _dict
= new LdindOpCodesDictionary();
29 private static readonly OpCode _emptyOpCode
= new OpCode();
31 private LdindOpCodesDictionary() : base()
33 Dictionary
[typeof(bool)] = OpCodes
.Ldind_I1
;
34 Dictionary
[typeof(char)] = OpCodes
.Ldind_I2
;
35 Dictionary
[typeof(SByte
)] = OpCodes
.Ldind_I1
;
36 Dictionary
[typeof(Int16
)] = OpCodes
.Ldind_I2
;
37 Dictionary
[typeof(Int32
)] = OpCodes
.Ldind_I4
;
38 Dictionary
[typeof(Int64
)] = OpCodes
.Ldind_I8
;
39 Dictionary
[typeof(float)] = OpCodes
.Ldind_R4
;
40 Dictionary
[typeof(double)] = OpCodes
.Ldind_R8
;
41 Dictionary
[typeof(byte)] = OpCodes
.Ldind_U1
;
42 Dictionary
[typeof(UInt16
)] = OpCodes
.Ldind_U2
;
43 Dictionary
[typeof(UInt32
)] = OpCodes
.Ldind_U4
;
44 Dictionary
[typeof(UInt64
)] = OpCodes
.Ldind_I8
;
47 public OpCode
this[Type type
]
51 if (Dictionary
.Contains(type
))
53 return (OpCode
) Dictionary
[type
];
59 public static LdindOpCodesDictionary Instance
64 public static OpCode EmptyOpCode
66 get { return _emptyOpCode; }