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 * dlr@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 * ***************************************************************************/
18 using System.Collections.Generic;
19 using System.Runtime.CompilerServices;
20 using System.Reflection;
22 using Microsoft.Scripting.Utils;
23 using Microsoft.Scripting.Ast;
24 using Microsoft.Scripting.Runtime;
26 namespace Microsoft.Scripting.Interpreter {
28 /// Implements dynamic call site with many arguments. Wraps the arguments into <see cref="ArgumentArray"/>.
30 internal sealed partial class DynamicSplatInstruction : Instruction {
31 private readonly CallSite<Func<CallSite, ArgumentArray, object>> _site;
32 private readonly int _argumentCount;
34 internal DynamicSplatInstruction(int argumentCount, CallSite<Func<CallSite, ArgumentArray, object>> site) {
36 _argumentCount = argumentCount;
39 public override int ProducedStack { get { return 1; } }
40 public override int ConsumedStack { get { return _argumentCount; } }
42 public override int Run(InterpretedFrame frame) {
43 int first = frame.StackIndex - _argumentCount;
44 object ret = _site.Target(_site, new ArgumentArray(frame.Data, first, _argumentCount));
45 frame.Data[first] = ret;
46 frame.StackIndex = first + 1;
51 public override string ToString() {
52 return "DynamicSplatInstruction(" + _site + ")";