Implement CALL-3288; resolves #8

This commit is contained in:
Joshua Bell 2014-12-27 17:51:21 -07:00
parent ef4ed17f37
commit 7a01309073
3 changed files with 780 additions and 761 deletions

View File

@ -451,6 +451,16 @@ this.basic = (function() {
};
call_table = {
0xD683: function() { // Clear stack
state.stack = [];
},
0xF328: function() { // Pop error entry off stack
var stack_record = state.stack.pop();
if (!{}.hasOwnProperty.call(stack_record, 'resume_stmt_index')) {
runtime_error(ERRORS.SYNTAX_ERROR);
return;
}
},
0xF3E4: function() { // Reveal hi-res page 1
if (!env.hires) { runtime_error('Hires graphics not supported'); }
env.display.setState('graphics', true, 'full', true, 'page1', true, 'lores', false);
@ -465,9 +475,6 @@ this.basic = (function() {
if (!hires) { runtime_error('Hires graphics not supported'); }
hires.clear(hires.color);
},
0xD683: function() { // Clear stack
state.stack = [];
},
0xFBF4: function() { // Move cursor right
if (env.tty.cursorRight) { env.tty.cursorRight(); }
},
@ -563,14 +570,11 @@ this.basic = (function() {
},
'pop': function POP() {
var stack_record;
while (state.stack.length) {
stack_record = state.stack.pop();
if ({}.hasOwnProperty.call(stack_record, 'gosub_return')) {
return;
}
var stack_record = state.stack.pop();
if (!{}.hasOwnProperty.call(stack_record, 'gosub_return')) {
runtime_error(ERRORS.RETURN_WITHOUT_GOSUB);
return;
}
runtime_error(ERRORS.RETURN_WITHOUT_GOSUB);
},
'for': function FOR(varname, from, to, step) {
@ -640,8 +644,13 @@ this.basic = (function() {
},
'resume': function RESUME() {
state.stmt_index = state.resume_stmt_index;
state.line_number = state.resume_line_number;
var stack_record = state.stack.pop();
if (!{}.hasOwnProperty.call(stack_record, 'resume_stmt_index')) {
runtime_error(ERRORS.SYNTAX_ERROR);
return;
}
state.line_number = stack_record.resume_line_number;
state.stmt_index = stack_record.resume_stmt_index;
},
//////////////////////////////////////////////////////////////////////
@ -2175,8 +2184,6 @@ this.basic = (function() {
onerr_code: 255,
onerr_handler: void 0,
resume_stmt_index: 0,
resume_line_number: 0,
trace_mode: false,
input_continuation: null,
@ -2319,8 +2326,10 @@ this.basic = (function() {
if (rte instanceof basic.RuntimeError) {
state.onerr_code = rte.code || 0;
if (state.onerr_handler !== void 0) {
state.resume_stmt_index = state.stmt_index;
state.resume_line_number = state.line_number;
state.stack.push({
resume_stmt_index: state.stmt_index,
resume_line_number: state.line_number
});
gotoline(state.onerr_handler);
return basic.STATE_RUNNING;
} else if (rte.code === ERRORS.REENTER[0]) {

View File

@ -211,10 +211,11 @@ can be literals (unquoted strings), strings, or numbers
<dt>CALL <var>aexpr</var><dd>Call native routine
<ul>
<li><code>CALL -3288</code> - pop <code>ONERR</code>/<code>RESUME</code> entry from stack
<li><code>CALL -3100</code> - reveal hi-res page 1
<li><code>CALL -3086</code> - clear current hi-res page to black
<li><code>CALL -3082</code> - clear current hi-res page to current color
<li><code>CALL 54951</code> - clear stack (cancel pending <code>FOR</code>-<code>NEXT</code> loops and <code>GOSUB</code>s)
<li><code>CALL 54951</code> - clear stack (pop all <code>FOR</code>/<code>NEXT</code>, <code>GOSUB</code>/<code>RETURN</code>, and <code>ONERR</code>/<code>RESUME</code> entries)
<li><code>CALL -1036</code> - move cursor right
<li><code>CALL -1008</code> - move cursor left
<li><code>CALL -998</code> - move cursor up

File diff suppressed because it is too large Load Diff