Resolve issue where code wouldnt fully execute

This commit is contained in:
Deukhoofd 2018-12-12 17:58:35 +01:00
parent 898a18a60a
commit 2bdb469b6f
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 8 additions and 3 deletions

View File

@ -490,11 +490,16 @@ namespace Upsilon.Evaluator
throw new Exception($"Cannot find variable: '{e.Variable.VariableSymbol.Name}'"); throw new Exception($"Cannot find variable: '{e.Variable.VariableSymbol.Name}'");
} }
private Queue<BoundStatement> _todoStatements; private readonly Stack<BoundStatement> _todoStatements = new Stack<BoundStatement>();
private void EvaluateBoundBlockStatement(BoundBlockStatement boundBlockStatement) private void EvaluateBoundBlockStatement(BoundBlockStatement boundBlockStatement)
{ {
_todoStatements = new Queue<BoundStatement>(boundBlockStatement.Statements); for (var index = boundBlockStatement.Statements.Length - 1; index >= 0; index--)
{
var s = boundBlockStatement.Statements[index];
_todoStatements.Push(s);
}
while (true) while (true)
{ {
if (DebugSession.Debugging) if (DebugSession.Debugging)
@ -508,7 +513,7 @@ namespace Upsilon.Evaluator
return; return;
if (_todoStatements.Count == 0) if (_todoStatements.Count == 0)
return; return;
var boundStatement = _todoStatements.Dequeue(); var boundStatement = _todoStatements.Pop();
if (DebugSession.DebuggerAttached && boundStatement.HasBreakpoint) if (DebugSession.DebuggerAttached && boundStatement.HasBreakpoint)
{ {
DebugSession.TriggerBreakpoint(Scope); DebugSession.TriggerBreakpoint(Scope);