mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2025-02-19 09:30:46 +00:00
Drop underscores in named function expressions
This commit is contained in:
parent
51b28d5320
commit
e44c2069e8
30
basic.js
30
basic.js
@ -290,7 +290,7 @@ this.basic = (function() {
|
||||
}
|
||||
};
|
||||
|
||||
this.get = function _get(subscripts) {
|
||||
this.get = function get(subscripts) {
|
||||
if (!array) {
|
||||
this.dim(subscripts.map(function() { return 10; }));
|
||||
}
|
||||
@ -299,7 +299,7 @@ this.basic = (function() {
|
||||
return array[offset(dimensions, subscripts)];
|
||||
};
|
||||
|
||||
this.set = function _set(subscripts, value) {
|
||||
this.set = function set(subscripts, value) {
|
||||
if (!array) {
|
||||
this.dim(subscripts.map(function() { return 10; }));
|
||||
}
|
||||
@ -355,7 +355,7 @@ this.basic = (function() {
|
||||
regexUnquotedString = /^[^:,\r\n]*/,
|
||||
regexComma = /^,/;
|
||||
|
||||
return function _parseDataInput(stream, items) {
|
||||
return function parseDataInput(stream, items) {
|
||||
|
||||
do {
|
||||
stream.match(regexWhitespace);
|
||||
@ -372,7 +372,7 @@ this.basic = (function() {
|
||||
} ());
|
||||
|
||||
|
||||
basic.compile = function _compile(source) {
|
||||
basic.compile = function compile(source) {
|
||||
"use strict";
|
||||
|
||||
function vartype(name) {
|
||||
@ -1021,25 +1021,25 @@ this.basic = (function() {
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
'div': function _div(n, d) {
|
||||
'div': function div(n, d) {
|
||||
var r = n / d;
|
||||
if (!isFinite(r)) { runtime_error(ERRORS.DIVISION_BY_ZERO); }
|
||||
return r;
|
||||
},
|
||||
|
||||
'fn': function _fn(name, arg) {
|
||||
'fn': function fn(name, arg) {
|
||||
if (!{}.hasOwnProperty.call(state.functions, name)) {
|
||||
runtime_error(ERRORS.UNDEFINED_FUNCTION);
|
||||
}
|
||||
return state.functions[name](arg);
|
||||
},
|
||||
|
||||
'checkFinite': function _checkFinite(n) {
|
||||
'checkFinite': function checkFinite(n) {
|
||||
if (!isFinite(n)) { runtime_error(ERRORS.OVERFLOW); }
|
||||
return n;
|
||||
},
|
||||
|
||||
'toint': function _toint(n) {
|
||||
'toint': function toint(n) {
|
||||
n = n >> 0;
|
||||
if (n > 0x7fff || n < -0x8000) { runtime_error(ERRORS.ILLEGAL_QUANTITY); }
|
||||
return n;
|
||||
@ -1298,7 +1298,7 @@ this.basic = (function() {
|
||||
|
||||
var lookahead = nextToken();
|
||||
|
||||
match = function _match(type, value) {
|
||||
match = function match(type, value) {
|
||||
|
||||
if (!lookahead) {
|
||||
parse_error("Syntax error: Expected " + type + ", saw end of file");
|
||||
@ -1321,7 +1321,7 @@ this.basic = (function() {
|
||||
return token[type];
|
||||
};
|
||||
|
||||
test = function _test(type, value, consume) {
|
||||
test = function test(type, value, consume) {
|
||||
if (lookahead && {}.hasOwnProperty.call(lookahead, type) &&
|
||||
(value === (void 0) || lookahead[type] === value)) {
|
||||
|
||||
@ -1339,13 +1339,13 @@ this.basic = (function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
endOfStatement = function _endOfStatement() {
|
||||
endOfStatement = function endOfStatement() {
|
||||
return !lookahead ||
|
||||
{}.hasOwnProperty.call(lookahead, 'separator') ||
|
||||
{}.hasOwnProperty.call(lookahead, 'lineNumber');
|
||||
};
|
||||
|
||||
endOfProgram = function _endOfProgram() {
|
||||
endOfProgram = function endOfProgram() {
|
||||
return !lookahead;
|
||||
};
|
||||
|
||||
@ -2171,7 +2171,7 @@ this.basic = (function() {
|
||||
return parseProgram();
|
||||
} ());
|
||||
|
||||
program.init = function _init(environment) {
|
||||
program.init = function init(environment) {
|
||||
|
||||
// stuff these into runtime library closure/binding
|
||||
env = environment;
|
||||
@ -2210,7 +2210,7 @@ this.basic = (function() {
|
||||
|
||||
state.clear();
|
||||
|
||||
state.parsevar = function _parsevar(name, subscripts, input) {
|
||||
state.parsevar = function parsevar(name, subscripts, input) {
|
||||
|
||||
if (arguments.length === 2) {
|
||||
input = arguments[1];
|
||||
@ -2243,7 +2243,7 @@ this.basic = (function() {
|
||||
};
|
||||
};
|
||||
|
||||
program.step = function _step(driver) {
|
||||
program.step = function step(driver) {
|
||||
|
||||
function gotoline(line) {
|
||||
if (!{}.hasOwnProperty.call(program.jump, line)) {
|
||||
|
8
dos.js
8
dos.js
@ -123,7 +123,7 @@ function DOS(tty) {
|
||||
// Implementation
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
this.reset = function _reset() {
|
||||
this.reset = function reset() {
|
||||
buffers = {};
|
||||
activebuffer = null;
|
||||
mode = "";
|
||||
@ -396,7 +396,7 @@ function DOS(tty) {
|
||||
tty_readChar = tty.readChar;
|
||||
tty_writeChar = tty.writeChar;
|
||||
|
||||
tty.readLine = function _dos_readLine(callback, prompt) {
|
||||
tty.readLine = function dos_readLine(callback, prompt) {
|
||||
|
||||
var string = "", c, data, len, fp, buffer;
|
||||
if (mode === "r") {
|
||||
@ -435,7 +435,7 @@ function DOS(tty) {
|
||||
|
||||
};
|
||||
|
||||
tty.readChar = function _dos_readChar(callback) {
|
||||
tty.readChar = function dos_readChar(callback) {
|
||||
|
||||
var character = "";
|
||||
if (mode === "r") {
|
||||
@ -457,7 +457,7 @@ function DOS(tty) {
|
||||
}
|
||||
};
|
||||
|
||||
tty.writeChar = function _dos_writeChar(c) {
|
||||
tty.writeChar = function dos_writeChar(c) {
|
||||
|
||||
if (commandMode) {
|
||||
if (c === "\r") {
|
||||
|
42
tty.js
42
tty.js
@ -149,7 +149,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
setCellByte(x, y, byte);
|
||||
}
|
||||
|
||||
this.reset = function _reset() {
|
||||
this.reset = function reset() {
|
||||
this.hideCursor();
|
||||
lineCallback = undefined;
|
||||
charCallback = undefined;
|
||||
@ -212,7 +212,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
self.setCursorPosition(0, 0);
|
||||
}
|
||||
|
||||
this.clearScreen = function _clearScreen() {
|
||||
this.clearScreen = function clearScreen() {
|
||||
var x, y;
|
||||
cursorX = self.textWindow.left;
|
||||
cursorY = self.textWindow.top;
|
||||
@ -224,7 +224,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
};
|
||||
|
||||
|
||||
this.clearEOL = function _clearEOL() {
|
||||
this.clearEOL = function clearEOL() {
|
||||
var x;
|
||||
for (x = cursorX; x < self.textWindow.left + self.textWindow.width; x += 1) {
|
||||
setCellChar(x, cursorY, 0x20);
|
||||
@ -232,7 +232,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
};
|
||||
|
||||
|
||||
this.setFirmwareActive = function _setFirmwareActive(active) {
|
||||
this.setFirmwareActive = function setFirmwareActive(active) {
|
||||
init(active, 24, active ? 80 : 40);
|
||||
};
|
||||
|
||||
@ -271,11 +271,11 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
}
|
||||
}
|
||||
|
||||
this.scrollScreen = function _scrollScreen() {
|
||||
this.scrollScreen = function scrollScreen() {
|
||||
scrollUp();
|
||||
};
|
||||
|
||||
this.setTextStyle = function _setTextStyle(style) {
|
||||
this.setTextStyle = function setTextStyle(style) {
|
||||
curStyle = style;
|
||||
};
|
||||
|
||||
@ -319,7 +319,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
}
|
||||
|
||||
// Hookable
|
||||
this.writeChar = function _writeChar(c) {
|
||||
this.writeChar = function writeChar(c) {
|
||||
var code = c.charCodeAt(0),
|
||||
x, y;
|
||||
|
||||
@ -503,22 +503,22 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
};
|
||||
|
||||
// Hookable
|
||||
this.writeString = function _writeString(s) {
|
||||
this.writeString = function writeString(s) {
|
||||
var i;
|
||||
for (i = 0; i < s.length; i += 1) {
|
||||
this.writeChar(s.charAt(i));
|
||||
}
|
||||
};
|
||||
|
||||
this.getScreenSize = function _getScreenSize() {
|
||||
this.getScreenSize = function getScreenSize() {
|
||||
return { width: screenWidth, height: screenHeight };
|
||||
};
|
||||
|
||||
this.getCursorPosition = function _getCursorPosition() {
|
||||
this.getCursorPosition = function getCursorPosition() {
|
||||
return { x: cursorX, y: cursorY };
|
||||
};
|
||||
|
||||
this.setCursorPosition = function _setCursorPosition(x, y) {
|
||||
this.setCursorPosition = function setCursorPosition(x, y) {
|
||||
if (x !== undefined) {
|
||||
x = Math.min(Math.max(Math.floor(x), 0), screenWidth - 1);
|
||||
} else {
|
||||
@ -541,7 +541,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
updateCursor();
|
||||
};
|
||||
|
||||
this.showCursor = function _showCursor() {
|
||||
this.showCursor = function showCursor() {
|
||||
cursorVisible = true;
|
||||
cursorInterval = setInterval(function() {
|
||||
cursorState = !cursorState;
|
||||
@ -549,14 +549,14 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
}, 500);
|
||||
};
|
||||
|
||||
this.hideCursor = function _hideCursor() {
|
||||
this.hideCursor = function hideCursor() {
|
||||
clearInterval(cursorInterval);
|
||||
cursorVisible = false;
|
||||
updateCursor();
|
||||
|
||||
};
|
||||
|
||||
this.splitScreen = function _splitScreen(splitAt) {
|
||||
this.splitScreen = function splitScreen(splitAt) {
|
||||
splitPos = splitAt;
|
||||
|
||||
var y;
|
||||
@ -837,18 +837,18 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
}
|
||||
|
||||
|
||||
this.getButtonState = function _getButtonState(btn) {
|
||||
this.getButtonState = function getButtonState(btn) {
|
||||
return buttonState[btn];
|
||||
};
|
||||
|
||||
|
||||
this.focus = function _focus() {
|
||||
this.focus = function focus() {
|
||||
keyboardElement.focus();
|
||||
};
|
||||
|
||||
|
||||
// Hookable
|
||||
this.readLine = function _readLine(callback, prompt) {
|
||||
this.readLine = function readLine(callback, prompt) {
|
||||
self.writeString(prompt);
|
||||
|
||||
lineCallback = callback;
|
||||
@ -858,7 +858,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
|
||||
|
||||
// Hookable
|
||||
this.readChar = function _readChar(callback) {
|
||||
this.readChar = function readChar(callback) {
|
||||
// If there is a key ready, deliver it immediately
|
||||
if (keyboardRegister & 0x80) {
|
||||
keyboardRegister = keyboardRegister & 0x7f;
|
||||
@ -873,12 +873,12 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
};
|
||||
|
||||
|
||||
this.getKeyboardRegister = function _getKeyboardRegister() {
|
||||
this.getKeyboardRegister = function getKeyboardRegister() {
|
||||
return keyboardRegister;
|
||||
};
|
||||
|
||||
|
||||
this.clearKeyboardStrobe = function _clearKeyboardStrobe() {
|
||||
this.clearKeyboardStrobe = function clearKeyboardStrobe() {
|
||||
keyboardRegister = keyboardRegister & 0x7f;
|
||||
return keyboardRegister | (keyDown ? 0x80 : 0x00);
|
||||
};
|
||||
@ -894,7 +894,7 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||
window.addEvent(keyboardElement, 'keydown', handleKeyDown);
|
||||
window.addEvent(keyboardElement, 'keyup', handleKeyUp);
|
||||
|
||||
setInterval(function _blinkFlash() {
|
||||
setInterval(function blinkFlash() {
|
||||
window.getClassList(styleElem).toggle('jsb-flash');
|
||||
}, 250);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user