MegaBites-AI/Windows-powershell
0372
1/* ****************************************************************************2 *3 * Copyright (c) Microsoft Corporation.4 *5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A6 * copy of the license can be found in the License.html file at the root of this distribution. If7 * you cannot locate the Apache License, Version 2.0, please send an email to8 * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound9 * by the terms of the Apache License, Version 2.0.10 *11 * You must not remove this notice, or any other, from this software.12 *13 *14 * ***************************************************************************/15#if !CLR216using System.Linq.Expressions;17#else18using Microsoft.Scripting.Ast;19#endif20 21using System;22using System.Collections.Generic;23using System.Diagnostics;24using System.Reflection;25using System.Threading;26 27using System.Dynamic;28 29namespace System.Management.Automation.Interpreter {30 #region Generated Reflected Caller31 32 // *** BEGIN GENERATED CODE ***33 // generated by function: gen_all from: generate_reflected_calls.py34 35 internal partial class CallInstruction {36 private const int MaxHelpers = 10;37 private const int MaxArgs = 3;38 39 public virtual object InvokeInstance(object instance, params object[] args) {40 switch(args.Length) {41 case 0: return Invoke(instance);42 case 1: return Invoke(instance, args[0]);43 case 2: return Invoke(instance, args[0], args[1]);44 case 3: return Invoke(instance, args[0], args[1], args[2]);45 case 4: return Invoke(instance, args[0], args[1], args[2], args[3]);46 case 5: return Invoke(instance, args[0], args[1], args[2], args[3], args[4]);47 case 6: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5]);48 case 7: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);49 case 8: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);50 default: throw new InvalidOperationException();51 }52 }53 54 public virtual object Invoke(params object[] args) {55 switch(args.Length) {56 case 0: return Invoke();57 case 1: return Invoke(args[0]);58 case 2: return Invoke(args[0], args[1]);59 case 3: return Invoke(args[0], args[1], args[2]);60 case 4: return Invoke(args[0], args[1], args[2], args[3]);61 case 5: return Invoke(args[0], args[1], args[2], args[3], args[4]);62 case 6: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5]);63 case 7: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);64 case 8: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);65 case 9: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);66 default: throw new InvalidOperationException();67 }68 }69 70 public virtual object Invoke() { throw new InvalidOperationException(); }71 72 public virtual object Invoke(object arg0) { throw new InvalidOperationException(); }73 74 public virtual object Invoke(object arg0, object arg1) { throw new InvalidOperationException(); }75 76 public virtual object Invoke(object arg0, object arg1, object arg2) { throw new InvalidOperationException(); }77 78 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3) { throw new InvalidOperationException(); }79 80 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) { throw new InvalidOperationException(); }81 82 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) { throw new InvalidOperationException(); }83 84 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) { throw new InvalidOperationException(); }85 86 public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) { throw new InvalidOperationException(); }87 88 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(); }89 90 /// <summary>91 /// Fast creation works if we have a known primitive types for the entire92 /// method signature. If we have any non-primitive types then FastCreate93 /// falls back to SlowCreate which works for all types.94 ///95 /// Fast creation is fast because it avoids using reflection (MakeGenericType96 /// and Activator.CreateInstance) to create the types. It does this through97 /// calling a series of generic methods picking up each strong type of the98 /// signature along the way. When it runs out of types it news up the99 /// appropriate CallInstruction with the strong-types that have been built up.100 ///101 /// One relaxation is that for return types which are non-primitive types102 /// we can fallback to object due to relaxed delegates.103 /// </summary>104 private static CallInstruction FastCreate(MethodInfo target, ParameterInfo[] pi) {105 Type t = TryGetParameterOrReturnType(target, pi, 0);106 if (t == null) {107 return new ActionCallInstruction(target);108 }109 110 if (t.IsEnum) return SlowCreate(target, pi);111 switch (t.GetTypeCode()) {112 case TypeCode.Object: {113 if (t != typeof(object) && (IndexIsNotReturnType(0, target, pi) || t.IsValueType)) {114 // if we're on the return type relaxed delegates makes it ok to use object115 goto default;116 }117 118 return FastCreate<object>(target, pi);119 }120 case TypeCode.Int16: return FastCreate<Int16>(target, pi);121 case TypeCode.Int32: return FastCreate<Int32>(target, pi);122 case TypeCode.Int64: return FastCreate<Int64>(target, pi);123 case TypeCode.Boolean: return FastCreate<bool>(target, pi);124 case TypeCode.Char: return FastCreate<char>(target, pi);125 case TypeCode.Byte: return FastCreate<byte>(target, pi);126 case TypeCode.Decimal: return FastCreate<Decimal>(target, pi);127 case TypeCode.DateTime: return FastCreate<DateTime>(target, pi);128 case TypeCode.Double: return FastCreate<double>(target, pi);129 case TypeCode.Single: return FastCreate<Single>(target, pi);130 case TypeCode.UInt16: return FastCreate<UInt16>(target, pi);131 case TypeCode.UInt32: return FastCreate<UInt32>(target, pi);132 case TypeCode.UInt64: return FastCreate<UInt64>(target, pi);133 case TypeCode.String: return FastCreate<string>(target, pi);134 case TypeCode.SByte: return FastCreate<sbyte>(target, pi);135 default: return SlowCreate(target, pi);136 }137 }138 139 private static CallInstruction FastCreate<T0>(MethodInfo target, ParameterInfo[] pi) {140 Type t = TryGetParameterOrReturnType(target, pi, 1);141 if (t == null) {142 if (target.ReturnType == typeof(void)) {143 return new ActionCallInstruction<T0>(target);144 }145 146 return new FuncCallInstruction<T0>(target);147 }148 149 if (t.IsEnum) return SlowCreate(target, pi);150 switch (t.GetTypeCode()) {151 case TypeCode.Object: {152 if (t != typeof(object) && (IndexIsNotReturnType(1, target, pi) || t.IsValueType)) {153 // if we're on the return type relaxed delegates makes it ok to use object154 goto default;155 }156 157 return FastCreate<T0, object>(target, pi);158 }159 case TypeCode.Int16: return FastCreate<T0, Int16>(target, pi);160 case TypeCode.Int32: return FastCreate<T0, Int32>(target, pi);161 case TypeCode.Int64: return FastCreate<T0, Int64>(target, pi);162 case TypeCode.Boolean: return FastCreate<T0, bool>(target, pi);163 case TypeCode.Char: return FastCreate<T0, char>(target, pi);164 case TypeCode.Byte: return FastCreate<T0, byte>(target, pi);165 case TypeCode.Decimal: return FastCreate<T0, Decimal>(target, pi);166 case TypeCode.DateTime: return FastCreate<T0, DateTime>(target, pi);167 case TypeCode.Double: return FastCreate<T0, Double>(target, pi);168 case TypeCode.Single: return FastCreate<T0, Single>(target, pi);169 case TypeCode.UInt16: return FastCreate<T0, UInt16>(target, pi);170 case TypeCode.UInt32: return FastCreate<T0, UInt32>(target, pi);171 case TypeCode.UInt64: return FastCreate<T0, UInt64>(target, pi);172 case TypeCode.String: return FastCreate<T0, string>(target, pi);173 case TypeCode.SByte: return FastCreate<T0, sbyte>(target, pi);174 default: return SlowCreate(target, pi);175 }176 }177 178 private static CallInstruction FastCreate<T0, T1>(MethodInfo target, ParameterInfo[] pi) {179 Type t = TryGetParameterOrReturnType(target, pi, 2);180 if (t == null) {181 if (target.ReturnType == typeof(void)) {182 return new ActionCallInstruction<T0, T1>(target);183 }184 185 return new FuncCallInstruction<T0, T1>(target);186 }187 188 if (t.IsEnum) return SlowCreate(target, pi);189 switch (t.GetTypeCode()) {190 case TypeCode.Object: {191 Debug.Assert(pi.Length == 2);192 if (t.IsValueType) goto default;193 194 return new FuncCallInstruction<T0, T1, object>(target);195 }196 case TypeCode.Int16: return new FuncCallInstruction<T0, T1, Int16>(target);197 case TypeCode.Int32: return new FuncCallInstruction<T0, T1, Int32>(target);198 case TypeCode.Int64: return new FuncCallInstruction<T0, T1, Int64>(target);199 case TypeCode.Boolean: return new FuncCallInstruction<T0, T1, bool>(target);200 case TypeCode.Char: return new FuncCallInstruction<T0, T1, char>(target);201 case TypeCode.Byte: return new FuncCallInstruction<T0, T1, byte>(target);202 case TypeCode.Decimal: return new FuncCallInstruction<T0, T1, Decimal>(target);203 case TypeCode.DateTime: return new FuncCallInstruction<T0, T1, DateTime>(target);204 case TypeCode.Double: return new FuncCallInstruction<T0, T1, Double>(target);205 case TypeCode.Single: return new FuncCallInstruction<T0, T1, Single>(target);206 case TypeCode.UInt16: return new FuncCallInstruction<T0, T1, UInt16>(target);207 case TypeCode.UInt32: return new FuncCallInstruction<T0, T1, UInt32>(target);208 case TypeCode.UInt64: return new FuncCallInstruction<T0, T1, UInt64>(target);209 case TypeCode.String: return new FuncCallInstruction<T0, T1, string>(target);210 case TypeCode.SByte: return new FuncCallInstruction<T0, T1, sbyte>(target);211 default: return SlowCreate(target, pi);212 }213 }214 215 private static Type GetHelperType(MethodInfo info, Type[] arrTypes) {216 Type t;217 if (info.ReturnType == typeof(void)) {218 switch (arrTypes.Length) {219 case 0: t = typeof(ActionCallInstruction); break;220 case 1: t = typeof(ActionCallInstruction<>).MakeGenericType(arrTypes); break;221 case 2: t = typeof(ActionCallInstruction<,>).MakeGenericType(arrTypes); break;222 case 3: t = typeof(ActionCallInstruction<,,>).MakeGenericType(arrTypes); break;223 case 4: t = typeof(ActionCallInstruction<,,,>).MakeGenericType(arrTypes); break;224 case 5: t = typeof(ActionCallInstruction<,,,,>).MakeGenericType(arrTypes); break;225 case 6: t = typeof(ActionCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;226 case 7: t = typeof(ActionCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;227 case 8: t = typeof(ActionCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;228 case 9: t = typeof(ActionCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;229 default: throw new InvalidOperationException();230 }231 } else {232 switch (arrTypes.Length) {233 case 1: t = typeof(FuncCallInstruction<>).MakeGenericType(arrTypes); break;234 case 2: t = typeof(FuncCallInstruction<,>).MakeGenericType(arrTypes); break;235 case 3: t = typeof(FuncCallInstruction<,,>).MakeGenericType(arrTypes); break;236 case 4: t = typeof(FuncCallInstruction<,,,>).MakeGenericType(arrTypes); break;237 case 5: t = typeof(FuncCallInstruction<,,,,>).MakeGenericType(arrTypes); break;238 case 6: t = typeof(FuncCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;239 case 7: t = typeof(FuncCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;240 case 8: t = typeof(FuncCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;241 case 9: t = typeof(FuncCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;242 case 10: t = typeof(FuncCallInstruction<,,,,,,,,,>).MakeGenericType(arrTypes); break;243 default: throw new InvalidOperationException();244 }245 }246 247 return t;248 }249 250 public static MethodInfo CacheFunc<TRet>(Func<TRet> method) {251 var info = method.GetMethodInfo();252 lock (s_cache) {253 s_cache[info] = new FuncCallInstruction<TRet>(method);254 }255 256 return info;257 }258 259 public static MethodInfo CacheFunc<T0, TRet>(Func<T0, TRet> method) {260 var info = method.GetMethodInfo();261 lock (s_cache) {262 s_cache[info] = new FuncCallInstruction<T0, TRet>(method);263 }264 265 return info;266 }267 268 public static MethodInfo CacheFunc<T0, T1, TRet>(Func<T0, T1, TRet> method) {269 var info = method.GetMethodInfo();270 lock (s_cache) {271 s_cache[info] = new FuncCallInstruction<T0, T1, TRet>(method);272 }273 274 return info;275 }276 277 public static MethodInfo CacheFunc<T0, T1, T2, TRet>(Func<T0, T1, T2, TRet> method) {278 var info = method.GetMethodInfo();279 lock (s_cache) {280 s_cache[info] = new FuncCallInstruction<T0, T1, T2, TRet>(method);281 }282 283 return info;284 }285 286 public static MethodInfo CacheFunc<T0, T1, T2, T3, TRet>(Func<T0, T1, T2, T3, TRet> method) {287 var info = method.GetMethodInfo();288 lock (s_cache) {289 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, TRet>(method);290 }291 292 return info;293 }294 295 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, TRet>(Func<T0, T1, T2, T3, T4, TRet> method) {296 var info = method.GetMethodInfo();297 lock (s_cache) {298 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, TRet>(method);299 }300 301 return info;302 }303 304 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, TRet>(Func<T0, T1, T2, T3, T4, T5, TRet> method) {305 var info = method.GetMethodInfo();306 lock (s_cache) {307 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet>(method);308 }309 310 return info;311 }312 313 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, TRet> method) {314 var info = method.GetMethodInfo();315 lock (s_cache) {316 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet>(method);317 }318 319 return info;320 }321 322 public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> method) {323 var info = method.GetMethodInfo();324 lock (s_cache) {325 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(method);326 }327 328 return info;329 }330 331 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) {332 var info = method.GetMethodInfo();333 lock (s_cache) {334 s_cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(method);335 }336 337 return info;338 }339 340 public static MethodInfo CacheAction(Action method) {341 var info = method.GetMethodInfo();342 lock (s_cache) {343 s_cache[info] = new ActionCallInstruction(method);344 }345 346 return info;347 }348 349 public static MethodInfo CacheAction<T0>(Action<T0> method) {350 var info = method.GetMethodInfo();351 lock (s_cache) {352 s_cache[info] = new ActionCallInstruction<T0>(method);353 }354 355 return info;356 }357 358 public static MethodInfo CacheAction<T0, T1>(Action<T0, T1> method) {359 var info = method.GetMethodInfo();360 lock (s_cache) {361 s_cache[info] = new ActionCallInstruction<T0, T1>(method);362 }363 364 return info;365 }366 367 public static MethodInfo CacheAction<T0, T1, T2>(Action<T0, T1, T2> method) {368 var info = method.GetMethodInfo();369 lock (s_cache) {370 s_cache[info] = new ActionCallInstruction<T0, T1, T2>(method);371 }372 373 return info;374 }375 376 public static MethodInfo CacheAction<T0, T1, T2, T3>(Action<T0, T1, T2, T3> method) {377 var info = method.GetMethodInfo();378 lock (s_cache) {379 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3>(method);380 }381 382 return info;383 }384 385 public static MethodInfo CacheAction<T0, T1, T2, T3, T4>(Action<T0, T1, T2, T3, T4> method) {386 var info = method.GetMethodInfo();387 lock (s_cache) {388 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4>(method);389 }390 391 return info;392 }393 394 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5>(Action<T0, T1, T2, T3, T4, T5> method) {395 var info = method.GetMethodInfo();396 lock (s_cache) {397 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5>(method);398 }399 400 return info;401 }402 403 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6>(Action<T0, T1, T2, T3, T4, T5, T6> method) {404 var info = method.GetMethodInfo();405 lock (s_cache) {406 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6>(method);407 }408 409 return info;410 }411 412 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7>(Action<T0, T1, T2, T3, T4, T5, T6, T7> method) {413 var info = method.GetMethodInfo();414 lock (s_cache) {415 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7>(method);416 }417 418 return info;419 }420 421 public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> method) {422 var info = method.GetMethodInfo();423 lock (s_cache) {424 s_cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(method);425 }426 427 return info;428 }429 430 }431 432 internal sealed class ActionCallInstruction : CallInstruction {433 private readonly Action _target;434 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }435 436 public override int ArgumentCount { get { return 0; } }437 438 public ActionCallInstruction(Action target) {439 _target = target;440 }441 442 public ActionCallInstruction(MethodInfo target) {443 _target = (Action)target.CreateDelegate(typeof(Action));444 }445 446 public override object Invoke() {447 _target();448 return null;449 }450 451 public override int Run(InterpretedFrame frame) {452 _target();453 frame.StackIndex -= 0;454 return 1;455 }456 }457 458 internal sealed class ActionCallInstruction<T0> : CallInstruction {459 private readonly Action<T0> _target;460 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }461 462 public override int ArgumentCount { get { return 1; } }463 464 public ActionCallInstruction(Action<T0> target) {465 _target = target;466 }467 468 public ActionCallInstruction(MethodInfo target) {469 _target = (Action<T0>)target.CreateDelegate(typeof(Action<T0>));470 }471 472 public override object Invoke(object arg0) {473 _target(arg0 != null ? (T0)arg0 : default(T0));474 return null;475 }476 477 public override int Run(InterpretedFrame frame) {478 _target((T0)frame.Data[frame.StackIndex - 1]);479 frame.StackIndex -= 1;480 return 1;481 }482 }483 484 internal sealed class ActionCallInstruction<T0, T1> : CallInstruction {485 private readonly Action<T0, T1> _target;486 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }487 488 public override int ArgumentCount { get { return 2; } }489 490 public ActionCallInstruction(Action<T0, T1> target) {491 _target = target;492 }493 494 public ActionCallInstruction(MethodInfo target) {495 _target = (Action<T0, T1>)target.CreateDelegate(typeof(Action<T0, T1>));496 }497 498 public override object Invoke(object arg0, object arg1) {499 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));500 return null;501 }502 503 public override int Run(InterpretedFrame frame) {504 _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);505 frame.StackIndex -= 2;506 return 1;507 }508 }509 510 internal sealed class ActionCallInstruction<T0, T1, T2> : CallInstruction {511 private readonly Action<T0, T1, T2> _target;512 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }513 514 public override int ArgumentCount { get { return 3; } }515 516 public ActionCallInstruction(Action<T0, T1, T2> target) {517 _target = target;518 }519 520 public ActionCallInstruction(MethodInfo target) {521 _target = (Action<T0, T1, T2>)target.CreateDelegate(typeof(Action<T0, T1, T2>));522 }523 524 public override object Invoke(object arg0, object arg1, object arg2) {525 _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));526 return null;527 }528 529 public override int Run(InterpretedFrame frame) {530 _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);531 frame.StackIndex -= 3;532 return 1;533 }534 }535 536 internal sealed class ActionCallInstruction<T0, T1, T2, T3> : CallInstruction {537 private readonly Action<T0, T1, T2, T3> _target;538 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }539 540 public override int ArgumentCount { get { return 4; } }541 542 public ActionCallInstruction(Action<T0, T1, T2, T3> target) {543 _target = target;544 }545 546 public ActionCallInstruction(MethodInfo target) {547 _target = (Action<T0, T1, T2, T3>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3>));548 }549 550 public override object Invoke(object arg0, object arg1, object arg2, object arg3) {551 _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));552 return null;553 }554 555 public override int Run(InterpretedFrame frame) {556 _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]);557 frame.StackIndex -= 4;558 return 1;559 }560 }561 562 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4> : CallInstruction {563 private readonly Action<T0, T1, T2, T3, T4> _target;564 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }565 566 public override int ArgumentCount { get { return 5; } }567 568 public ActionCallInstruction(Action<T0, T1, T2, T3, T4> target) {569 _target = target;570 }571 572 public ActionCallInstruction(MethodInfo target) {573 _target = (Action<T0, T1, T2, T3, T4>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4>));574 }575 576 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {577 _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));578 return null;579 }580 581 public override int Run(InterpretedFrame frame) {582 _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]);583 frame.StackIndex -= 5;584 return 1;585 }586 }587 588 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5> : CallInstruction {589 private readonly Action<T0, T1, T2, T3, T4, T5> _target;590 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }591 592 public override int ArgumentCount { get { return 6; } }593 594 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5> target) {595 _target = target;596 }597 598 public ActionCallInstruction(MethodInfo target) {599 _target = (Action<T0, T1, T2, T3, T4, T5>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5>));600 }601 602 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {603 _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));604 return null;605 }606 607 public override int Run(InterpretedFrame frame) {608 _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]);609 frame.StackIndex -= 6;610 return 1;611 }612 }613 614 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6> : CallInstruction {615 private readonly Action<T0, T1, T2, T3, T4, T5, T6> _target;616 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }617 618 public override int ArgumentCount { get { return 7; } }619 620 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6> target) {621 _target = target;622 }623 624 public ActionCallInstruction(MethodInfo target) {625 _target = (Action<T0, T1, T2, T3, T4, T5, T6>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6>));626 }627 628 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {629 _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));630 return null;631 }632 633 public override int Run(InterpretedFrame frame) {634 _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]);635 frame.StackIndex -= 7;636 return 1;637 }638 }639 640 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7> : CallInstruction {641 private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7> _target;642 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }643 644 public override int ArgumentCount { get { return 8; } }645 646 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7> target) {647 _target = target;648 }649 650 public ActionCallInstruction(MethodInfo target) {651 _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7>));652 }653 654 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {655 _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));656 return null;657 }658 659 public override int Run(InterpretedFrame frame) {660 _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]);661 frame.StackIndex -= 8;662 return 1;663 }664 }665 666 internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8> : CallInstruction {667 private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> _target;668 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }669 670 public override int ArgumentCount { get { return 9; } }671 672 public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> target) {673 _target = target;674 }675 676 public ActionCallInstruction(MethodInfo target) {677 _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>));678 }679 680 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {681 _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));682 return null;683 }684 685 public override int Run(InterpretedFrame frame) {686 _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]);687 frame.StackIndex -= 9;688 return 1;689 }690 }691 692 internal sealed class FuncCallInstruction<TRet> : CallInstruction {693 private readonly Func<TRet> _target;694 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }695 696 public override int ArgumentCount { get { return 0; } }697 698 public FuncCallInstruction(Func<TRet> target) {699 _target = target;700 }701 702 public FuncCallInstruction(MethodInfo target) {703 _target = (Func<TRet>)target.CreateDelegate(typeof(Func<TRet>));704 }705 706 public override object Invoke() {707 return _target();708 }709 710 public override int Run(InterpretedFrame frame) {711 frame.Data[frame.StackIndex - 0] = _target();712 frame.StackIndex -= -1;713 return 1;714 }715 }716 717 internal sealed class FuncCallInstruction<T0, TRet> : CallInstruction {718 private readonly Func<T0, TRet> _target;719 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }720 721 public override int ArgumentCount { get { return 1; } }722 723 public FuncCallInstruction(Func<T0, TRet> target) {724 _target = target;725 }726 727 public FuncCallInstruction(MethodInfo target) {728 _target = (Func<T0, TRet>)target.CreateDelegate(typeof(Func<T0, TRet>));729 }730 731 public override object Invoke(object arg0) {732 return _target(arg0 != null ? (T0)arg0 : default(T0));733 }734 735 public override int Run(InterpretedFrame frame) {736 frame.Data[frame.StackIndex - 1] = _target((T0)frame.Data[frame.StackIndex - 1]);737 frame.StackIndex -= 0;738 return 1;739 }740 }741 742 internal sealed class FuncCallInstruction<T0, T1, TRet> : CallInstruction {743 private readonly Func<T0, T1, TRet> _target;744 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }745 746 public override int ArgumentCount { get { return 2; } }747 748 public FuncCallInstruction(Func<T0, T1, TRet> target) {749 _target = target;750 }751 752 public FuncCallInstruction(MethodInfo target) {753 _target = (Func<T0, T1, TRet>)target.CreateDelegate(typeof(Func<T0, T1, TRet>));754 }755 756 public override object Invoke(object arg0, object arg1) {757 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));758 }759 760 public override int Run(InterpretedFrame frame) {761 frame.Data[frame.StackIndex - 2] = _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);762 frame.StackIndex -= 1;763 return 1;764 }765 }766 767 internal sealed class FuncCallInstruction<T0, T1, T2, TRet> : CallInstruction {768 private readonly Func<T0, T1, T2, TRet> _target;769 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }770 771 public override int ArgumentCount { get { return 3; } }772 773 public FuncCallInstruction(Func<T0, T1, T2, TRet> target) {774 _target = target;775 }776 777 public FuncCallInstruction(MethodInfo target) {778 _target = (Func<T0, T1, T2, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, TRet>));779 }780 781 public override object Invoke(object arg0, object arg1, object arg2) {782 return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));783 }784 785 public override int Run(InterpretedFrame frame) {786 frame.Data[frame.StackIndex - 3] = _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);787 frame.StackIndex -= 2;788 return 1;789 }790 }791 792 internal sealed class FuncCallInstruction<T0, T1, T2, T3, TRet> : CallInstruction {793 private readonly Func<T0, T1, T2, T3, TRet> _target;794 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }795 796 public override int ArgumentCount { get { return 4; } }797 798 public FuncCallInstruction(Func<T0, T1, T2, T3, TRet> target) {799 _target = target;800 }801 802 public FuncCallInstruction(MethodInfo target) {803 _target = (Func<T0, T1, T2, T3, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, TRet>));804 }805 806 public override object Invoke(object arg0, object arg1, object arg2, object arg3) {807 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));808 }809 810 public override int Run(InterpretedFrame frame) {811 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]);812 frame.StackIndex -= 3;813 return 1;814 }815 }816 817 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, TRet> : CallInstruction {818 private readonly Func<T0, T1, T2, T3, T4, TRet> _target;819 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }820 821 public override int ArgumentCount { get { return 5; } }822 823 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, TRet> target) {824 _target = target;825 }826 827 public FuncCallInstruction(MethodInfo target) {828 _target = (Func<T0, T1, T2, T3, T4, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, TRet>));829 }830 831 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {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));833 }834 835 public override int Run(InterpretedFrame frame) {836 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]);837 frame.StackIndex -= 4;838 return 1;839 }840 }841 842 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet> : CallInstruction {843 private readonly Func<T0, T1, T2, T3, T4, T5, TRet> _target;844 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }845 846 public override int ArgumentCount { get { return 6; } }847 848 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, TRet> target) {849 _target = target;850 }851 852 public FuncCallInstruction(MethodInfo target) {853 _target = (Func<T0, T1, T2, T3, T4, T5, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, TRet>));854 }855 856 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {857 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));858 }859 860 public override int Run(InterpretedFrame frame) {861 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]);862 frame.StackIndex -= 5;863 return 1;864 }865 }866 867 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet> : CallInstruction {868 private readonly Func<T0, T1, T2, T3, T4, T5, T6, TRet> _target;869 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }870 871 public override int ArgumentCount { get { return 7; } }872 873 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, TRet> target) {874 _target = target;875 }876 877 public FuncCallInstruction(MethodInfo target) {878 _target = (Func<T0, T1, T2, T3, T4, T5, T6, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, TRet>));879 }880 881 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {882 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));883 }884 885 public override int Run(InterpretedFrame frame) {886 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]);887 frame.StackIndex -= 6;888 return 1;889 }890 }891 892 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet> : CallInstruction {893 private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> _target;894 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }895 896 public override int ArgumentCount { get { return 8; } }897 898 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> target) {899 _target = target;900 }901 902 public FuncCallInstruction(MethodInfo target) {903 _target = (Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>));904 }905 906 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {907 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));908 }909 910 public override int Run(InterpretedFrame frame) {911 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]);912 frame.StackIndex -= 7;913 return 1;914 }915 }916 917 internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> : CallInstruction {918 private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> _target;919 public override MethodInfo Info { get { return _target.GetMethodInfo(); } }920 921 public override int ArgumentCount { get { return 9; } }922 923 public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> target) {924 _target = target;925 }926 927 public FuncCallInstruction(MethodInfo target) {928 _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>));929 }930 931 public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {932 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));933 }934 935 public override int Run(InterpretedFrame frame) {936 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]);937 frame.StackIndex -= 8;938 return 1;939 }940 }941 942 internal sealed partial class MethodInfoCallInstruction : CallInstruction {943 public override object Invoke() {944 return InvokeWorker();945 }946 947 public override object Invoke(object arg0) {948 return InvokeWorker(arg0);949 }950 951 public override object Invoke(object arg0, object arg1) {952 return InvokeWorker(arg0, arg1);953 }954 }955 956 // *** END GENERATED CODE ***957 958 #endregion959}960 