|
4 | 4 |
|
5 | 5 | #if FEATURE_CTYPES |
6 | 6 |
|
7 | | -using System.Linq.Expressions; |
8 | | -using System.Numerics; |
9 | | - |
10 | 7 | using System; |
11 | 8 | using System.Collections.Generic; |
12 | | -using System.Dynamic; |
13 | 9 | using System.Diagnostics; |
| 10 | +using System.Dynamic; |
| 11 | +using System.Linq; |
| 12 | +using System.Linq.Expressions; |
| 13 | +using System.Numerics; |
14 | 14 | using System.Reflection; |
15 | 15 | using System.Reflection.Emit; |
16 | 16 | using System.Runtime.CompilerServices; |
17 | 17 | using System.Runtime.InteropServices; |
18 | 18 | using System.Threading; |
19 | 19 |
|
20 | | -using Microsoft.Scripting; |
21 | 20 | using Microsoft.Scripting.Ast; |
22 | 21 | using Microsoft.Scripting.Generation; |
23 | 22 | using Microsoft.Scripting.Runtime; |
24 | | -using Microsoft.Scripting.Utils; |
25 | 23 |
|
26 | 24 | using IronPython.Runtime; |
27 | 25 | using IronPython.Runtime.Binding; |
@@ -388,7 +386,7 @@ private Expression AddReturnChecks(CodeContext context, DynamicMetaObject[] args |
388 | 386 | typeof(PythonOps).GetMethod(nameof(PythonOps.MakeTuple)), |
389 | 387 | Expression.NewArrayInit( |
390 | 388 | typeof(object), |
391 | | - ArrayUtils.ConvertAll(args, x => Utils.Convert(x.Expression, typeof(object))) |
| 389 | + Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(args, x => Utils.Convert(x.Expression, typeof(object))) |
392 | 390 | ) |
393 | 391 | ) |
394 | 392 | ); |
@@ -609,7 +607,7 @@ private INativeType GetNativeReturnType() { |
609 | 607 | #endif |
610 | 608 |
|
611 | 609 | method.Emit(OpCodes.Ldarg_0); |
612 | | - method.Emit(OpCodes.Calli, GetCalliSignature(convention, sig, calliRetType)); |
| 610 | + method.EmitCalli(OpCodes.Calli, convention, calliRetType, sig.Select(x => x.NativeType).ToArray()); |
613 | 611 |
|
614 | 612 | // if we have a return value we need to store it and marshal to Python |
615 | 613 | // before we run any cleanup code. |
@@ -960,5 +958,19 @@ public string __repr__(CodeContext context) { |
960 | 958 | } |
961 | 959 | } |
962 | 960 | } |
| 961 | + |
| 962 | +#if NETSTANDARD2_0 |
| 963 | +#nullable enable |
| 964 | + internal static class ILGeneratorExtensions { |
| 965 | + private static MethodInfo? EmitCalliMethodInfo = typeof(ILGenerator).GetMethod("EmitCalli", new Type[] { typeof(OpCode), typeof(CallingConvention), typeof(Type), typeof(Type[]) }); |
| 966 | + |
| 967 | + public static void EmitCalli(this ILGenerator ilgen, OpCode opcode, CallingConvention unmanagedCallConv, Type? returnType, Type[]? parameterTypes) { |
| 968 | + // should exist in runtimes of interest, but just in case, let it throw if the method doesn't exist... |
| 969 | + EmitCalliMethodInfo!.Invoke(ilgen, new object[] { opcode, unmanagedCallConv, returnType!, parameterTypes! }); |
| 970 | + } |
| 971 | + } |
| 972 | +#nullable restore |
| 973 | +#endif |
963 | 974 | } |
| 975 | + |
964 | 976 | #endif |
0 commit comments