From 2bdb469b6f1247e03c96432929ba5d8868c2bf58 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 12 Dec 2018 17:58:35 +0100 Subject: [PATCH] Resolve issue where code wouldnt fully execute --- Upsilon/Evaluator/Evaluator.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Upsilon/Evaluator/Evaluator.cs b/Upsilon/Evaluator/Evaluator.cs index c154bfb..f4ab525 100644 --- a/Upsilon/Evaluator/Evaluator.cs +++ b/Upsilon/Evaluator/Evaluator.cs @@ -490,11 +490,16 @@ namespace Upsilon.Evaluator throw new Exception($"Cannot find variable: '{e.Variable.VariableSymbol.Name}'"); } - private Queue _todoStatements; + private readonly Stack _todoStatements = new Stack(); private void EvaluateBoundBlockStatement(BoundBlockStatement boundBlockStatement) { - _todoStatements = new Queue(boundBlockStatement.Statements); + for (var index = boundBlockStatement.Statements.Length - 1; index >= 0; index--) + { + var s = boundBlockStatement.Statements[index]; + _todoStatements.Push(s); + } + while (true) { if (DebugSession.Debugging) @@ -508,7 +513,7 @@ namespace Upsilon.Evaluator return; if (_todoStatements.Count == 0) return; - var boundStatement = _todoStatements.Dequeue(); + var boundStatement = _todoStatements.Pop(); if (DebugSession.DebuggerAttached && boundStatement.HasBreakpoint) { DebugSession.TriggerBreakpoint(Scope);