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 * dlr@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 16using System.Runtime.CompilerServices;17 18namespace System.Management.Automation.Interpreter19{20 /// <summary>21 /// Implements dynamic call site with many arguments. Wraps the arguments into <see cref="ArgumentArray"/>.22 /// </summary>23 internal sealed class DynamicSplatInstruction : Instruction24 {25 private readonly CallSite<Func<CallSite, ArgumentArray, object>> _site;26 private readonly int _argumentCount;27 28 internal DynamicSplatInstruction(int argumentCount, CallSite<Func<CallSite, ArgumentArray, object>> site)29 {30 _site = site;31 _argumentCount = argumentCount;32 }33 34 public override int ProducedStack { get { return 1; } }35 36 public override int ConsumedStack { get { return _argumentCount; } }37 38 public override int Run(InterpretedFrame frame)39 {40 int first = frame.StackIndex - _argumentCount;41 object ret = _site.Target(_site, new ArgumentArray(frame.Data, first, _argumentCount));42 frame.Data[first] = ret;43 frame.StackIndex = first + 1;44 45 return 1;46 }47 48 public override string ToString()49 {50 return "DynamicSplatInstruction(" + _site + ")";51 }52 }53}54 