Rename vars

This commit is contained in:
jacquej96 2019-10-16 14:09:58 -04:00 committed by GitHub
parent 51527ae95b
commit 8cbf2b45c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -237,11 +237,11 @@ function getOperandType(text, result) {
} }
function produceError(result, currentLine, errorString) { function produceError(result, currentLine, explanation) {
result.annotations.push({ result.annotations.push({
row: currentLine, row: currentLine,
column: 0, column: 0,
text: errorString, text: explanation,
type: "error" type: "error"
}); });
} }
@ -289,23 +289,23 @@ function parseInstruction(line, result, currentLine) {
return; return;
} }
var strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length, line.indexOf(',')); var op1 = line.substring(line.indexOf(mnemonic) + mnemonic.length, line.indexOf(','));
var strO2 = line.substring(line.indexOf(',') + 1).trim(); var op2 = line.substring(line.indexOf(',') + 1).trim();
//Validate operand type //Validate operand type
var o1Type = getOperandType(strO1, result); var op1Type = getOperandType(op1, result);
var o2Type = getOperandType(strO2, result); var op2Type = getOperandType(op2, result);
if (o1Type === OPERAND_INVALID) { if (op1Type === OPERAND_INVALID) {
produceError(result, currentLine, "Invalid operand: " + strO1); produceError(result, currentLine, "Invalid operand: " + op1);
return; return;
} }
if (o2Type === OPERAND_INVALID) { if (op2Type === OPERAND_INVALID) {
produceError(result, currentLine, "Invalid operand: " + strO2); produceError(result, currentLine, "Invalid operand: " + op2);
return; return;
} }
//Check for illegal operand combos: //Check for illegal operand combos:
if (o1Type === OPERAND_IMM) { if (op1Type === OPERAND_IMM) {
produceError(result, currentLine, "Destination operand can't be an immediate value"); produceError(result, currentLine, "Destination operand can't be an immediate value");
} }
@ -317,16 +317,16 @@ function parseInstruction(line, result, currentLine) {
return; return;
} }
strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length).trim(); var op1 = line.substring(line.indexOf(mnemonic) + mnemonic.length).trim();
//Validate operand type //Validate operand type
if (getOperandType(strO1, result) === OPERAND_INVALID) { if (getOperandType(op1, result) === OPERAND_INVALID) {
produceError(result, currentLine, "Invalid operand: " + strO1); produceError(result, currentLine, "Invalid operand: " + op1);
} }
if (new RegExp('\\b(?:seta|setnbe|setae|setnb|setnc|setbe|setna|setb|setc|setnae|sete|setz|setne|setnz|setg|setnle|setge|setnl|setle|setng|setl|setnge|seto|setno|sets|setns)\\b').test(mnemonic.toLowerCase())) { if (new RegExp('\\b(?:seta|setnbe|setae|setnb|setnc|setbe|setna|setb|setc|setnae|sete|setz|setne|setnz|setg|setnle|setge|setnl|setle|setng|setl|setnge|seto|setno|sets|setns)\\b').test(mnemonic.toLowerCase())) {
if (getOperandType(strO1, result) === OPERAND_IMM) { if (getOperandType(op1, result) === OPERAND_IMM) {
produceError(result, currentLine, "Invalid operand type: " + strO1); produceError(result, currentLine, "Invalid operand type: " + op1);
} }
} }