Fix error handling in PDT evaluator.

This commit is contained in:
2023-04-22 21:09:53 +08:00
parent d72afaa75b
commit a1fd420493
3 changed files with 11 additions and 6 deletions

View File

@@ -64,8 +64,10 @@ namespace Cryville.Common.Pdt {
}
else {
var frame = _stack[_framecount - 1];
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
for (var j = 0; j < fc1; j++) il.Remove(_ip.Previous);
if (frame.Type != PdtInternalType.Error) {
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
for (var j = 0; j < fc1; j++) il.Remove(_ip.Previous);
}
}
}
else if (i is PdtInstruction.Collapse) {
@@ -197,7 +199,7 @@ namespace Cryville.Common.Pdt {
for (int i = 0; i < pc; i++) {
var frame = _stack[--_framecount];
if (frame.Type == PdtInternalType.Error) {
_framecount -= pc - i;
_framecount -= pc - i - 1;
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
return false;
}