Commit 8bb7e18b authored by Iuri Matias's avatar Iuri Matias

refactor decodeLocalsAt

parent 57f715f9
...@@ -88,44 +88,12 @@ Ethdebugger.prototype.extractLocalsAt = function (step, callback) { ...@@ -88,44 +88,12 @@ Ethdebugger.prototype.extractLocalsAt = function (step, callback) {
} }
Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback) { Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback) {
const self = this
this.traceManager.waterfall([
function getStackAt (stepIndex, callback) {
try { try {
const result = self.traceManager.getStackAt(stepIndex) const stack = this.traceManager.getStackAt(step)
callback(null, result) const memory = this.traceManager.getMemoryAt(step)
} catch (error) { const address = this.traceManager.getCurrentCalledAddressAt(step)
callback(error)
}
},
function getMemoryAt (stepIndex, callback) {
try {
const result = self.traceManager.getMemoryAt(stepIndex)
callback(null, result)
} catch (error) {
callback(error)
}
},
function getCurrentCalledAddressAt (stepIndex, next) {
try {
const address = self.traceManager.getCurrentCalledAddressAt(stepIndex)
next(null, address)
} catch (error) {
next(error)
}
}],
step,
(error, result) => {
if (!error) {
const stack = result[0].value
const memory = result[1].value
try { try {
const storageViewer = new StorageViewer({ const storageViewer = new StorageViewer({ stepIndex: step, tx: this.tx, address: address }, this.storageResolver, this.traceManager)
stepIndex: step,
tx: this.tx,
address: result[2].value
}, this.storageResolver, this.traceManager)
localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation).then((locals) => { localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation).then((locals) => {
if (!locals.error) { if (!locals.error) {
callback(null, locals) callback(null, locals)
...@@ -136,10 +104,9 @@ Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback) ...@@ -136,10 +104,9 @@ Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback)
} catch (e) { } catch (e) {
callback(e.message) callback(e.message)
} }
} else { } catch (error) {
callback(error) callback(error)
} }
})
} }
/* decode state */ /* decode state */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment