Fix ON GOTO and ON GOSUB better - Should handle edge cases

This commit is contained in:
Sigurdur Sveinn Halldorsson 2016-07-20 20:21:11 +02:00
parent 29e8b8ec70
commit 42eca47f96
1 changed files with 4 additions and 2 deletions

View File

@ -523,10 +523,11 @@ this.basic = (function() {
},
'on_goto': function ON_GOTO(index /* , ...lines */) {
index = Math.floor(index)
if (index < 0 || index > 255) {
runtime_error(ERRORS.ILLEGAL_QUANTITY);
}
index = (index - 1) >> 0;
--index;
var lines = Array.prototype.slice.call(arguments, 1);
if (index >= 0 && index < lines.length) {
@ -543,10 +544,11 @@ this.basic = (function() {
},
'on_gosub': function ON_GOSUB(index /* , ...lines */) {
index = Math.floor(index)
if (index < 0 || index > 255) {
runtime_error(ERRORS.ILLEGAL_QUANTITY);
}
index = (index - 1) >> 0;
--index;
var lines = Array.prototype.slice.call(arguments, 1);
if (index >= 0 && index < lines.length) {
state.stack.push({