refactor decodeLocalsAt

refactor_remix_debug4
Iuri Matias 5 years ago
parent 57f715f939
commit 8bb7e18bc1
  1. 43
      libs/remix-debug/src/Ethdebugger.js

@ -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)
} catch (e) { } catch (e) {
callback(e.message) callback(e.message)
} }
} else { } catch (error) {
callback(error) callback(error)
} }
})
} }
/* decode state */ /* decode state */

Loading…
Cancel
Save