testing commit notification
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy / Generators / Emitters / StindOpCodesDictionary.cs
blob5957f5905a96774e0957c4f24ef41ba99e643471
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.Collections;
19 using System.Reflection.Emit;
21 /// <summary>
22 /// Provides appropriate Stind.X opcode
23 /// for the type of primitive value to be stored indirectly.
24 /// </summary>
25 public sealed class StindOpCodesDictionary : DictionaryBase
27 private static readonly StindOpCodesDictionary _dict = new StindOpCodesDictionary();
29 private static readonly OpCode _emptyOpCode = new OpCode();
31 private StindOpCodesDictionary() : base()
33 Dictionary[typeof(bool)] = OpCodes.Stind_I1;
34 Dictionary[typeof(char)] = OpCodes.Stind_I2;
35 Dictionary[typeof(SByte)] = OpCodes.Stind_I1;
36 Dictionary[typeof(Int16)] = OpCodes.Stind_I2;
37 Dictionary[typeof(Int32)] = OpCodes.Stind_I4;
38 Dictionary[typeof(Int64)] = OpCodes.Stind_I8;
39 Dictionary[typeof(float)] = OpCodes.Stind_R4;
40 Dictionary[typeof(double)] = OpCodes.Stind_R8;
41 Dictionary[typeof(byte)] = OpCodes.Stind_I1;
42 Dictionary[typeof(UInt16)] = OpCodes.Stind_I2;
43 Dictionary[typeof(UInt32)] = OpCodes.Stind_I4;
44 Dictionary[typeof(UInt64)] = OpCodes.Stind_I8;
47 public OpCode this[Type type]
49 get
51 if (Dictionary.Contains(type))
53 return (OpCode) Dictionary[type];
55 return EmptyOpCode;
59 public static StindOpCodesDictionary Instance
61 get { return _dict; }
64 public static OpCode EmptyOpCode
66 get { return _emptyOpCode; }