mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-16 01:14:04 +09:00
fixing null nextLine when IF condition is false and has no ELSE
This commit is contained in:
@@ -37,7 +37,12 @@ lang.refError = function(line, obj) {
|
|||||||
return "Unresolved reference" + ((obj !== undefined) ? " \"" + obj + "\"" : "") + ((line !== undefined) ? (" in "+line) : "");
|
return "Unresolved reference" + ((obj !== undefined) ? " \"" + obj + "\"" : "") + ((line !== undefined) ? (" in "+line) : "");
|
||||||
};
|
};
|
||||||
lang.nowhereToReturn = function(line) { return "RETURN without GOSUB in " + line; };
|
lang.nowhereToReturn = function(line) { return "RETURN without GOSUB in " + line; };
|
||||||
lang.errorinline = function(line, stmt, errobj) { return "Error on statement \""+stmt+"\": " + errobj; };
|
lang.errorinline = function(line, stmt, errobj) {
|
||||||
|
return "Error on statement \""+stmt+"\": " + errobj;
|
||||||
|
};
|
||||||
|
lang.parserError = function(line, errorobj) {
|
||||||
|
return "Parser error in " + line + ": " + errorobj;
|
||||||
|
};
|
||||||
Object.freeze(lang);
|
Object.freeze(lang);
|
||||||
|
|
||||||
function getUsedMemSize() {
|
function getUsedMemSize() {
|
||||||
@@ -1163,7 +1168,7 @@ function SyntaxTreeReturnObj(type, value, nextLine) {
|
|||||||
}
|
}
|
||||||
basicFunctions._gotoCmds = { GOTO:1, GOSUB:1 };
|
basicFunctions._gotoCmds = { GOTO:1, GOSUB:1 };
|
||||||
basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
||||||
var _debugExec = true;
|
var _debugExec = false;
|
||||||
var recWedge = "> ".repeat(recDepth);
|
var recWedge = "> ".repeat(recDepth);
|
||||||
|
|
||||||
if (_debugExec) serial.println(recWedge+"@@ EXECUTE @@");
|
if (_debugExec) serial.println(recWedge+"@@ EXECUTE @@");
|
||||||
@@ -1180,10 +1185,12 @@ basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
|||||||
if (syntaxTree.leaves.length != 2 && syntaxTree.leaves.length != 3) throw lang.syntaxfehler(lnum);
|
if (syntaxTree.leaves.length != 2 && syntaxTree.leaves.length != 3) throw lang.syntaxfehler(lnum);
|
||||||
var testedval = basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[0], recDepth + 1);
|
var testedval = basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[0], recDepth + 1);
|
||||||
|
|
||||||
serial.println(recWedge+"testedval:");
|
if (_debugExec) {
|
||||||
serial.println(recWedge+"type="+testedval.type);
|
serial.println(recWedge+"testedval:");
|
||||||
serial.println(recWedge+"value="+testedval.value);
|
serial.println(recWedge+"type="+testedval.type);
|
||||||
serial.println(recWedge+"nextLine="+testedval.nextLine);
|
serial.println(recWedge+"value="+testedval.value);
|
||||||
|
serial.println(recWedge+"nextLine="+testedval.nextLine);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var iftest = basicInterpreterStatus.builtin["TEST"](lnum, [testedval]);
|
var iftest = basicInterpreterStatus.builtin["TEST"](lnum, [testedval]);
|
||||||
@@ -1192,6 +1199,8 @@ basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
|||||||
return basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[2], recDepth + 1);
|
return basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[2], recDepth + 1);
|
||||||
else if (iftest)
|
else if (iftest)
|
||||||
return basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[1], recDepth + 1);
|
return basicFunctions._executeSyntaxTree(lnum, syntaxTree.leaves[1], recDepth + 1);
|
||||||
|
else
|
||||||
|
return new SyntaxTreeReturnObj("null", undefined, lnum + 1);
|
||||||
}
|
}
|
||||||
catch (eeeee) {
|
catch (eeeee) {
|
||||||
throw lang.errorinline(lnum, "TEST", eeeee);
|
throw lang.errorinline(lnum, "TEST", eeeee);
|
||||||
@@ -1244,7 +1253,7 @@ basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
|||||||
};
|
};
|
||||||
// @returns: line number for the next command, normally (lnum + 1); if GOTO or GOSUB was met, returns its line number
|
// @returns: line number for the next command, normally (lnum + 1); if GOTO or GOSUB was met, returns its line number
|
||||||
basicFunctions._interpretLine = function(lnum, cmd) {
|
basicFunctions._interpretLine = function(lnum, cmd) {
|
||||||
var _debugprintHighestLevel = true;
|
var _debugprintHighestLevel = false;
|
||||||
|
|
||||||
// TOKENISE
|
// TOKENISE
|
||||||
var tokenisedObject = basicFunctions._tokenise(lnum, cmd);
|
var tokenisedObject = basicFunctions._tokenise(lnum, cmd);
|
||||||
@@ -1265,7 +1274,12 @@ basicFunctions._interpretLine = function(lnum, cmd) {
|
|||||||
|
|
||||||
|
|
||||||
// EXECUTE
|
// EXECUTE
|
||||||
return execResult.nextLine;
|
try {
|
||||||
|
return execResult.nextLine;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw lang.parserError(lnum, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // end INTERPRETLINE
|
}; // end INTERPRETLINE
|
||||||
|
|||||||
Reference in New Issue
Block a user