This commit is contained in:
Ryan Dahl 2011-01-24 10:55:30 -08:00
Родитель f263b29141
Коммит 9e976abad9
11 изменённых файлов: 73 добавлений и 51 удалений

Просмотреть файл

@ -7,14 +7,14 @@ exports.port = 5858;
exports.start = function() {
if (process.argv.length < 3) {
console.error("Usage: node debug script.js");
console.error('Usage: node debug script.js');
process.exit(1);
}
var interface = new Interface();
process.on('uncaughtException', function (e) {
process.on('uncaughtException', function(e) {
console.error("There was an internal error in Node's debugger. " +
"Please report this bug.");
'Please report this bug.');
console.error(e.message);
console.error(e.stack);
if (interface.child) interface.child.kill();
@ -260,7 +260,7 @@ Client.prototype.reqEval = function(expression, cb) {
}
// Otherwise we need to get the current frame to see which scopes it has.
this.reqBacktrace(function (bt) {
this.reqBacktrace(function(bt) {
var frame = bt.frames[self.currentFrame];
var evalFrames = frame.scopes.map(function(s) {
@ -414,7 +414,7 @@ Client.prototype.mirrorObject = function(handle, cb) {
this.reqLookup(propertyRefs, function(res) {
if (!res.success) {
console.error("problem with reqLookup");
console.error('problem with reqLookup');
if (cb) cb(handle);
return;
}
@ -479,7 +479,7 @@ Client.prototype.fullTrace = function(cb) {
// column: 2,
// sourceLineText: ' debugger;',
// scopes: [ { type: 1, index: 0 }, { type: 0, index: 1 } ],
// text: '#00 blah() /home/ryan/projects/node/test-debug.js line 8 column 3 (position 161)' }
// text: '#00 blah() /home/ryan/projects/node/test-debug.js l...' }
refs.push(frame.script.ref);
refs.push(frame.func.ref);
refs.push(frame.receiver.ref);
@ -496,7 +496,7 @@ Client.prototype.fullTrace = function(cb) {
if (cb) cb(trace);
});
});
}
};
@ -516,7 +516,7 @@ var commands = [
'run',
'scripts',
'step',
'version',
'version'
];
@ -565,13 +565,15 @@ function SourceInfo(body) {
// "node debug"
function Interface() {
var self = this;
var term = this.term =
readline.createInterface(process.stdin, process.stdout, function (line) {
return self.complete(line);
});
var child;
var client;
var term;
function complete(line) {
return self.complete(line);
}
var term = readline.createInterface(process.stdin, process.stdout, complete);
this.term = term;
process.on('exit', function() {
self.killChild();

Просмотреть файл

@ -203,8 +203,8 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
env = options.env || process.env;
customFds = options.customFds || [-1, -1, -1];
setsid = options.setsid ? true : false;
uid = options.hasOwnProperty("uid") ? options.uid : -1;
gid = options.hasOwnProperty("gid") ? options.gid : -1;
uid = options.hasOwnProperty('uid') ? options.uid : -1;
gid = options.hasOwnProperty('gid') ? options.gid : -1;
}
var envPairs = [];

Просмотреть файл

@ -942,7 +942,7 @@ Agent.prototype.appendMessage = function(options) {
Agent.prototype._removeSocket = function(socket) {
var i = this.sockets.indexOf(socket);
if (i >= 0) this.sockets.splice(i, 1);
}
};
Agent.prototype._establishNewConnection = function() {
@ -951,10 +951,10 @@ Agent.prototype._establishNewConnection = function() {
// Grab a new "socket". Depending on the implementation of _getConnection
// this could either be a raw TCP socket or a TLS stream.
var socket = this._getConnection(this.host, this.port, function () {
var socket = this._getConnection(this.host, this.port, function() {
socket._httpConnecting = false;
self.emit('connect'); // mostly for the shim.
debug("Agent _getConnection callback");
debug('Agent _getConnection callback');
self._cycle();
});
@ -972,10 +972,10 @@ Agent.prototype._establishNewConnection = function() {
parser.incoming = null;
socket.on('error', function(err) {
debug("AGENT SOCKET ERROR: " + err.message);
var req;
debug('AGENT SOCKET ERROR: ' + err.message);
var req;
if (socket._httpMessage) {
req = socket._httpMessage
req = socket._httpMessage;
} else if (self.queue.length) {
req = self.queue.shift();
} else {
@ -1105,8 +1105,8 @@ Agent.prototype._establishNewConnection = function() {
// Sub-classes can overwrite this method with e.g. something that supplies
// TLS streams.
Agent.prototype._getConnection = function(host, port, cb) {
debug("Agent connected!");
var c = net.createConnection(port, host);
debug('Agent connected!');
var c = net.createConnection(port, host);
c.on('connect', cb);
return c;
};
@ -1116,7 +1116,8 @@ Agent.prototype._getConnection = function(host, port, cb) {
// waiting sockets. If a waiting socket cannot be found, it will
// start the process of establishing one.
Agent.prototype._cycle = function() {
debug("Agent _cycle sockets=" + this.sockets.length + " queue=" + this.queue.length);
debug('Agent _cycle sockets=' + this.sockets.length +
' queue=' + this.queue.length);
var self = this;
var first = this.queue[0];
@ -1131,7 +1132,7 @@ Agent.prototype._cycle = function() {
// If the socket doesn't already have a message it's sending out
// and the socket is available for writing...
if (!socket._httpMessage && (socket.writable && socket.readable)) {
debug("Agent found socket, shift");
debug('Agent found socket, shift');
// We found an available connection!
this.queue.shift(); // remove first from queue.
first.assignSocket(socket);
@ -1159,7 +1160,7 @@ Agent.prototype._cycle = function() {
// TODO currently we never remove agents from this hash. This is a small
// memory leak. Have a 2 second timeout after a agent's sockets are to try
// to remove it?
var agents = {}
var agents = {};
function getAgent(host, port) {
@ -1220,7 +1221,7 @@ function Client(port, host) {
});
// proxy upgrade events upwards;
this.agent.on('upgrade', function (res, socket, upgradeHead) {
this.agent.on('upgrade', function(res, socket, upgradeHead) {
if (self.listeners('upgrade').length) {
self.emit('upgrade', res, socket, upgradeHead);
} else {

Просмотреть файл

@ -12,7 +12,7 @@ function Module(id, parent) {
this.loaded = false;
this.exited = false;
this.children = [];
};
}
module.exports = Module;
// Set the environ variable NODE_MODULE_CONTEXTS=1 to make node load all
@ -35,9 +35,11 @@ if (process.env.NODE_DEBUG && /module/.test(process.env.NODE_DEBUG)) {
};
}
// We use this alias for the preprocessor that filters it out
var debug = Module._debug;
// given a module name, and a list of paths to test, returns the first
// matching file in the following precedence.
//
@ -93,12 +95,12 @@ Module._findPath = function(request, paths) {
if (!filename) {
// try it with each of the extensions
filename = tryExtensions(basePath)
filename = tryExtensions(basePath);
}
if (!filename) {
// try it with each of the extensions at "index"
filename = tryExtensions(path.resolve(basePath, 'index'))
filename = tryExtensions(path.resolve(basePath, 'index'));
}
if (filename) {
@ -107,7 +109,8 @@ Module._findPath = function(request, paths) {
}
}
return false;
}
};
Module._resolveLookupPaths = function(request, parent) {
if (NativeModule.exists(request)) {
@ -143,7 +146,7 @@ Module._resolveLookupPaths = function(request, parent) {
' set ID to: ' + id + ' from ' + parent.id);
return [id, [path.dirname(parent.filename)]];
}
};
Module._load = function(request, parent) {
@ -197,7 +200,7 @@ Module._resolveFilename = function(request, parent) {
}
id = filename;
return [id, filename];
}
};
Module.prototype.load = function(filename) {
@ -232,7 +235,7 @@ Module.prototype._compile = function(content, filename) {
// Enable support to add extra extension types
require.extensions = Module._extensions;
require.registerExtension = function() {
throw new Error('require.registerExtension() removed. Use '+
throw new Error('require.registerExtension() removed. Use ' +
'require.extensions instead.');
}
require.cache = Module._cache;

Просмотреть файл

@ -1,7 +1,7 @@
var util = require('util');
var events = require('events');
var stream = require('stream');
var timers = require('timers');;
var timers = require('timers');
var kMinPoolSpace = 128;
var kPoolSize = 40 * 1024;

Просмотреть файл

@ -290,6 +290,7 @@ Interface.prototype._tabComplete = function() {
}
};
function commonPrefix(strings) {
if (!strings || strings.length == 0) {
return '';
@ -305,6 +306,7 @@ function commonPrefix(strings) {
return min;
}
Interface.prototype._deleteLeft = function() {
if (this.cursor > 0 && this.line.length > 0) {
this.line = this.line.slice(0, this.cursor - 1) +
@ -315,11 +317,13 @@ Interface.prototype._deleteLeft = function() {
}
};
Interface.prototype._deleteRight = function() {
this.line = this.line.slice(0, this.cursor) +
this.line.slice(this.cursor + 1, this.line.length);
this._refreshLine();
}
};
Interface.prototype._line = function() {
var line = this._addHistory();
@ -327,6 +331,7 @@ Interface.prototype._line = function() {
this._onLine(line);
};
Interface.prototype._historyNext = function() {
if (this.historyIndex > 0) {
this.historyIndex--;
@ -342,6 +347,7 @@ Interface.prototype._historyNext = function() {
}
};
Interface.prototype._historyPrev = function() {
if (this.historyIndex + 1 < this.history.length) {
this.historyIndex++;
@ -478,7 +484,10 @@ Interface.prototype._ttyWrite = function(s, key) {
case 'f': // forward word
if (this.cursor < this.line.length) {
next_word = this.line.slice(this.cursor, this.line.length).search(/\w/);
next_word = this.line
.slice(this.cursor, this.line.length)
.search(/\w/);
if (next_word !== -1) {
next_non_word = this.line.slice(this.cursor + next_word,
this.line.length).search(/\W/);
@ -495,7 +504,10 @@ Interface.prototype._ttyWrite = function(s, key) {
case 'd': // delete forward word
if (this.cursor < this.line.length) {
next_word = this.line.slice(this.cursor, this.line.length).search(/\w/);
next_word = this.line
.slice(this.cursor, this.line.length)
.search(/\w/);
if (next_word !== -1) {
next_non_word = this.line.slice(this.cursor + next_word,
this.line.length).search(/\W/);
@ -586,4 +598,5 @@ Interface.prototype._ttyWrite = function(s, key) {
}
};
exports.Interface = Interface;

Просмотреть файл

@ -64,9 +64,12 @@ function REPLServer(prompt, stream) {
self.prompt = prompt || '> ';
var rli = self.rli = rl.createInterface(self.inputStream, self.outputStream, function(text) {
function complete(text) {
return self.complete(text);
});
}
var rli = rl.createInterface(self.inputStream, self.outputStream, complete);
self.rli = rli;
this.commands = {};
defineDefaultCommands(this);

Просмотреть файл

@ -169,7 +169,7 @@ CryptoStream.prototype.destroy = function(err) {
CryptoStream.prototype.fd = -1;
CryptoStream.prototype.__defineGetter__('readyState',
net.Socket.prototype.__lookupGetter__('readyState'));
net.Socket.prototype.__lookupGetter__('readyState'));
// Move decrypted, clear data out into the application.
// From the user's perspective this occurs as a 'data' event

Просмотреть файл

@ -91,9 +91,9 @@ ReadStream.prototype.isTTY = true;
*/
// Regexes used for ansi escape code splitting
var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/,
functionKeyCodeRe =
/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/;
var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/;
var functionKeyCodeRe =
/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/;
ReadStream.prototype._emitKey = function(s) {
var char,
@ -108,7 +108,7 @@ ReadStream.prototype._emitKey = function(s) {
if (Buffer.isBuffer(s)) {
if (s[0] > 127 && s[1] === undefined) {
s[0] -= 128;
s = '\x1b'+s.toString(this.encoding || 'utf-8');
s = '\x1b' + s.toString(this.encoding || 'utf-8');
} else {
s = s.toString(this.encoding || 'utf-8');
}
@ -158,7 +158,7 @@ ReadStream.prototype._emitKey = function(s) {
// reassemble the key code leaving out leading \x1b's,
// the modifier key bitflag and any meaningless "1;" sequence
var code = (parts[1] || '') + (parts[2] || '') +
var code = (parts[1] || '') + (parts[2] || '') +
(parts[4] || '') + (parts[6] || ''),
modifier = (parts[3] || parts[5] || 1) - 1;

Просмотреть файл

@ -143,22 +143,22 @@ WriteStream.prototype.destroy = function() {
};
WriteStream.prototype.moveCursor = function(dx, dy) {
if (!this.writable)
if (!this.writable)
throw new Error('Stream not writable');
binding.moveCursor(this.fd, dx, dy);
};
WriteStream.prototype.cursorTo = function(x, y) {
if (!this.writable)
if (!this.writable)
throw new Error('Stream not writable');
binding.cursorTo(this.fd, x, y);
};
WriteStream.prototype.clearLine = function(direction) {
if (!this.writable)
if (!this.writable)
throw new Error('Stream not writable');
binding.clearLine(this.fd, direction || 0);
};
};

Просмотреть файл

@ -314,7 +314,7 @@
// one to drop a file lib/_third_party_main.js into the build directory
// which will be executed instead of Node's normal loading.
if (NativeModule.exists('_third_party_main')) {
process.nextTick(function () {
process.nextTick(function() {
NativeModule.require('_third_party_main');
});
return;