Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
InterpretedFrame.cs
Go to the documentation of this file.
3
5
6internal sealed class InterpretedFrame
7{
10
11 internal readonly Interpreter Interpreter;
12
14
15 private readonly int[] _continuations;
16
17 private int _continuationIndex;
18
20
21 private object _pendingValue;
22
23 public readonly object[] Data;
24
25 public readonly IStrongBox[] Closure;
26
27 public int StackIndex;
28
29 public int InstructionIndex;
30
31 public string Name => Interpreter.Name;
32
34
36 {
38 StackIndex = interpreter.LocalCount;
39 Data = new object[StackIndex + interpreter.Instructions.MaxStackDepth];
40 int maxContinuationDepth = interpreter.Instructions.MaxContinuationDepth;
42 {
44 }
48 }
49
54
55 public void Push(object value)
56 {
57 Data[StackIndex++] = value;
58 }
59
60 public void Push(bool value)
61 {
62 Data[StackIndex++] = (value ? Utils.BoxedTrue : Utils.BoxedFalse);
63 }
64
65 public void Push(int value)
66 {
68 }
69
70 public void Push(byte value)
71 {
72 Data[StackIndex++] = value;
73 }
74
75 public void Push(sbyte value)
76 {
77 Data[StackIndex++] = value;
78 }
79
80 public void Push(short value)
81 {
82 Data[StackIndex++] = value;
83 }
84
85 public void Push(ushort value)
86 {
87 Data[StackIndex++] = value;
88 }
89
90 public object Pop()
91 {
92 return Data[--StackIndex];
93 }
94
95 internal void SetStackDepth(int depth)
96 {
97 StackIndex = Interpreter.LocalCount + depth;
98 }
99
100 public object Peek()
101 {
102 return Data[StackIndex - 1];
103 }
104
105 public void Dup()
106 {
108 Data[stackIndex] = Data[stackIndex - 1];
110 }
111
113 {
114 InterpretedFrame frame = this;
115 do
116 {
117 yield return new InterpretedFrameInfo(frame.Name, frame.GetDebugInfo(frame.InstructionIndex));
118 frame = frame.Parent;
119 }
120 while (frame != null);
121 }
122
130
132 {
134 s_currentFrame = this;
135 return _parent = parent;
136 }
137
138 internal void Leave(InterpretedFrame prevFrame)
139 {
140 s_currentFrame = prevFrame;
141 }
142
143 internal bool IsJumpHappened()
144 {
145 return _pendingContinuation >= 0;
146 }
147
148 public void RemoveContinuation()
149 {
151 }
152
157
159 {
161 SetStackDepth(runtimeLabel.StackDepth);
162 return runtimeLabel.Index - InstructionIndex;
163 }
164
166 {
168 if (runtimeLabel.ContinuationStackDepth < _continuationIndex)
169 {
171 SetStackDepth(runtimeLabel2.StackDepth);
172 return runtimeLabel2.Index - InstructionIndex;
173 }
174 SetStackDepth(runtimeLabel.StackDepth);
176 {
177 Data[StackIndex - 1] = _pendingValue;
178 }
181 return runtimeLabel.Index - InstructionIndex;
182 }
183
191
193 {
194 _pendingValue = Pop();
195 _pendingContinuation = (int)Pop();
196 }
197
198 public int Goto(int labelIndex, object value, bool gotoExceptionHandler)
199 {
201 if (_continuationIndex == runtimeLabel.ContinuationStackDepth)
202 {
203 SetStackDepth(runtimeLabel.StackDepth);
205 {
206 Data[StackIndex - 1] = value;
207 }
208 return runtimeLabel.Index - InstructionIndex;
209 }
213 }
214}
static DebugInfo GetMatchingDebugInfo(DebugInfo[] debugInfos, int index)
Definition DebugInfo.cs:37
IEnumerable< InterpretedFrameInfo > GetStackTraceDebugInfo()
int Goto(int labelIndex, object value, bool gotoExceptionHandler)
InterpretedFrame(Interpreter interpreter, IStrongBox[] closure)
static readonly object BoxedFalse
Definition Utils.cs:8