Drop underscores in named function expressions

This commit is contained in:
Joshua Bell 2013-08-17 15:30:46 -07:00
parent 51b28d5320
commit e44c2069e8
3 changed files with 40 additions and 40 deletions

View File

@ -290,7 +290,7 @@ this.basic = (function() {
} }
}; };
this.get = function _get(subscripts) { this.get = function get(subscripts) {
if (!array) { if (!array) {
this.dim(subscripts.map(function() { return 10; })); this.dim(subscripts.map(function() { return 10; }));
} }
@ -299,7 +299,7 @@ this.basic = (function() {
return array[offset(dimensions, subscripts)]; return array[offset(dimensions, subscripts)];
}; };
this.set = function _set(subscripts, value) { this.set = function set(subscripts, value) {
if (!array) { if (!array) {
this.dim(subscripts.map(function() { return 10; })); this.dim(subscripts.map(function() { return 10; }));
} }
@ -355,7 +355,7 @@ this.basic = (function() {
regexUnquotedString = /^[^:,\r\n]*/, regexUnquotedString = /^[^:,\r\n]*/,
regexComma = /^,/; regexComma = /^,/;
return function _parseDataInput(stream, items) { return function parseDataInput(stream, items) {
do { do {
stream.match(regexWhitespace); stream.match(regexWhitespace);
@ -372,7 +372,7 @@ this.basic = (function() {
} ()); } ());
basic.compile = function _compile(source) { basic.compile = function compile(source) {
"use strict"; "use strict";
function vartype(name) { function vartype(name) {
@ -1021,25 +1021,25 @@ this.basic = (function() {
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
'div': function _div(n, d) { 'div': function div(n, d) {
var r = n / d; var r = n / d;
if (!isFinite(r)) { runtime_error(ERRORS.DIVISION_BY_ZERO); } if (!isFinite(r)) { runtime_error(ERRORS.DIVISION_BY_ZERO); }
return r; return r;
}, },
'fn': function _fn(name, arg) { 'fn': function fn(name, arg) {
if (!{}.hasOwnProperty.call(state.functions, name)) { if (!{}.hasOwnProperty.call(state.functions, name)) {
runtime_error(ERRORS.UNDEFINED_FUNCTION); runtime_error(ERRORS.UNDEFINED_FUNCTION);
} }
return state.functions[name](arg); return state.functions[name](arg);
}, },
'checkFinite': function _checkFinite(n) { 'checkFinite': function checkFinite(n) {
if (!isFinite(n)) { runtime_error(ERRORS.OVERFLOW); } if (!isFinite(n)) { runtime_error(ERRORS.OVERFLOW); }
return n; return n;
}, },
'toint': function _toint(n) { 'toint': function toint(n) {
n = n >> 0; n = n >> 0;
if (n > 0x7fff || n < -0x8000) { runtime_error(ERRORS.ILLEGAL_QUANTITY); } if (n > 0x7fff || n < -0x8000) { runtime_error(ERRORS.ILLEGAL_QUANTITY); }
return n; return n;
@ -1298,7 +1298,7 @@ this.basic = (function() {
var lookahead = nextToken(); var lookahead = nextToken();
match = function _match(type, value) { match = function match(type, value) {
if (!lookahead) { if (!lookahead) {
parse_error("Syntax error: Expected " + type + ", saw end of file"); parse_error("Syntax error: Expected " + type + ", saw end of file");
@ -1321,7 +1321,7 @@ this.basic = (function() {
return token[type]; return token[type];
}; };
test = function _test(type, value, consume) { test = function test(type, value, consume) {
if (lookahead && {}.hasOwnProperty.call(lookahead, type) && if (lookahead && {}.hasOwnProperty.call(lookahead, type) &&
(value === (void 0) || lookahead[type] === value)) { (value === (void 0) || lookahead[type] === value)) {
@ -1339,13 +1339,13 @@ this.basic = (function() {
return false; return false;
}; };
endOfStatement = function _endOfStatement() { endOfStatement = function endOfStatement() {
return !lookahead || return !lookahead ||
{}.hasOwnProperty.call(lookahead, 'separator') || {}.hasOwnProperty.call(lookahead, 'separator') ||
{}.hasOwnProperty.call(lookahead, 'lineNumber'); {}.hasOwnProperty.call(lookahead, 'lineNumber');
}; };
endOfProgram = function _endOfProgram() { endOfProgram = function endOfProgram() {
return !lookahead; return !lookahead;
}; };
@ -2171,7 +2171,7 @@ this.basic = (function() {
return parseProgram(); return parseProgram();
} ()); } ());
program.init = function _init(environment) { program.init = function init(environment) {
// stuff these into runtime library closure/binding // stuff these into runtime library closure/binding
env = environment; env = environment;
@ -2210,7 +2210,7 @@ this.basic = (function() {
state.clear(); state.clear();
state.parsevar = function _parsevar(name, subscripts, input) { state.parsevar = function parsevar(name, subscripts, input) {
if (arguments.length === 2) { if (arguments.length === 2) {
input = arguments[1]; input = arguments[1];
@ -2243,7 +2243,7 @@ this.basic = (function() {
}; };
}; };
program.step = function _step(driver) { program.step = function step(driver) {
function gotoline(line) { function gotoline(line) {
if (!{}.hasOwnProperty.call(program.jump, line)) { if (!{}.hasOwnProperty.call(program.jump, line)) {

8
dos.js
View File

@ -123,7 +123,7 @@ function DOS(tty) {
// Implementation // Implementation
//---------------------------------------------------------------------- //----------------------------------------------------------------------
this.reset = function _reset() { this.reset = function reset() {
buffers = {}; buffers = {};
activebuffer = null; activebuffer = null;
mode = ""; mode = "";
@ -396,7 +396,7 @@ function DOS(tty) {
tty_readChar = tty.readChar; tty_readChar = tty.readChar;
tty_writeChar = tty.writeChar; 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; var string = "", c, data, len, fp, buffer;
if (mode === "r") { if (mode === "r") {
@ -435,7 +435,7 @@ function DOS(tty) {
}; };
tty.readChar = function _dos_readChar(callback) { tty.readChar = function dos_readChar(callback) {
var character = ""; var character = "";
if (mode === "r") { 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 (commandMode) {
if (c === "\r") { if (c === "\r") {

42
tty.js
View File

@ -149,7 +149,7 @@ function TTY(screenElement, keyboardElement, bell) {
setCellByte(x, y, byte); setCellByte(x, y, byte);
} }
this.reset = function _reset() { this.reset = function reset() {
this.hideCursor(); this.hideCursor();
lineCallback = undefined; lineCallback = undefined;
charCallback = undefined; charCallback = undefined;
@ -212,7 +212,7 @@ function TTY(screenElement, keyboardElement, bell) {
self.setCursorPosition(0, 0); self.setCursorPosition(0, 0);
} }
this.clearScreen = function _clearScreen() { this.clearScreen = function clearScreen() {
var x, y; var x, y;
cursorX = self.textWindow.left; cursorX = self.textWindow.left;
cursorY = self.textWindow.top; cursorY = self.textWindow.top;
@ -224,7 +224,7 @@ function TTY(screenElement, keyboardElement, bell) {
}; };
this.clearEOL = function _clearEOL() { this.clearEOL = function clearEOL() {
var x; var x;
for (x = cursorX; x < self.textWindow.left + self.textWindow.width; x += 1) { for (x = cursorX; x < self.textWindow.left + self.textWindow.width; x += 1) {
setCellChar(x, cursorY, 0x20); 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); init(active, 24, active ? 80 : 40);
}; };
@ -271,11 +271,11 @@ function TTY(screenElement, keyboardElement, bell) {
} }
} }
this.scrollScreen = function _scrollScreen() { this.scrollScreen = function scrollScreen() {
scrollUp(); scrollUp();
}; };
this.setTextStyle = function _setTextStyle(style) { this.setTextStyle = function setTextStyle(style) {
curStyle = style; curStyle = style;
}; };
@ -319,7 +319,7 @@ function TTY(screenElement, keyboardElement, bell) {
} }
// Hookable // Hookable
this.writeChar = function _writeChar(c) { this.writeChar = function writeChar(c) {
var code = c.charCodeAt(0), var code = c.charCodeAt(0),
x, y; x, y;
@ -503,22 +503,22 @@ function TTY(screenElement, keyboardElement, bell) {
}; };
// Hookable // Hookable
this.writeString = function _writeString(s) { this.writeString = function writeString(s) {
var i; var i;
for (i = 0; i < s.length; i += 1) { for (i = 0; i < s.length; i += 1) {
this.writeChar(s.charAt(i)); this.writeChar(s.charAt(i));
} }
}; };
this.getScreenSize = function _getScreenSize() { this.getScreenSize = function getScreenSize() {
return { width: screenWidth, height: screenHeight }; return { width: screenWidth, height: screenHeight };
}; };
this.getCursorPosition = function _getCursorPosition() { this.getCursorPosition = function getCursorPosition() {
return { x: cursorX, y: cursorY }; return { x: cursorX, y: cursorY };
}; };
this.setCursorPosition = function _setCursorPosition(x, y) { this.setCursorPosition = function setCursorPosition(x, y) {
if (x !== undefined) { if (x !== undefined) {
x = Math.min(Math.max(Math.floor(x), 0), screenWidth - 1); x = Math.min(Math.max(Math.floor(x), 0), screenWidth - 1);
} else { } else {
@ -541,7 +541,7 @@ function TTY(screenElement, keyboardElement, bell) {
updateCursor(); updateCursor();
}; };
this.showCursor = function _showCursor() { this.showCursor = function showCursor() {
cursorVisible = true; cursorVisible = true;
cursorInterval = setInterval(function() { cursorInterval = setInterval(function() {
cursorState = !cursorState; cursorState = !cursorState;
@ -549,14 +549,14 @@ function TTY(screenElement, keyboardElement, bell) {
}, 500); }, 500);
}; };
this.hideCursor = function _hideCursor() { this.hideCursor = function hideCursor() {
clearInterval(cursorInterval); clearInterval(cursorInterval);
cursorVisible = false; cursorVisible = false;
updateCursor(); updateCursor();
}; };
this.splitScreen = function _splitScreen(splitAt) { this.splitScreen = function splitScreen(splitAt) {
splitPos = splitAt; splitPos = splitAt;
var y; var y;
@ -837,18 +837,18 @@ function TTY(screenElement, keyboardElement, bell) {
} }
this.getButtonState = function _getButtonState(btn) { this.getButtonState = function getButtonState(btn) {
return buttonState[btn]; return buttonState[btn];
}; };
this.focus = function _focus() { this.focus = function focus() {
keyboardElement.focus(); keyboardElement.focus();
}; };
// Hookable // Hookable
this.readLine = function _readLine(callback, prompt) { this.readLine = function readLine(callback, prompt) {
self.writeString(prompt); self.writeString(prompt);
lineCallback = callback; lineCallback = callback;
@ -858,7 +858,7 @@ function TTY(screenElement, keyboardElement, bell) {
// Hookable // Hookable
this.readChar = function _readChar(callback) { this.readChar = function readChar(callback) {
// If there is a key ready, deliver it immediately // If there is a key ready, deliver it immediately
if (keyboardRegister & 0x80) { if (keyboardRegister & 0x80) {
keyboardRegister = keyboardRegister & 0x7f; keyboardRegister = keyboardRegister & 0x7f;
@ -873,12 +873,12 @@ function TTY(screenElement, keyboardElement, bell) {
}; };
this.getKeyboardRegister = function _getKeyboardRegister() { this.getKeyboardRegister = function getKeyboardRegister() {
return keyboardRegister; return keyboardRegister;
}; };
this.clearKeyboardStrobe = function _clearKeyboardStrobe() { this.clearKeyboardStrobe = function clearKeyboardStrobe() {
keyboardRegister = keyboardRegister & 0x7f; keyboardRegister = keyboardRegister & 0x7f;
return keyboardRegister | (keyDown ? 0x80 : 0x00); return keyboardRegister | (keyDown ? 0x80 : 0x00);
}; };
@ -894,7 +894,7 @@ function TTY(screenElement, keyboardElement, bell) {
window.addEvent(keyboardElement, 'keydown', handleKeyDown); window.addEvent(keyboardElement, 'keydown', handleKeyDown);
window.addEvent(keyboardElement, 'keyup', handleKeyUp); window.addEvent(keyboardElement, 'keyup', handleKeyUp);
setInterval(function _blinkFlash() { setInterval(function blinkFlash() {
window.getClassList(styleElem).toggle('jsb-flash'); window.getClassList(styleElem).toggle('jsb-flash');
}, 250); }, 250);
} }