retrieve sourcelocation and test against current

pull/7/head
yann300 8 years ago
parent 2a181ebd07
commit 4716dad855
  1. 4
      src/solidity/localDecoder.js
  2. 36
      src/ui/SolidityLocals.js

@ -1,6 +1,6 @@
'use strict' 'use strict'
function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage) { function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage, currentSourceLocation) {
var scope = internalTreeCall.findScope(vmtraceIndex) var scope = internalTreeCall.findScope(vmtraceIndex)
if (!scope) { if (!scope) {
var error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' } var error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' }
@ -10,7 +10,7 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage)
memory = formatMemory(memory) memory = formatMemory(memory)
for (var local in scope.locals) { for (var local in scope.locals) {
let variable = scope.locals[local] let variable = scope.locals[local]
if (variable.stackDepth < stack.length) { if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) {
locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory, storage) locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory, storage)
} }
} }

@ -38,26 +38,24 @@ class SolidityLocals {
if (this.parent.currentStepIndex !== index) return if (this.parent.currentStepIndex !== index) return
this.traceManager.waterfall([ this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => {
this.traceManager.getStackAt, this.traceManager.waterfall([
this.traceManager.getMemoryAt], this.traceManager.getStackAt,
index, this.traceManager.getMemoryAt],
(error, result) => { index,
if (!error) { (error, result) => {
var stack = result[0].value if (!error) {
var memory = result[1].value var stack = result[0].value
try { var memory = result[1].value
this.traceManager.getStorageAt(index, this.parent.tx, (error, storage) => { try {
if (!error) { var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory, sourceLocation)
var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory, storage) this.basicPanel.update(locals)
this.basicPanel.update(locals) } catch (e) {
} warningDiv.innerHTML = e.message
}) }
} catch (e) {
warningDiv.innerHTML = e.message
} }
} })
}) })
}) })
} }
} }

Loading…
Cancel
Save