Skip to content

Commit da67f6f

Browse files
committed
fixed EvilBeaver#1498 Исправлена обработка вложенных попыток
1 parent 1408492 commit da67f6f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ protected override void VisitTryExceptNode(TryExceptNode node)
885885
var endIndex = AddLineNumber(node.EndLocation.LineNumber,
886886
CodeGenerationFlags.CodeStatistics | CodeGenerationFlags.DebugCode);
887887

888-
AddCommand(OperationCode.EndTry);
888+
AddCommand(OperationCode.EndTry, beginHandler);
889889
CorrectCommandArgument(jmpIndex, endIndex);
890890
}
891891

src/ScriptEngine/Machine/MachineInstance.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,12 @@ private void BeginTry(int exceptBlockAddress)
12271227

12281228
private void EndTry(int arg)
12291229
{
1230-
if (_exceptionsStack.Count > 0 && _exceptionsStack.Peek().HandlerFrame == _currentFrame)
1231-
_exceptionsStack.Pop();
1230+
if (_exceptionsStack.Count > 0)
1231+
{
1232+
var jmpInfo = _exceptionsStack.Peek();
1233+
if (jmpInfo.HandlerFrame == _currentFrame && arg == jmpInfo.HandlerAddress)
1234+
_exceptionsStack.Pop();
1235+
}
12321236
_currentFrame.LastException = null;
12331237
NextInstruction();
12341238
}

0 commit comments

Comments
 (0)