From 1d32da5cbfe9413f20d7d81baea1edc351c3475a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 Feb 2017 13:04:51 +0100 Subject: [PATCH] set solidityMode to slider --- src/ui/Slider.js | 14 ++++++++++++++ src/ui/StepManager.js | 28 +++------------------------- src/util/internalCallTree.js | 4 ++-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/ui/Slider.js b/src/ui/Slider.js index a707097e12..8993f5207e 100644 --- a/src/ui/Slider.js +++ b/src/ui/Slider.js @@ -2,6 +2,7 @@ var style = require('./styles/sliderStyles') var EventManager = require('../lib/eventManager') var yo = require('yo-yo') +var utils = require('../helpers/util.js') var ui = require('../helpers/ui') class Slider { @@ -11,6 +12,7 @@ class Slider { this.max this.disabled = true this.view + this.solidityMode = false this.previousValue = null } @@ -46,6 +48,10 @@ class Slider { onChange (event) { 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 this.previousValue = value this.event.trigger('moved', [value]) @@ -61,6 +67,14 @@ class Slider { } } + setReducedTrace (trace) { + this.reducedTrace = trace + } + + setSolidityMode (mode) { + this.solidityMode = false + } + updateDisabled (disabled) { if (disabled) { this.view.querySelector('#slider').setAttribute('disabled', true) diff --git a/src/ui/StepManager.js b/src/ui/StepManager.js index 7fa3a59b68..d3d1561997 100644 --- a/src/ui/StepManager.js +++ b/src/ui/StepManager.js @@ -1,7 +1,6 @@ 'use strict' var ButtonNavigator = require('./ButtonNavigator') var Slider = require('./Slider') -var SoliditySlider = require('./SoliditySlider') var EventManager = require('../lib/eventManager') var SourceMappingDecoder = require('../util/sourceMappingDecoder') var yo = require('yo-yo') @@ -28,26 +27,15 @@ function StepManager (_parent, _traceManager) { this.slider = new Slider(this.traceManager) this.slider.event.register('moved', this, function (step) { self.sliderMoved(step) - self.soliditySlider.setValue(step) }) - this.soliditySlider = new SoliditySlider(this.traceManager) - this.parent.callTree.event.register('callTreeReady', () => { - this.soliditySlider.setReducedTrace(this.parent.callTree.reducedTraceBySourceLocation) - this.soliditySlider.event.register('moved', this, function (srcLocationStep) { - var step = self.parent.callTree.reducedTraceBySourceLocation[srcLocationStep] - self.sliderMoved(step) - self.slider.setValue(step) - }) - + this.slider.setReducedTrace(this.parent.callTree.reducedTrace) this.parent.vmDebugger.asmCode.event.register('hide', () => { - this.soliditySlider.show() - this.slider.hide() + this.slider.setSolidityMode(true) }) this.parent.vmDebugger.asmCode.event.register('show', () => { - this.soliditySlider.hide() - this.slider.show() + this.slider.setSolidityMode(false) }) }) @@ -79,7 +67,6 @@ StepManager.prototype.render = function () { return ( yo`
${this.slider.render()} - ${this.soliditySlider.render()} ${this.buttonNavigator.render()}
` ) @@ -87,14 +74,12 @@ StepManager.prototype.render = function () { StepManager.prototype.reset = function () { this.slider.setValue(0) - this.soliditySlider.setValue(0) this.currentStepIndex = 0 this.buttonNavigator.reset() } StepManager.prototype.init = function () { this.slider.setValue(0) - this.soliditySlider.setValue(0) this.changeState(0) } @@ -107,7 +92,6 @@ StepManager.prototype.jumpTo = function (step) { return } this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -127,7 +111,6 @@ StepManager.prototype.stepIntoForward = function () { return } this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -140,7 +123,6 @@ StepManager.prototype.stepIntoBack = function () { return } this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -150,7 +132,6 @@ StepManager.prototype.stepOverForward = function () { } var step = this.traceManager.findStepOverForward(this.currentStepIndex) this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -160,7 +141,6 @@ StepManager.prototype.stepOverBack = function () { } var step = this.traceManager.findStepOverBack(this.currentStepIndex) this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -170,7 +150,6 @@ StepManager.prototype.jumpNextCall = function () { } var step = this.traceManager.findNextCall(this.currentStepIndex) this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } @@ -180,7 +159,6 @@ StepManager.prototype.jumpOut = function () { } var step = this.traceManager.findStepOut(this.currentStepIndex) this.slider.setValue(step) - this.soliditySlider.setValue(step) this.changeState(step) } diff --git a/src/util/internalCallTree.js b/src/util/internalCallTree.js index a7135b0a5b..c9fa25d855 100644 --- a/src/util/internalCallTree.js +++ b/src/util/internalCallTree.js @@ -58,7 +58,7 @@ class InternalCallTree { this.scopeStarts = {} this.variableDeclarationByFile = {} this.astWalker = new AstWalker() - this.reducedTraceBySourceLocation = [] + this.reducedTrace = [] } /** @@ -96,7 +96,7 @@ async function buildTree (tree, step, scopeId) { sourceLocation.start !== currentSourceLocation.start || sourceLocation.length !== currentSourceLocation.length || sourceLocation.file !== currentSourceLocation.file) { - tree.reducedTraceBySourceLocation.push(step) + tree.reducedTrace.push(step) currentSourceLocation = sourceLocation } } catch (e) {