|
|
@ -210,6 +210,22 @@ Client.prototype.reqVersion = function(cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Client.prototype.reqLookup = function(refs, cb) { |
|
|
|
// TODO: We have a cache of handle's we've already seen in this.handles
|
|
|
|
// This can be used if we're careful.
|
|
|
|
var req = { |
|
|
|
command: 'lookup', |
|
|
|
arguments: { |
|
|
|
handles: refs |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
this.req(req, function(res) { |
|
|
|
if (cb) cb(res); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Client.prototype.reqEval = function(expression, cb) { |
|
|
|
var self = this; |
|
|
|
var req = { |
|
|
@ -225,9 +241,10 @@ Client.prototype.reqEval = function(expression, cb) { |
|
|
|
} |
|
|
|
|
|
|
|
this.req(req, function(res) { |
|
|
|
console.error('reqEval res ', res.body); |
|
|
|
self._addHandle(res.body); |
|
|
|
if (cb) cb(res.body); |
|
|
|
if (res.success) { |
|
|
|
self._addHandle(res.body); |
|
|
|
} |
|
|
|
if (cb) cb(res); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
@ -307,6 +324,60 @@ Client.prototype.step = function(action, count, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Client.prototype.mirrorObject = function(handle, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (handle.type == 'object') { |
|
|
|
// The handle looks something like this:
|
|
|
|
// { handle: 8,
|
|
|
|
// type: 'object',
|
|
|
|
// className: 'Object',
|
|
|
|
// constructorFunction: { ref: 9 },
|
|
|
|
// protoObject: { ref: 4 },
|
|
|
|
// prototypeObject: { ref: 2 },
|
|
|
|
// properties: [ { name: 'hello', propertyType: 1, ref: 10 } ],
|
|
|
|
// text: '#<an Object>' }
|
|
|
|
|
|
|
|
// For now ignore the className and constructor and prototype.
|
|
|
|
// TJ's method of object inspection would probably be good for this:
|
|
|
|
// https://groups.google.com/forum/?pli=1#!topic/nodejs-dev/4gkWBOimiOg
|
|
|
|
|
|
|
|
var propertyRefs = handle.properties.map(function(p) { |
|
|
|
return p.ref; |
|
|
|
}); |
|
|
|
|
|
|
|
this.reqLookup(propertyRefs, function(res) { |
|
|
|
if (!res.success) { |
|
|
|
console.error("problem with reqLookup"); |
|
|
|
if (cb) cb(handle); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var mirror = {}; |
|
|
|
for (var i = 0; i < handle.properties.length; i++) { |
|
|
|
var value = res.body[handle.properties[i].ref]; |
|
|
|
self._addHandle(value); |
|
|
|
mirror[handle.properties[i].name] = value.text; |
|
|
|
} |
|
|
|
|
|
|
|
if (cb) cb(mirror); |
|
|
|
}); |
|
|
|
|
|
|
|
} else if (handle.type == 'string') { |
|
|
|
process.nextTick(function() { |
|
|
|
cb(handle.text); |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
process.nextTick(function() { |
|
|
|
cb(handle); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var commands = [ |
|
|
|
'backtrace', |
|
|
|
'continue', |
|
|
@ -724,12 +795,16 @@ Interface.prototype.handleCommand = function(cmd) { |
|
|
|
} else { |
|
|
|
cmd = cmd.slice(i); |
|
|
|
client.reqEval(cmd, function(res) { |
|
|
|
if (res) { |
|
|
|
console.log(res.text); |
|
|
|
} else { |
|
|
|
console.log(res); |
|
|
|
if (!res.success) { |
|
|
|
console.log(res.message); |
|
|
|
term.prompt(); |
|
|
|
return; |
|
|
|
} |
|
|
|
term.prompt(); |
|
|
|
|
|
|
|
client.mirrorObject(res.body, function(mirror) { |
|
|
|
console.log(mirror); |
|
|
|
term.prompt(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|