Simple impl to MockRailsEngineContext.Url
[castle.git] / Tools / DynamicProxy / Castle.DynamicProxy / Builder / CodeBuilder / SimpleAST / ArgumentReference.cs
blob29820e6a52b1df3b58e962382094dc5328d394ed
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.Builder.CodeBuilder.SimpleAST
17 using System;
18 using System.Reflection.Emit;
20 /// <summary>
21 /// Summary description for ArgumentReference.
22 /// </summary>
23 [CLSCompliant(false)]
24 public class ArgumentReference : TypeReference
26 private int _position = -1;
28 public ArgumentReference( Type argumentType ) : base(argumentType)
32 internal int Position
34 get { return _position; }
35 set { _position = value; }
38 public override void LoadReference(ILGenerator gen)
40 if (Position == -1)
42 throw new ApplicationException("ArgumentReference unitialized");
44 switch(Position)
46 case 0:
47 gen.Emit(OpCodes.Ldarg_0);
48 break;
49 case 1:
50 gen.Emit(OpCodes.Ldarg_1);
51 break;
52 case 2:
53 gen.Emit(OpCodes.Ldarg_2);
54 break;
55 case 3:
56 gen.Emit(OpCodes.Ldarg_3);
57 break;
58 default:
59 gen.Emit(OpCodes.Ldarg, Position);
60 break;
64 public override void StoreReference(ILGenerator gen)
66 // Invalid operation
67 // We'd like to keep arguments read-only
68 throw new NotImplementedException();
71 public override void LoadAddressOfReference(ILGenerator gen)
73 throw new NotSupportedException();