From 51527ae95bdb04c4660630c206e1147d0cc00e4d Mon Sep 17 00:00:00 2001 From: jacquej96 <32223123+jacquej96@users.noreply.github.com> Date: Wed, 16 Oct 2019 13:55:12 -0400 Subject: [PATCH] Reuse error function throughout file --- Server/src/main/resources/static/js/editor.js | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/Server/src/main/resources/static/js/editor.js b/Server/src/main/resources/static/js/editor.js index 4d07294..1b374a0 100644 --- a/Server/src/main/resources/static/js/editor.js +++ b/Server/src/main/resources/static/js/editor.js @@ -54,12 +54,7 @@ function checkForEQUInstruction(line, result, currentLine) { result.labels.push(tokens[0]); return true; } else { - result.annotations.push({ - row: currentLine, - column: 0, - text: "Usage: constant_name EQU immediate_value", - type: "error" - }); + produceError(result, currentLine, "Usage: constant_name EQU immediate_value"); return true; } } else { @@ -102,12 +97,7 @@ function checkForORGInstruction(line, result, currentLine) { if (!isNaN(num) && num === Math.floor(num)) { return true; } else { - result.annotations.push({ - row: currentLine, - column: 0, - text: "Invalid operand: " + tokens[1], - type: "error" - }); + produceError(result, currentLine, "Invalid operand: " + tokens[1]); return true } } @@ -140,13 +130,7 @@ function parseDWInstruction(line, result, currentLine) { var strText = values[i].substr(1, values[i].length - 2); if (strText.match(MALFORMED_UTF16_RE) != null) { - - result.annotations.push({ - row: currentLine, - column: 0, - text: "Malformed UTF-16 escape sequence", - type: "error" - }); + produceError(result, currentLine, "Malformed UTF-16 escape sequence"); return true; } @@ -157,15 +141,8 @@ function parseDWInstruction(line, result, currentLine) { // console.log("is Imm " + values[i]); } else { - - result.annotations.push({ - row: currentLine, - column: 0, - text: "Usage: DW IMM, IMM ...", - type: "error" - }); + produceError(result, currentLine, "Usage: DW IMM, IMM ..."); return true; - } }