From 0054b1022d8b854acced95693b4d2d487abf1bf8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 2 Oct 2018 13:56:35 -0400 Subject: [PATCH] merge 'old' ui and new ui --- src/app/debugger/EthdebuggerUI.js | 112 ------------------------ src/app/debugger/debuggerUI.js | 137 +++++++++++++++++++++++++----- 2 files changed, 118 insertions(+), 131 deletions(-) delete mode 100644 src/app/debugger/EthdebuggerUI.js diff --git a/src/app/debugger/EthdebuggerUI.js b/src/app/debugger/EthdebuggerUI.js deleted file mode 100644 index 5d4b7b5ad6..0000000000 --- a/src/app/debugger/EthdebuggerUI.js +++ /dev/null @@ -1,112 +0,0 @@ -'use strict' -// var TxBrowser = require('./TxBrowser') -// var StepManager = require('./StepManager') -// var VmDebugger = require('./VmDebugger') - -var yo = require('yo-yo') -var csjs = require('csjs-inject') - -var remixLib = require('remix-lib') -var executionContext = remixLib.execution.executionContext -var EventManager = remixLib.EventManager - -var css = csjs` - .statusMessage { - margin-left: 15px; - } - .innerShift { - padding: 2px; - margin-left: 10px; - } -` - -function EthdebuggerUI (opts) { - this.opts = opts || {} - this.debugger = opts.debugger - - var self = this - this.event = new EventManager() - - this.currentStepIndex = -1 - this.tx - this.statusMessage = '' - - this.view - - this.event.register('indexChanged', this, function (index) { - self.debugger.codeManager.resolveStep(index, self.tx) - }) - - executionContext.event.register('contextChanged', this, function () { - self.updateWeb3Reference() - }) -} - -EthdebuggerUI.prototype.updateWeb3Reference = function (web3) { - if (!this.txBrowser) return - this.txBrowser.web3 = web3 || executionContext.web3() -} - -EthdebuggerUI.prototype.render = function () { - this.debuggerPanelsView = yo`
` - this.debuggerHeadPanelsView = yo`
` - this.stepManagerView = yo`
` - - var view = yo`
-
- ${this.txBrowser.render()} - ${this.debuggerHeadPanelsView} - ${this.stepManagerView} -
-
${this.statusMessage}
- ${this.debuggerPanelsView} -
` - if (!this.view) { - this.view = view - } - return view -} - -EthdebuggerUI.prototype.unLoad = function () { - this.debugger.unLoad() - yo.update(this.debuggerHeadPanelsView, yo`
`) - yo.update(this.debuggerPanelsView, yo`
`) - yo.update(this.stepManagerView, yo`
`) - if (this.vmDebugger) this.vmDebugger.remove() - if (this.stepManager) this.stepManager.remove() - this.vmDebugger = null - this.stepManager = null - this.event.trigger('traceUnloaded') -} - -EthdebuggerUI.prototype.stepChanged = function (stepIndex) { - this.currentStepIndex = stepIndex - this.event.trigger('indexChanged', [stepIndex]) -} - -EthdebuggerUI.prototype.startDebugging = function (blockNumber, txIndex, tx) { - const self = this - if (this.debugger.traceManager.isLoading) { - return false - } - - this.tx = tx - - this.debugger.codeManager.event.register('changed', this, (code, address, instIndex) => { - self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, this.currentStepIndex, this.debugger.solidityProxy.contracts, (error, sourceLocation) => { - if (!error) { - self.event.trigger('sourceLocationChanged', [sourceLocation]) - } - }) - }) - - return true -} - -EthdebuggerUI.prototype.andAddVmDebugger = function () { - yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead()) - yo.update(this.debuggerPanelsView, this.vmDebugger.render()) - yo.update(this.stepManagerView, this.stepManager.render()) -} - -module.exports = EthdebuggerUI diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index aa657488bb..a5334fd088 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -1,4 +1,4 @@ -var OldEthdebuggerUI = require('./EthdebuggerUI') +// var OldEthdebuggerUI = require('./EthdebuggerUI') var Debugger = require('../debugger/debugger') var SourceHighlighter = require('../editor/sourceHighlighter') var TxBrowser = require('./debuggerUI/TxBrowser') @@ -7,25 +7,56 @@ var StepManager = require('./stepManager') var VmDebugger = require('./debuggerUI/VmDebugger') var remixLib = require('remix-lib') var executionContext = remixLib.execution.executionContext +var EventManager = remixLib.EventManager var traceHelper = remixLib.helpers.trace var VmDebuggerLogic = require('./VmDebugger') +var yo = require('yo-yo') +var csjs = require('csjs-inject') + +var css = csjs` + .statusMessage { + margin-left: 15px; + } + .innerShift { + padding: 2px; + margin-left: 10px; + } +` + class DebuggerUI { constructor (container) { + const self = this this.transactionDebugger = new Debugger(new SourceHighlighter()) + this.debugger = this.transactionDebugger.debugger this.isActive = false + this.event = new EventManager() - this.debugger_ui = new OldEthdebuggerUI({ - debugger: this.transactionDebugger.debugger - }) + // this.debugger_ui = new OldEthdebuggerUI({ + // debugger: this.transactionDebugger.debugger + // }) this.startTxBrowser() // this.startStepManager() this.stepManager = null - container.appendChild(this.debugger_ui.render()) + this.currentStepIndex = -1 + this.tx + this.statusMessage = '' + + this.view + + this.event.register('indexChanged', this, function (index) { + self.debugger.codeManager.resolveStep(index, self.tx) + }) + + executionContext.event.register('contextChanged', this, function () { + self.updateWeb3Reference() + }) + + container.appendChild(this.render()) this.listenToEvents() } @@ -40,7 +71,7 @@ class DebuggerUI { self.stepManager.stepManager.jumpTo(step) }) - this.debugger_ui.event.register('indexChanged', function (index) { + this.event.register('indexChanged', function (index) { self.transactionDebugger.registerAndHighlightCodeItem(index) }) } @@ -53,11 +84,11 @@ class DebuggerUI { const self = this let web3 = executionContext.web3() - let txBrowser = new TxBrowser(this.debugger_ui, {web3: web3}) - this.debugger_ui.txBrowser = txBrowser + let txBrowser = new TxBrowser(this, {web3: web3}) + this.txBrowser = txBrowser txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { - self.debugger_ui.unLoad() + self.unLoad() if (tx) { if (!tx.to) { @@ -85,14 +116,14 @@ class DebuggerUI { }) txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { - self.debugger_ui.unLoad() + self.unLoad() }) - this.debugger_ui.event.register('providerChanged', this, function (provider) { + this.event.register('providerChanged', this, function (provider) { txBrowser.setDefaultValues() }) - this.txBrowser = this.debugger_ui.txBrowser + this.txBrowser = this.txBrowser } view () { @@ -105,20 +136,20 @@ class DebuggerUI { startDebugging (blockNumber, txNumber, tx) { const self = this - let shouldOpenDebugger = this.debugger_ui.startDebugging(blockNumber, txNumber, tx) + let shouldOpenDebugger = this.UIstartDebugging(blockNumber, txNumber, tx) if (!shouldOpenDebugger) return - this.transactionDebugger.step_manager = new StepManager(this.debugger_ui, this.transactionDebugger.debugger.traceManager) + this.transactionDebugger.step_manager = new StepManager(this, this.transactionDebugger.debugger.traceManager) this.stepManager = new StepManagerUI(this.transactionDebugger.step_manager) this.stepManager.event.register('stepChanged', this, function (stepIndex) { - self.debugger_ui.stepChanged(stepIndex) + self.stepChanged(stepIndex) }) - this.debugger_ui.stepManager = this.stepManager + this.stepManager = this.stepManager - this.vmDebuggerLogic = new VmDebuggerLogic(this.debugger_ui, this.transactionDebugger.debugger.traceManager, this.transactionDebugger.debugger.codeManager, this.transactionDebugger.debugger.solidityProxy, this.transactionDebugger.debugger.callTree) - this.debugger_ui.vmDebugger = new VmDebugger(this.vmDebuggerLogic) - this.debugger_ui.andAddVmDebugger() + this.vmDebuggerLogic = new VmDebuggerLogic(this, this.transactionDebugger.debugger.traceManager, this.transactionDebugger.debugger.codeManager, this.transactionDebugger.debugger.solidityProxy, this.transactionDebugger.debugger.callTree) + this.vmDebugger = new VmDebugger(this.vmDebuggerLogic) + this.andAddVmDebugger() this.transactionDebugger.debugger.debug(tx) } @@ -140,6 +171,74 @@ class DebuggerUI { // self.debugger_ui.debug(tx) }) } + + updateWeb3Reference (web3) { + if (!this.txBrowser) return + this.txBrowser.web3 = web3 || executionContext.web3() + } + + render () { + this.debuggerPanelsView = yo`
` + this.debuggerHeadPanelsView = yo`
` + this.stepManagerView = yo`
` + + var view = yo`
+
+ ${this.txBrowser.render()} + ${this.debuggerHeadPanelsView} + ${this.stepManagerView} +
+
${this.statusMessage}
+ ${this.debuggerPanelsView} +
` + if (!this.view) { + this.view = view + } + return view + } + + unLoad () { + this.debugger.unLoad() + yo.update(this.debuggerHeadPanelsView, yo`
`) + yo.update(this.debuggerPanelsView, yo`
`) + yo.update(this.stepManagerView, yo`
`) + if (this.vmDebugger) this.vmDebugger.remove() + if (this.stepManager) this.stepManager.remove() + this.vmDebugger = null + this.stepManager = null + this.event.trigger('traceUnloaded') + } + + stepChanged (stepIndex) { + this.currentStepIndex = stepIndex + this.event.trigger('indexChanged', [stepIndex]) + } + + UIstartDebugging (blockNumber, txIndex, tx) { + const self = this + if (this.debugger.traceManager.isLoading) { + return false + } + + this.tx = tx + + this.debugger.codeManager.event.register('changed', this, (code, address, instIndex) => { + self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, this.currentStepIndex, this.debugger.solidityProxy.contracts, (error, sourceLocation) => { + if (!error) { + self.event.trigger('sourceLocationChanged', [sourceLocation]) + } + }) + }) + + return true + } + + andAddVmDebugger () { + yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead()) + yo.update(this.debuggerPanelsView, this.vmDebugger.render()) + yo.update(this.stepManagerView, this.stepManager.render()) + } + } module.exports = DebuggerUI