From b2330dfa6c6bf1280c15116cdd919e45a9019d9e Mon Sep 17 00:00:00 2001 From: arookas Date: Sun, 31 Jan 2016 21:25:50 -0500 Subject: [PATCH] Refactored break/continue compilation. I didn't like the null overload usage. I might remove the overload completely later. --- ssc/ast/nodes.flow.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ssc/ast/nodes.flow.cs b/ssc/ast/nodes.flow.cs index c9b4f6f..d6f655d 100644 --- a/ssc/ast/nodes.flow.cs +++ b/ssc/ast/nodes.flow.cs @@ -155,7 +155,14 @@ namespace arookas { public override void Compile(sunCompiler compiler) { var point = compiler.Binary.WriteJMP(); - if (!compiler.Context.Loops.AddBreak(point, IsNamed ? NameLabel.Value : null)) { + var success = true; + if (IsNamed) { + success = compiler.Context.Loops.AddBreak(point, NameLabel.Value); + } + else { + success = compiler.Context.Loops.AddBreak(point); + } + if (!success) { throw new sunBreakException(this); } } @@ -170,7 +177,14 @@ namespace arookas { public override void Compile(sunCompiler compiler) { var point = compiler.Binary.WriteJMP(); - if (!compiler.Context.Loops.AddContinue(point, IsNamed ? NameLabel.Value : null)) { + var success = true; + if (IsNamed) { + success = compiler.Context.Loops.AddContinue(point, NameLabel.Value); + } + else { + success = compiler.Context.Loops.AddContinue(point); + } + if (!success) { throw new sunContinueException(this); } }