Commit 1d32da5c authored by yann300's avatar yann300

set solidityMode to slider

parent 922fe987
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
var style = require('./styles/sliderStyles') var style = require('./styles/sliderStyles')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
var yo = require('yo-yo') var yo = require('yo-yo')
var utils = require('../helpers/util.js')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
class Slider { class Slider {
...@@ -11,6 +12,7 @@ class Slider { ...@@ -11,6 +12,7 @@ class Slider {
this.max this.max
this.disabled = true this.disabled = true
this.view this.view
this.solidityMode = false
this.previousValue = null this.previousValue = null
} }
...@@ -46,6 +48,10 @@ class Slider { ...@@ -46,6 +48,10 @@ class Slider {
onChange (event) { onChange (event) {
var value = parseInt(this.view.querySelector('#slider').value) var value = parseInt(this.view.querySelector('#slider').value)
if (this.solidityMode) {
value = utils.findLowerBound(value, this.reducedTrace)
this.view.querySelector('#slider').value = value
}
if (value === this.previousValue) return if (value === this.previousValue) return
this.previousValue = value this.previousValue = value
this.event.trigger('moved', [value]) this.event.trigger('moved', [value])
...@@ -61,6 +67,14 @@ class Slider { ...@@ -61,6 +67,14 @@ class Slider {
} }
} }
setReducedTrace (trace) {
this.reducedTrace = trace
}
setSolidityMode (mode) {
this.solidityMode = false
}
updateDisabled (disabled) { updateDisabled (disabled) {
if (disabled) { if (disabled) {
this.view.querySelector('#slider').setAttribute('disabled', true) this.view.querySelector('#slider').setAttribute('disabled', true)
......
'use strict' 'use strict'
var ButtonNavigator = require('./ButtonNavigator') var ButtonNavigator = require('./ButtonNavigator')
var Slider = require('./Slider') var Slider = require('./Slider')
var SoliditySlider = require('./SoliditySlider')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
var SourceMappingDecoder = require('../util/sourceMappingDecoder') var SourceMappingDecoder = require('../util/sourceMappingDecoder')
var yo = require('yo-yo') var yo = require('yo-yo')
...@@ -28,26 +27,15 @@ function StepManager (_parent, _traceManager) { ...@@ -28,26 +27,15 @@ function StepManager (_parent, _traceManager) {
this.slider = new Slider(this.traceManager) this.slider = new Slider(this.traceManager)
this.slider.event.register('moved', this, function (step) { this.slider.event.register('moved', this, function (step) {
self.sliderMoved(step) self.sliderMoved(step)
self.soliditySlider.setValue(step)
}) })
this.soliditySlider = new SoliditySlider(this.traceManager)
this.parent.callTree.event.register('callTreeReady', () => { this.parent.callTree.event.register('callTreeReady', () => {
this.soliditySlider.setReducedTrace(this.parent.callTree.reducedTraceBySourceLocation) this.slider.setReducedTrace(this.parent.callTree.reducedTrace)
this.soliditySlider.event.register('moved', this, function (srcLocationStep) {
var step = self.parent.callTree.reducedTraceBySourceLocation[srcLocationStep]
self.sliderMoved(step)
self.slider.setValue(step)
})
this.parent.vmDebugger.asmCode.event.register('hide', () => { this.parent.vmDebugger.asmCode.event.register('hide', () => {
this.soliditySlider.show() this.slider.setSolidityMode(true)
this.slider.hide()
}) })
this.parent.vmDebugger.asmCode.event.register('show', () => { this.parent.vmDebugger.asmCode.event.register('show', () => {
this.soliditySlider.hide() this.slider.setSolidityMode(false)
this.slider.show()
}) })
}) })
...@@ -79,7 +67,6 @@ StepManager.prototype.render = function () { ...@@ -79,7 +67,6 @@ StepManager.prototype.render = function () {
return ( return (
yo`<div> yo`<div>
${this.slider.render()} ${this.slider.render()}
${this.soliditySlider.render()}
${this.buttonNavigator.render()} ${this.buttonNavigator.render()}
</div>` </div>`
) )
...@@ -87,14 +74,12 @@ StepManager.prototype.render = function () { ...@@ -87,14 +74,12 @@ StepManager.prototype.render = function () {
StepManager.prototype.reset = function () { StepManager.prototype.reset = function () {
this.slider.setValue(0) this.slider.setValue(0)
this.soliditySlider.setValue(0)
this.currentStepIndex = 0 this.currentStepIndex = 0
this.buttonNavigator.reset() this.buttonNavigator.reset()
} }
StepManager.prototype.init = function () { StepManager.prototype.init = function () {
this.slider.setValue(0) this.slider.setValue(0)
this.soliditySlider.setValue(0)
this.changeState(0) this.changeState(0)
} }
...@@ -107,7 +92,6 @@ StepManager.prototype.jumpTo = function (step) { ...@@ -107,7 +92,6 @@ StepManager.prototype.jumpTo = function (step) {
return return
} }
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -127,7 +111,6 @@ StepManager.prototype.stepIntoForward = function () { ...@@ -127,7 +111,6 @@ StepManager.prototype.stepIntoForward = function () {
return return
} }
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -140,7 +123,6 @@ StepManager.prototype.stepIntoBack = function () { ...@@ -140,7 +123,6 @@ StepManager.prototype.stepIntoBack = function () {
return return
} }
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -150,7 +132,6 @@ StepManager.prototype.stepOverForward = function () { ...@@ -150,7 +132,6 @@ StepManager.prototype.stepOverForward = function () {
} }
var step = this.traceManager.findStepOverForward(this.currentStepIndex) var step = this.traceManager.findStepOverForward(this.currentStepIndex)
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -160,7 +141,6 @@ StepManager.prototype.stepOverBack = function () { ...@@ -160,7 +141,6 @@ StepManager.prototype.stepOverBack = function () {
} }
var step = this.traceManager.findStepOverBack(this.currentStepIndex) var step = this.traceManager.findStepOverBack(this.currentStepIndex)
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -170,7 +150,6 @@ StepManager.prototype.jumpNextCall = function () { ...@@ -170,7 +150,6 @@ StepManager.prototype.jumpNextCall = function () {
} }
var step = this.traceManager.findNextCall(this.currentStepIndex) var step = this.traceManager.findNextCall(this.currentStepIndex)
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
...@@ -180,7 +159,6 @@ StepManager.prototype.jumpOut = function () { ...@@ -180,7 +159,6 @@ StepManager.prototype.jumpOut = function () {
} }
var step = this.traceManager.findStepOut(this.currentStepIndex) var step = this.traceManager.findStepOut(this.currentStepIndex)
this.slider.setValue(step) this.slider.setValue(step)
this.soliditySlider.setValue(step)
this.changeState(step) this.changeState(step)
} }
......
...@@ -58,7 +58,7 @@ class InternalCallTree { ...@@ -58,7 +58,7 @@ class InternalCallTree {
this.scopeStarts = {} this.scopeStarts = {}
this.variableDeclarationByFile = {} this.variableDeclarationByFile = {}
this.astWalker = new AstWalker() this.astWalker = new AstWalker()
this.reducedTraceBySourceLocation = [] this.reducedTrace = []
} }
/** /**
...@@ -96,7 +96,7 @@ async function buildTree (tree, step, scopeId) { ...@@ -96,7 +96,7 @@ async function buildTree (tree, step, scopeId) {
sourceLocation.start !== currentSourceLocation.start || sourceLocation.start !== currentSourceLocation.start ||
sourceLocation.length !== currentSourceLocation.length || sourceLocation.length !== currentSourceLocation.length ||
sourceLocation.file !== currentSourceLocation.file) { sourceLocation.file !== currentSourceLocation.file) {
tree.reducedTraceBySourceLocation.push(step) tree.reducedTrace.push(step)
currentSourceLocation = sourceLocation currentSourceLocation = sourceLocation
} }
} catch (e) { } catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment