From 90db64dcde22364704f0af82641ede2edb6f3373 Mon Sep 17 00:00:00 2001 From: yeti0904 Date: Fri, 17 Nov 2023 20:32:04 +0000 Subject: [PATCH] fix assembler crashing when labels aren't found --- source/assembler/assembler.d | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/assembler/assembler.d b/source/assembler/assembler.d index e908841..ed280a6 100644 --- a/source/assembler/assembler.d +++ b/source/assembler/assembler.d @@ -392,12 +392,10 @@ class Assembler { } if (!valid) { - Error( - format( - "Parameter %d is invalid for instruction %s", i + 1, - inst.name - ) - ); + Error(format( + "Parameter %d is invalid for instruction %s", i + 1, + inst.name + )); exit(1); } } @@ -448,6 +446,13 @@ class Assembler { case NodeType.Identifier: { auto paramNode = cast(IdentifierNode) param; + if (paramNode.name !in labels) { + Error(format( + "No such label: '%s'", paramNode.name + )); + return; + } + addr = labels[paramNode.name]; string[] bsInstructions = [