add getSourceLocation from stepindex

pull/7/head
yann300 8 years ago
parent b2760e6706
commit 2639b6b0be
  1. 30
      src/code/sourceLocationTracker.js

@ -36,6 +36,36 @@ SourceLocationTracker.prototype.getSourceLocation = function (address, index, co
})
}
/**
* Return the source location associated with the given @arg pc
*
* @param {String} address - contract address from which the source location is retrieved
* @param {Int} vmtraceStepIndex - index of the current code in the vmtrace
* @param {Object} contractDetails - AST of compiled contracts
* @param {Function} cb - callback function
*/
SourceLocationTracker.prototype.getSourceLocation = function (address, vmtraceStepIndex, contractsDetails, cb) {
var self = this
this.codeManager.getCode(address, function (error, result) {
if (!error) {
var sourceMap = getSourceMap(address, result.bytecode, contractsDetails)
if (sourceMap) {
self.codeManager.getInstructionIndex(address, vmtraceStepIndex, function (error, index) {
if (error) {
cb(error)
} else {
cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap))
}
})
} else {
cb('no srcmap associated with the code ' + address)
}
} else {
cb(error)
}
})
}
/**
* backwards compatibility - attribute name will certainly be changed
*/

Loading…
Cancel
Save