Merge pull request #714 from ethereum/displaySourceLocationAnyCase

Display source location in any case
pull/7/head
yann300 7 years ago committed by GitHub
commit 19038f22b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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.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))
}
})

@ -200,7 +200,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
})
}
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)
// means: the previous location was a function definition && JUMPDEST
// => we are at the beginning of the function and input/output are setup

Loading…
Cancel
Save