Merge pull request #714 from ethereum/displaySourceLocationAnyCase

Display source location in any case
pull/3094/head
yann300 7 years ago committed by GitHub
commit 5f30f21117
  1. 10
      remix-lib/src/sourceLocationTracker.js
  2. 2
      remix-solidity/src/decoder/internalCallTree.js

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

@ -200,7 +200,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
}) })
} }
var functionDefinition = resolveFunctionDefinition(tree, step, previousSourceLocation) var functionDefinition = resolveFunctionDefinition(tree, step, previousSourceLocation)
if (functionDefinition && ((newLocation && traceHelper.isJumpDestInstruction(tree.traceManager.trace[step - 1])) || functionDefinition.attributes.isConstructor)) { if (functionDefinition && newLocation && traceHelper.isJumpDestInstruction(tree.traceManager.trace[step - 1])) {
tree.functionCallStack.push(step) tree.functionCallStack.push(step)
// means: the previous location was a function definition && JUMPDEST // means: the previous location was a function definition && JUMPDEST
// => we are at the beginning of the function and input/output are setup // => we are at the beginning of the function and input/output are setup

Loading…
Cancel
Save