Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ByRefMethodInfoCallInstruction.cs
Go to the documentation of this file.
3
5
7{
8 private readonly ByRefUpdater[] _byrefArgs;
9
10 public override int ProducedStack
11 {
12 get
13 {
14 if (!(_target.ReturnType == typeof(void)))
15 {
16 return 1;
17 }
18 return 0;
19 }
20 }
21
22 internal ByRefMethodInfoCallInstruction(MethodInfo target, int argumentCount, ByRefUpdater[] byrefArgs)
23 : base(target, argumentCount)
24 {
25 _byrefArgs = byrefArgs;
26 }
27
28 public sealed override int Run(InterpretedFrame frame)
29 {
30 int num = frame.StackIndex - _argumentCount;
31 object[] array = null;
32 object obj = null;
33 try
34 {
35 object obj2;
36 if (_target.IsStatic)
37 {
38 array = GetArgs(frame, num, 0);
39 try
40 {
41 obj2 = _target.Invoke(null, array);
42 }
44 {
47 }
48 }
49 else
50 {
51 obj = frame.Data[num];
53 array = GetArgs(frame, num, 1);
54 if (CallInstruction.TryGetLightLambdaTarget(obj, out var lightLambda))
55 {
56 obj2 = InterpretLambdaInvoke(lightLambda, array);
57 }
58 else
59 {
60 try
61 {
62 obj2 = _target.Invoke(obj, array);
63 }
64 catch (TargetInvocationException exception2)
65 {
68 }
69 }
70 }
71 if (_target.ReturnType != typeof(void))
72 {
73 frame.Data[num] = obj2;
74 frame.StackIndex = num + 1;
75 }
76 else
77 {
78 frame.StackIndex = num;
79 }
80 }
81 finally
82 {
83 if (array != null)
84 {
85 ByRefUpdater[] byrefArgs = _byrefArgs;
86 foreach (ByRefUpdater byRefUpdater in byrefArgs)
87 {
88 byRefUpdater.Update(frame, (byRefUpdater.ArgumentIndex == -1) ? obj : array[byRefUpdater.ArgumentIndex]);
89 }
90 }
91 }
92 return 1;
93 }
94}
ByRefMethodInfoCallInstruction(MethodInfo target, int argumentCount, ByRefUpdater[] byrefArgs)
void Update(InterpretedFrame frame, object value)
object InterpretLambdaInvoke(LightLambda targetLambda, object[] args)
static bool TryGetLightLambdaTarget(object instance, [NotNullWhen(true)] out LightLambda lightLambda)
static void UnwrapAndRethrow(TargetInvocationException exception)
object[] GetArgs(InterpretedFrame frame, int first, int skip)
object? Invoke(object? obj, object?[]? parameters)