refactor getCurrentCalledAddressAt

pull/62/head
Iuri Matias 4 years ago committed by aniket-engg
parent 2db6ff85af
commit 22ac28fe38
  1. 1
      libs/remix-debug/src/debugger/VmDebugger.js
  2. 2
      libs/remix-debug/src/debugger/solidityLocals.js
  3. 21
      libs/remix-debug/src/solidity-decoder/internalCallTree.js
  4. 65
      libs/remix-lib/src/trace/traceManager.js

@ -111,7 +111,6 @@ class VmDebuggerLogic {
} }
}) })
} catch (error) { } catch (error) {
console.log(error)
} }
this._traceManager.getCurrentStep(index, (error, step) => { this._traceManager.getCurrentStep(index, (error, step) => {

@ -34,7 +34,7 @@ class DebuggerSolidityLocals {
this.traceManager.waterfall([ this.traceManager.waterfall([
this.traceManager.getStackAt, this.traceManager.getStackAt,
this.traceManager.getMemoryAt, this.traceManager.getMemoryAt,
(stepIndex, next) => { function getCurrentCalledAddressAt (stepIndex, next) {
try { try {
const address = this.traceManager.getCurrentCalledAddressAt(stepIndex) const address = this.traceManager.getCurrentCalledAddressAt(stepIndex)
next(null, address) next(null, address)

@ -126,19 +126,18 @@ class InternalCallTree {
extractSourceLocation (step) { extractSourceLocation (step) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.traceManager.getCurrentCalledAddressAt(step, (error, address) => { try {
if (!error) { const address = this.traceManager.getCurrentCalledAddressAt(step)
try { try {
this.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, step, this.solidityProxy.contracts).then(resolve).catch((error) => { this.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, step, this.solidityProxy.contracts).then(resolve).catch((error) => {
return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error) return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error)
}) })
} catch (error) { } catch (error) {
return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error)
}
} else {
return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error) return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error)
} }
}) } catch (error) {
return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error)
}
}) })
} }

@ -140,24 +140,10 @@ TraceManager.prototype.getStackAt = function (stepIndex, callback) {
} }
} }
// TraceManager.prototype.getLastCallChangeSince = function (stepIndex, callback) {
// const check = this.checkRequestedStep(stepIndex)
// if (check) {
// return callback(check, null)
// }
// const callChange = util.findCall(stepIndex, this.traceCache.callsTree.call)
// if (callChange === null) {
// callback(null, 0)
// } else {
// callback(null, callChange)
// }
// }
TraceManager.prototype.getLastCallChangeSince = function (stepIndex) { TraceManager.prototype.getLastCallChangeSince = function (stepIndex) {
try { try {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
} catch (check) { } catch (check) {
// return callback(check, null)
throw new Error(check) throw new Error(check)
} }
@ -168,59 +154,16 @@ TraceManager.prototype.getLastCallChangeSince = function (stepIndex) {
return callChange return callChange
} }
// TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback) { TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex) {
// const check = this.checkRequestedStep(stepIndex)
// if (check) {
// return callback(check, null)
// }
// this.getLastCallChangeSince(stepIndex, function (error, resp) {
// if (error) {
// callback(error, null)
// } else {
// if (resp) {
// callback(null, resp.address)
// } else {
// callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL')
// }
// }
// })
// }
// TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex) {
// const check = this.checkRequestedStep(stepIndex)
// if (check) {
// // return callback(check, null)
// throw new Error(check)
// }
// try {
// const resp = this.getLastCallChangeSince(stepIndex)
// if (!resp) {
// throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL')
// }
// return resp.address
// } catch (error) {
// throw new Error(error)
// }
// }
TraceManager.prototype.getCurrentCalledAddressAt = function (stepIndex, callback) {
try { try {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
} catch (check) {
return callback(check, null)
}
try {
const resp = this.getLastCallChangeSince(stepIndex) const resp = this.getLastCallChangeSince(stepIndex)
if (!resp) { if (!resp) {
// throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL') throw new Error('unable to get current called address. ' + stepIndex + ' does not match with a CALL')
callback('unable to get current called address. ' + stepIndex + ' does not match with a CALL')
} }
// return resp.address return resp.address
return callback(null, resp.address)
} catch (error) { } catch (error) {
// throw new Error(error) throw new Error(error)
return callback(error)
} }
} }

Loading…
Cancel
Save