|
|
|
@ -11,6 +11,8 @@ function SourceLocationTracker (_codeManager) { |
|
|
|
|
this.codeManager = _codeManager |
|
|
|
|
this.event = new EventManager() |
|
|
|
|
this.sourceMappingDecoder = new SourceMappingDecoder() |
|
|
|
|
this.sourceMapCacheOfInstructionIndex = {} |
|
|
|
|
this.sourceMapCacheOfVMTraceIndex = {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -23,10 +25,14 @@ function SourceLocationTracker (_codeManager) { |
|
|
|
|
*/ |
|
|
|
|
SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = function (address, index, contracts, cb) { |
|
|
|
|
var self = this |
|
|
|
|
if (self.sourceMapCacheOfInstructionIndex[address]) { |
|
|
|
|
return cb(null, self.sourceMappingDecoder.atIndex(index, self.sourceMapCacheOfInstructionIndex[address])) |
|
|
|
|
} |
|
|
|
|
extractSourceMap(this.codeManager, address, contracts, function (error, sourceMap) { |
|
|
|
|
if (error) { |
|
|
|
|
cb(error) |
|
|
|
|
} else { |
|
|
|
|
if (!helper.isContractCreation(address)) self.sourceMapCacheOfInstructionIndex[address] = sourceMap |
|
|
|
|
cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap)) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -42,12 +48,16 @@ SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = function |
|
|
|
|
*/ |
|
|
|
|
SourceLocationTracker.prototype.getSourceLocationFromVMTraceIndex = function (address, vmtraceStepIndex, contracts, cb) { |
|
|
|
|
var self = this |
|
|
|
|
if (self.sourceMapCacheOfVMTraceIndex[address]) { |
|
|
|
|
return cb(null, self.sourceMappingDecoder.atIndex(vmtraceStepIndex, self.sourceMapCacheOfVMTraceIndex[address])) |
|
|
|
|
} |
|
|
|
|
extractSourceMap(this.codeManager, address, contracts, function (error, sourceMap) { |
|
|
|
|
if (!error) { |
|
|
|
|
self.codeManager.getInstructionIndex(address, vmtraceStepIndex, function (error, index) { |
|
|
|
|
if (error) { |
|
|
|
|
cb(error) |
|
|
|
|
} else { |
|
|
|
|
if (!helper.isContractCreation(address)) self.sourceMapCacheOfVMTraceIndex[address] = sourceMap |
|
|
|
|
cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap)) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|