1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Apache License, Version 2.0, please send an email to
8 * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Apache License, Version 2.0.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
16 using System.Linq.Expressions;
18 using Microsoft.Scripting.Ast;
22 using System.Collections.Generic;
23 using System.Diagnostics;
24 using System.Reflection;
25 using System.Threading;
26 using Microsoft.Scripting.Utils;
27 using Microsoft.Scripting.Generation;
28 using Microsoft.Scripting.Runtime;
32 namespace Microsoft.Scripting.Interpreter {
33 #region Generated Reflected Caller
35 // *** BEGIN GENERATED CODE ***
36 // generated by function: gen_all from: generate_reflected_calls.py
38 public partial class CallInstruction {
39 private const int MaxHelpers = 10;
40 private const int MaxArgs = 3;
42 public virtual object InvokeInstance(object instance, params object[] args) {
44 case 0: return Invoke(instance);
45 case 1: return Invoke(instance, args[0]);
46 case 2: return Invoke(instance, args[0], args[1]);
47 case 3: return Invoke(instance, args[0], args[1], args[2]);
48 case 4: return Invoke(instance, args[0], args[1], args[2], args[3]);
49 case 5: return Invoke(instance, args[0], args[1], args[2], args[3], args[4]);
50 case 6: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5]);
51 case 7: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
52 case 8: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
53 default: throw new InvalidOperationException();
57 public virtual object Invoke(params object[] args) {
59 case 0: return Invoke();
60 case 1: return Invoke(args[0]);
61 case 2: return Invoke(args[0], args[1]);
62 case 3: return Invoke(args[0], args[1], args[2]);
63 case 4: return Invoke(args[0], args[1], args[2], args[3]);
64 case 5: return Invoke(args[0], args[1], args[2], args[3], args[4]);
65 case 6: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5]);
66 case 7: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
67 case 8: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
68 case 9: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
69 default: throw new InvalidOperationException();
73 public virtual object Invoke() { throw new InvalidOperationException(); }
74 public virtual object Invoke(object arg0) { throw new InvalidOperationException(); }
75 public virtual object Invoke(object arg0, object arg1) { throw new InvalidOperationException(); }
76 public virtual object Invoke(object arg0, object arg1, object arg2) { throw new InvalidOperationException(); }
77 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3) { throw new InvalidOperationException(); }
78 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) { throw new InvalidOperationException(); }
79 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) { throw new InvalidOperationException(); }
80 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) { throw new InvalidOperationException(); }
81 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) { throw new InvalidOperationException(); }
82 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) { throw new InvalidOperationException(); }
85 /// Fast creation works if we have a known primitive types for the entire
86 /// method siganture. If we have any non-primitive types then FastCreate
87 /// falls back to SlowCreate which works for all types.
89 /// Fast creation is fast because it avoids using reflection (MakeGenericType
90 /// and Activator.CreateInstance) to create the types. It does this through
91 /// calling a series of generic methods picking up each strong type of the
92 /// signature along the way. When it runs out of types it news up the
93 /// appropriate CallInstruction with the strong-types that have been built up.
95 /// One relaxation is that for return types which are non-primitive types
96 /// we can fallback to object due to relaxed delegates.
98 private static CallInstruction FastCreate(MethodInfo target, ParameterInfo[] pi) {
99 Type t = TryGetParameterOrReturnType(target, pi, 0);
101 return new ActionCallInstruction(target);
104 if (t.IsEnum()) return SlowCreate(target, pi);
105 switch (t.GetTypeCode()) {
106 case TypeCode.Object: {
107 if (t != typeof(object) && (IndexIsNotReturnType(0, target, pi) || t.IsValueType())) {
108 // if we're on the return type relaxed delegates makes it ok to use object
111 return FastCreate<Object>(target, pi);
113 case TypeCode.Int16: return FastCreate<Int16>(target, pi);
114 case TypeCode.Int32: return FastCreate<Int32>(target, pi);
115 case TypeCode.Int64: return FastCreate<Int64>(target, pi);
116 case TypeCode.Boolean: return FastCreate<Boolean>(target, pi);
117 case TypeCode.Char: return FastCreate<Char>(target, pi);
118 case TypeCode.Byte: return FastCreate<Byte>(target, pi);
119 case TypeCode.Decimal: return FastCreate<Decimal>(target, pi);
120 case TypeCode.DateTime: return FastCreate<DateTime>(target, pi);
121 case TypeCode.Double: return FastCreate<Double>(target, pi);
122 case TypeCode.Single: return FastCreate<Single>(target, pi);
123 case TypeCode.UInt16: return FastCreate<UInt16>(target, pi);
124 case TypeCode.UInt32: return FastCreate<UInt32>(target, pi);
125 case TypeCode.UInt64: return FastCreate<UInt64>(target, pi);
126 case TypeCode.String: return FastCreate<String>(target, pi);
127 case TypeCode.SByte: return FastCreate<SByte>(target, pi);
128 default: return SlowCreate(target, pi);
132 private static CallInstruction FastCreate<T0>(MethodInfo target, ParameterInfo[] pi) {
133 Type t = TryGetParameterOrReturnType(target, pi, 1);
135 if (target.ReturnType == typeof(void)) {
136 return new ActionCallInstruction<T0>(target);
138 return new FuncCallInstruction<T0>(target);
141 if (t.IsEnum()) return SlowCreate(target, pi);
142 switch (t.GetTypeCode()) {
143 case TypeCode.Object: {
144 if (t != typeof(object) && (IndexIsNotReturnType(1, target, pi) || t.IsValueType())) {
145 // if we're on the return type relaxed delegates makes it ok to use object
148 return FastCreate<T0, Object>(target, pi);
150 case TypeCode.Int16: return FastCreate<T0, Int16>(target, pi);
151 case TypeCode.Int32: return FastCreate<T0, Int32>(target, pi);
152 case TypeCode.Int64: return FastCreate<T0, Int64>(target, pi);
153 case TypeCode.Boolean: return FastCreate<T0, Boolean>(target, pi);
154 case TypeCode.Char: return FastCreate<T0, Char>(target, pi);
155 case TypeCode.Byte: return FastCreate<T0, Byte>(target, pi);
156 case TypeCode.Decimal: return FastCreate<T0, Decimal>(target, pi);
157 case TypeCode.DateTime: return FastCreate<T0, DateTime>(target, pi);
158 case TypeCode.Double: return FastCreate<T0, Double>(target, pi);
159 case TypeCode.Single: return FastCreate<T0, Single>(target, pi);
160 case TypeCode.UInt16: return FastCreate<T0, UInt16>(target, pi);
161 case TypeCode.UInt32: return FastCreate<T0, UInt32>(target, pi);
162 case TypeCode.UInt64: return FastCreate<T0, UInt64>(target, pi);
163 case TypeCode.String: return FastCreate<T0, String>(target, pi);
164 case TypeCode.SByte: return FastCreate<T0, SByte>(target, pi);
165 default: return SlowCreate(target, pi);
169 private static CallInstruction FastCreate<T0, T1>(MethodInfo target, ParameterInfo[] pi) {
170 Type t = TryGetParameterOrReturnType(target, pi, 2);
172 if (target.ReturnType == typeof(void)) {
173 return new ActionCallInstruction<T0, T1>(target);
175 return new FuncCallInstruction<T0, T1>(target);
178 if (t.IsEnum()) return SlowCreate(target, pi);
179 switch (t.GetTypeCode()) {
180 case TypeCode.Object: {
181 Debug.Assert(pi.Length == 2);
182 if (t.IsValueType()) goto default;
184 return new FuncCallInstruction<T0, T1, Object>(target);
186 case TypeCode.Int16: return new FuncCallInstruction<T0, T1, Int16>(target);
187 case TypeCode.Int32: return new FuncCallInstruction<T0, T1, Int32>(target);
188 case TypeCode.Int64: return new FuncCallInstruction<T0, T1, Int64>(target);
189 case TypeCode.Boolean: return new FuncCallInstruction<T0, T1, Boolean>(target);
190 case TypeCode.Char: return new FuncCallInstruction<T0, T1, Char>(target);
191 case TypeCode.Byte: return new FuncCallInstruction<T0, T1, Byte>(target);
192 case TypeCode.Decimal: return new FuncCallInstruction<T0, T1, Decimal>(target);
193 case TypeCode.DateTime: return new FuncCallInstruction<T0, T1, DateTime>(target);
194 case TypeCode.Double: return new FuncCallInstruction<T0, T1, Double>(target);
195 case TypeCode.Single: return new FuncCallInstruction<T0, T1, Single>(target);
196 case TypeCode.UInt16: return new FuncCallInstruction<T0, T1, UInt16>(target);
197 case TypeCode.UInt32: return new FuncCallInstruction<T0, T1, UInt32>(target);
198 case TypeCode.UInt64: return new FuncCallInstruction<T0, T1, UInt64>(target);
199 case TypeCode.String: return new FuncCallInstruction<T0, T1, String>(target);
200 case TypeCode.SByte: return new FuncCallInstruction<T0, T1, SByte>(target);
201 default: return SlowCreate(target, pi);
205 private static Type GetHelperType(MethodInfo info, Type[] arrTypes) {
207 if (info.ReturnType == typeof(void)) {
208 switch (arrTypes.Length) {
209 case 0: t = typeof(ActionCallInstruction); break;
210 case 1: t = typeof(ActionCallInstruction<>).MakeGenericType(arrTypes); break;
211 case 2: t = typeof(ActionCallInstruction<,>).MakeGenericType(arrTypes); break;
212 case 3: t = typeof(ActionCallInstruction<,,>).MakeGenericType(arrTypes); break;
213 case 4: t = typeof(ActionCallInstruction<,,,>).MakeGenericType(arrTypes); break;
214 case 5: t = typeof(ActionCallInstruction<,,,,>).MakeGenericType(arrTypes); break;
215 case 6: t = typeof(ActionCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;
216 case 7: t = typeof(ActionCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;
217 case 8: t = typeof(ActionCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;
218 case 9: t = typeof(ActionCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;
219 default: throw new InvalidOperationException();
222 switch (arrTypes.Length) {
223 case 1: t = typeof(FuncCallInstruction<>).MakeGenericType(arrTypes); break;
224 case 2: t = typeof(FuncCallInstruction<,>).MakeGenericType(arrTypes); break;
225 case 3: t = typeof(FuncCallInstruction<,,>).MakeGenericType(arrTypes); break;
226 case 4: t = typeof(FuncCallInstruction<,,,>).MakeGenericType(arrTypes); break;
227 case 5: t = typeof(FuncCallInstruction<,,,,>).MakeGenericType(arrTypes); break;
228 case 6: t = typeof(FuncCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;
229 case 7: t = typeof(FuncCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;
230 case 8: t = typeof(FuncCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;
231 case 9: t = typeof(FuncCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;
232 case 10: t = typeof(FuncCallInstruction<,,,,,,,,,>).MakeGenericType(arrTypes); break;
233 default: throw new InvalidOperationException();
238 public static MethodInfo CacheFunc<TRet>(Func<TRet> method) {
239 var info = method.GetMethodInfo();
241 _cache[info] = new FuncCallInstruction<TRet>(method);
246 public static MethodInfo CacheFunc<T0, TRet>(Func<T0, TRet> method) {
247 var info = method.GetMethodInfo();
249 _cache[info] = new FuncCallInstruction<T0, TRet>(method);
254 public static MethodInfo CacheFunc<T0, T1, TRet>(Func<T0, T1, TRet> method) {
255 var info = method.GetMethodInfo();
257 _cache[info] = new FuncCallInstruction<T0, T1, TRet>(method);
262 public static MethodInfo CacheFunc<T0, T1, T2, TRet>(Func<T0, T1, T2, TRet> method) {
263 var info = method.GetMethodInfo();
265 _cache[info] = new FuncCallInstruction<T0, T1, T2, TRet>(method);
270 public static MethodInfo CacheFunc<T0, T1, T2, T3, TRet>(Func<T0, T1, T2, T3, TRet> method) {
271 var info = method.GetMethodInfo();
273 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, TRet>(method);
278 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, TRet>(Func<T0, T1, T2, T3, T4, TRet> method) {
279 var info = method.GetMethodInfo();
281 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, TRet>(method);
286 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, TRet>(Func<T0, T1, T2, T3, T4, T5, TRet> method) {
287 var info = method.GetMethodInfo();
289 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet>(method);
294 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, TRet> method) {
295 var info = method.GetMethodInfo();
297 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet>(method);
302 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> method) {
303 var info = method.GetMethodInfo();
305 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(method);
310 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> method) {
311 var info = method.GetMethodInfo();
313 _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(method);
318 public static MethodInfo CacheAction(Action method) {
319 var info = method.GetMethodInfo();
321 _cache[info] = new ActionCallInstruction(method);
326 public static MethodInfo CacheAction<T0>(Action<T0> method) {
327 var info = method.GetMethodInfo();
329 _cache[info] = new ActionCallInstruction<T0>(method);
334 public static MethodInfo CacheAction<T0, T1>(Action<T0, T1> method) {
335 var info = method.GetMethodInfo();
337 _cache[info] = new ActionCallInstruction<T0, T1>(method);
342 public static MethodInfo CacheAction<T0, T1, T2>(Action<T0, T1, T2> method) {
343 var info = method.GetMethodInfo();
345 _cache[info] = new ActionCallInstruction<T0, T1, T2>(method);
350 public static MethodInfo CacheAction<T0, T1, T2, T3>(Action<T0, T1, T2, T3> method) {
351 var info = method.GetMethodInfo();
353 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3>(method);
358 public static MethodInfo CacheAction<T0, T1, T2, T3, T4>(Action<T0, T1, T2, T3, T4> method) {
359 var info = method.GetMethodInfo();
361 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4>(method);
366 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5>(Action<T0, T1, T2, T3, T4, T5> method) {
367 var info = method.GetMethodInfo();
369 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5>(method);
374 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6>(Action<T0, T1, T2, T3, T4, T5, T6> method) {
375 var info = method.GetMethodInfo();
377 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6>(method);
382 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7>(Action<T0, T1, T2, T3, T4, T5, T6, T7> method) {
383 var info = method.GetMethodInfo();
385 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7>(method);
390 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> method) {
391 var info = method.GetMethodInfo();
393 _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(method);
400 internal sealed class ActionCallInstruction : CallInstruction {
401 private readonly Action _target;
402 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
403 public override int ArgumentCount { get { return 0; } }
405 public ActionCallInstruction(Action target) {
409 public ActionCallInstruction(MethodInfo target) {
410 _target = (Action)target.CreateDelegate(typeof(Action));
413 public override object Invoke() {
418 public override int Run(InterpretedFrame frame) {
420 frame.StackIndex -= 0;
425 internal sealed class ActionCallInstruction<T0> : CallInstruction {
426 private readonly Action<T0> _target;
427 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
428 public override int ArgumentCount { get { return 1; } }
430 public ActionCallInstruction(Action<T0> target) {
434 public ActionCallInstruction(MethodInfo target) {
435 _target = (Action<T0>)target.CreateDelegate(typeof(Action<T0>));
438 public override object Invoke(object arg0) {
439 _target(arg0 != null ? (T0)arg0 : default(T0));
443 public override int Run(InterpretedFrame frame) {
444 _target((T0)frame.Data[frame.StackIndex - 1]);
445 frame.StackIndex -= 1;
450 internal sealed class ActionCallInstruction<T0, T1> : CallInstruction {
451 private readonly Action<T0, T1> _target;
452 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
453 public override int ArgumentCount { get { return 2; } }
455 public ActionCallInstruction(Action<T0, T1> target) {
459 public ActionCallInstruction(MethodInfo target) {
460 _target = (Action<T0, T1>)target.CreateDelegate(typeof(Action<T0, T1>));
463 public override object Invoke(object arg0, object arg1) {
464 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));
468 public override int Run(InterpretedFrame frame) {
469 _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
470 frame.StackIndex -= 2;
475 internal sealed class ActionCallInstruction<T0, T1, T2> : CallInstruction {
476 private readonly Action<T0, T1, T2> _target;
477 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
478 public override int ArgumentCount { get { return 3; } }
480 public ActionCallInstruction(Action<T0, T1, T2> target) {
484 public ActionCallInstruction(MethodInfo target) {
485 _target = (Action<T0, T1, T2>)target.CreateDelegate(typeof(Action<T0, T1, T2>));
488 public override object Invoke(object arg0, object arg1, object arg2) {
489 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));
493 public override int Run(InterpretedFrame frame) {
494 _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);
495 frame.StackIndex -= 3;
500 internal sealed class ActionCallInstruction<T0, T1, T2, T3> : CallInstruction {
501 private readonly Action<T0, T1, T2, T3> _target;
502 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
503 public override int ArgumentCount { get { return 4; } }
505 public ActionCallInstruction(Action<T0, T1, T2, T3> target) {
509 public ActionCallInstruction(MethodInfo target) {
510 _target = (Action<T0, T1, T2, T3>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3>));
513 public override object Invoke(object arg0, object arg1, object arg2, object arg3) {
514 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3));
518 public override int Run(InterpretedFrame frame) {
519 _target((T0)frame.Data[frame.StackIndex - 4], (T1)frame.Data[frame.StackIndex - 3], (T2)frame.Data[frame.StackIndex - 2], (T3)frame.Data[frame.StackIndex - 1]);
520 frame.StackIndex -= 4;
525 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4> : CallInstruction {
526 private readonly Action<T0, T1, T2, T3, T4> _target;
527 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
528 public override int ArgumentCount { get { return 5; } }
530 public ActionCallInstruction(Action<T0, T1, T2, T3, T4> target) {
534 public ActionCallInstruction(MethodInfo target) {
535 _target = (Action<T0, T1, T2, T3, T4>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4>));
538 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {
539 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4));
543 public override int Run(InterpretedFrame frame) {
544 _target((T0)frame.Data[frame.StackIndex - 5], (T1)frame.Data[frame.StackIndex - 4], (T2)frame.Data[frame.StackIndex - 3], (T3)frame.Data[frame.StackIndex - 2], (T4)frame.Data[frame.StackIndex - 1]);
545 frame.StackIndex -= 5;
550 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5> : CallInstruction {
551 private readonly Action<T0, T1, T2, T3, T4, T5> _target;
552 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
553 public override int ArgumentCount { get { return 6; } }
555 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5> target) {
559 public ActionCallInstruction(MethodInfo target) {
560 _target = (Action<T0, T1, T2, T3, T4, T5>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5>));
563 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {
564 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5));
568 public override int Run(InterpretedFrame frame) {
569 _target((T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
570 frame.StackIndex -= 6;
575 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6> : CallInstruction {
576 private readonly Action<T0, T1, T2, T3, T4, T5, T6> _target;
577 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
578 public override int ArgumentCount { get { return 7; } }
580 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6> target) {
584 public ActionCallInstruction(MethodInfo target) {
585 _target = (Action<T0, T1, T2, T3, T4, T5, T6>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6>));
588 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {
589 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6));
593 public override int Run(InterpretedFrame frame) {
594 _target((T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
595 frame.StackIndex -= 7;
600 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7> : CallInstruction {
601 private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7> _target;
602 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
603 public override int ArgumentCount { get { return 8; } }
605 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7> target) {
609 public ActionCallInstruction(MethodInfo target) {
610 _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7>));
613 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {
614 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7));
618 public override int Run(InterpretedFrame frame) {
619 _target((T0)frame.Data[frame.StackIndex - 8], (T1)frame.Data[frame.StackIndex - 7], (T2)frame.Data[frame.StackIndex - 6], (T3)frame.Data[frame.StackIndex - 5], (T4)frame.Data[frame.StackIndex - 4], (T5)frame.Data[frame.StackIndex - 3], (T6)frame.Data[frame.StackIndex - 2], (T7)frame.Data[frame.StackIndex - 1]);
620 frame.StackIndex -= 8;
625 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8> : CallInstruction {
626 private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> _target;
627 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
628 public override int ArgumentCount { get { return 9; } }
630 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> target) {
634 public ActionCallInstruction(MethodInfo target) {
635 _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>));
638 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {
639 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7), arg8 != null ? (T8)arg8 : default(T8));
643 public override int Run(InterpretedFrame frame) {
644 _target((T0)frame.Data[frame.StackIndex - 9], (T1)frame.Data[frame.StackIndex - 8], (T2)frame.Data[frame.StackIndex - 7], (T3)frame.Data[frame.StackIndex - 6], (T4)frame.Data[frame.StackIndex - 5], (T5)frame.Data[frame.StackIndex - 4], (T6)frame.Data[frame.StackIndex - 3], (T7)frame.Data[frame.StackIndex - 2], (T8)frame.Data[frame.StackIndex - 1]);
645 frame.StackIndex -= 9;
650 internal sealed class FuncCallInstruction<TRet> : CallInstruction {
651 private readonly Func<TRet> _target;
652 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
653 public override int ArgumentCount { get { return 0; } }
655 public FuncCallInstruction(Func<TRet> target) {
659 public FuncCallInstruction(MethodInfo target) {
660 _target = (Func<TRet>)target.CreateDelegate(typeof(Func<TRet>));
663 public override object Invoke() {
667 public override int Run(InterpretedFrame frame) {
668 frame.Data[frame.StackIndex - 0] = _target();
669 frame.StackIndex -= -1;
674 internal sealed class FuncCallInstruction<T0, TRet> : CallInstruction {
675 private readonly Func<T0, TRet> _target;
676 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
677 public override int ArgumentCount { get { return 1; } }
679 public FuncCallInstruction(Func<T0, TRet> target) {
683 public FuncCallInstruction(MethodInfo target) {
684 _target = (Func<T0, TRet>)target.CreateDelegate(typeof(Func<T0, TRet>));
687 public override object Invoke(object arg0) {
688 return _target(arg0 != null ? (T0)arg0 : default(T0));
691 public override int Run(InterpretedFrame frame) {
692 frame.Data[frame.StackIndex - 1] = _target((T0)frame.Data[frame.StackIndex - 1]);
693 frame.StackIndex -= 0;
698 internal sealed class FuncCallInstruction<T0, T1, TRet> : CallInstruction {
699 private readonly Func<T0, T1, TRet> _target;
700 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
701 public override int ArgumentCount { get { return 2; } }
703 public FuncCallInstruction(Func<T0, T1, TRet> target) {
707 public FuncCallInstruction(MethodInfo target) {
708 _target = (Func<T0, T1, TRet>)target.CreateDelegate(typeof(Func<T0, T1, TRet>));
711 public override object Invoke(object arg0, object arg1) {
712 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));
715 public override int Run(InterpretedFrame frame) {
716 frame.Data[frame.StackIndex - 2] = _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
717 frame.StackIndex -= 1;
722 internal sealed class FuncCallInstruction<T0, T1, T2, TRet> : CallInstruction {
723 private readonly Func<T0, T1, T2, TRet> _target;
724 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
725 public override int ArgumentCount { get { return 3; } }
727 public FuncCallInstruction(Func<T0, T1, T2, TRet> target) {
731 public FuncCallInstruction(MethodInfo target) {
732 _target = (Func<T0, T1, T2, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, TRet>));
735 public override object Invoke(object arg0, object arg1, object arg2) {
736 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));
739 public override int Run(InterpretedFrame frame) {
740 frame.Data[frame.StackIndex - 3] = _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);
741 frame.StackIndex -= 2;
746 internal sealed class FuncCallInstruction<T0, T1, T2, T3, TRet> : CallInstruction {
747 private readonly Func<T0, T1, T2, T3, TRet> _target;
748 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
749 public override int ArgumentCount { get { return 4; } }
751 public FuncCallInstruction(Func<T0, T1, T2, T3, TRet> target) {
755 public FuncCallInstruction(MethodInfo target) {
756 _target = (Func<T0, T1, T2, T3, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, TRet>));
759 public override object Invoke(object arg0, object arg1, object arg2, object arg3) {
760 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3));
763 public override int Run(InterpretedFrame frame) {
764 frame.Data[frame.StackIndex - 4] = _target((T0)frame.Data[frame.StackIndex - 4], (T1)frame.Data[frame.StackIndex - 3], (T2)frame.Data[frame.StackIndex - 2], (T3)frame.Data[frame.StackIndex - 1]);
765 frame.StackIndex -= 3;
770 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, TRet> : CallInstruction {
771 private readonly Func<T0, T1, T2, T3, T4, TRet> _target;
772 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
773 public override int ArgumentCount { get { return 5; } }
775 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, TRet> target) {
779 public FuncCallInstruction(MethodInfo target) {
780 _target = (Func<T0, T1, T2, T3, T4, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, TRet>));
783 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {
784 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4));
787 public override int Run(InterpretedFrame frame) {
788 frame.Data[frame.StackIndex - 5] = _target((T0)frame.Data[frame.StackIndex - 5], (T1)frame.Data[frame.StackIndex - 4], (T2)frame.Data[frame.StackIndex - 3], (T3)frame.Data[frame.StackIndex - 2], (T4)frame.Data[frame.StackIndex - 1]);
789 frame.StackIndex -= 4;
794 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet> : CallInstruction {
795 private readonly Func<T0, T1, T2, T3, T4, T5, TRet> _target;
796 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
797 public override int ArgumentCount { get { return 6; } }
799 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, TRet> target) {
803 public FuncCallInstruction(MethodInfo target) {
804 _target = (Func<T0, T1, T2, T3, T4, T5, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, TRet>));
807 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {
808 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5));
811 public override int Run(InterpretedFrame frame) {
812 frame.Data[frame.StackIndex - 6] = _target((T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
813 frame.StackIndex -= 5;
818 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet> : CallInstruction {
819 private readonly Func<T0, T1, T2, T3, T4, T5, T6, TRet> _target;
820 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
821 public override int ArgumentCount { get { return 7; } }
823 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, TRet> target) {
827 public FuncCallInstruction(MethodInfo target) {
828 _target = (Func<T0, T1, T2, T3, T4, T5, T6, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, TRet>));
831 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {
832 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6));
835 public override int Run(InterpretedFrame frame) {
836 frame.Data[frame.StackIndex - 7] = _target((T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
837 frame.StackIndex -= 6;
842 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet> : CallInstruction {
843 private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> _target;
844 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
845 public override int ArgumentCount { get { return 8; } }
847 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> target) {
851 public FuncCallInstruction(MethodInfo target) {
852 _target = (Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>));
855 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {
856 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7));
859 public override int Run(InterpretedFrame frame) {
860 frame.Data[frame.StackIndex - 8] = _target((T0)frame.Data[frame.StackIndex - 8], (T1)frame.Data[frame.StackIndex - 7], (T2)frame.Data[frame.StackIndex - 6], (T3)frame.Data[frame.StackIndex - 5], (T4)frame.Data[frame.StackIndex - 4], (T5)frame.Data[frame.StackIndex - 3], (T6)frame.Data[frame.StackIndex - 2], (T7)frame.Data[frame.StackIndex - 1]);
861 frame.StackIndex -= 7;
866 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> : CallInstruction {
867 private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> _target;
868 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
869 public override int ArgumentCount { get { return 9; } }
871 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> target) {
875 public FuncCallInstruction(MethodInfo target) {
876 _target = (Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>));
879 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {
880 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7), arg8 != null ? (T8)arg8 : default(T8));
883 public override int Run(InterpretedFrame frame) {
884 frame.Data[frame.StackIndex - 9] = _target((T0)frame.Data[frame.StackIndex - 9], (T1)frame.Data[frame.StackIndex - 8], (T2)frame.Data[frame.StackIndex - 7], (T3)frame.Data[frame.StackIndex - 6], (T4)frame.Data[frame.StackIndex - 5], (T5)frame.Data[frame.StackIndex - 4], (T6)frame.Data[frame.StackIndex - 3], (T7)frame.Data[frame.StackIndex - 2], (T8)frame.Data[frame.StackIndex - 1]);
885 frame.StackIndex -= 8;
890 internal sealed partial class MethodInfoCallInstruction : CallInstruction {
891 public override object Invoke() {
892 return InvokeWorker();
894 public override object Invoke(object arg0) {
895 return InvokeWorker(arg0);
897 public override object Invoke(object arg0, object arg1) {
898 return InvokeWorker(arg0, arg1);
902 // *** END GENERATED CODE ***