From aba9c8de14cc7d88d85fc20d8ad3d467b544200e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 8 Sep 2018 15:33:43 -0400 Subject: [PATCH] move memory panel logic to caller --- src/app/debugger/debuggerUI/VmDebugger.js | 18 +++++++++++- .../debuggerUI/vmDebugger/MemoryPanel.js | 28 ++++--------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index 06731b0744..0a7dc69d00 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -12,6 +12,8 @@ var DropdownPanel = require('../remix-debugger/src/ui/DropdownPanel') var SolidityState = require('../remix-debugger/src/ui/SolidityState') var SolidityLocals = require('../remix-debugger/src/ui/SolidityLocals') var remixDebug = require('remix-debug') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var StorageResolver = remixDebug.storage.StorageResolver var yo = require('yo-yo') @@ -53,9 +55,23 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca }) }) + this.memoryPanel = new MemoryPanel() + _parentUI.event.register('indexChanged', this, function (index) { + if (index < 0) return + if (_parentUI.currentStepIndex !== index) return + + _traceManager.getMemoryAt(index, function (error, memory) { + if (error) { + console.log(error) + self.memoryPanel.update({}) + } else if (_parentUI.currentStepIndex === index) { + self.memoryPanel.update(ui.formatMemory(memory, 16)) + } + }) + }) + this.stackPanel = new StackPanel(_parentUI, _traceManager) this.storagePanel = new StoragePanel(_parentUI, _traceManager) - this.memoryPanel = new MemoryPanel(_parentUI, _traceManager) this.callstackPanel = new CallstackPanel(_parentUI, _traceManager) this.stepDetail = new StepDetail(_parentUI, _traceManager) this.solidityState = new SolidityState(_parentUI, _traceManager, _codeManager, _solidityProxy) diff --git a/src/app/debugger/debuggerUI/vmDebugger/MemoryPanel.js b/src/app/debugger/debuggerUI/vmDebugger/MemoryPanel.js index c37cf48b2c..02b3fba41a 100644 --- a/src/app/debugger/debuggerUI/vmDebugger/MemoryPanel.js +++ b/src/app/debugger/debuggerUI/vmDebugger/MemoryPanel.js @@ -1,39 +1,21 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var remixLib = require('remix-lib') -var ui = remixLib.helpers.ui var yo = require('yo-yo') -function MemoryPanel (_parent, _traceManager) { - this.parent = _parent - this.traceManager = _traceManager +function MemoryPanel () { this.basicPanel = new DropdownPanel('Memory', { json: true, css: { 'font-family': 'monospace' }}) - this.init() } -MemoryPanel.prototype.render = function () { - return yo`
${this.basicPanel.render()}
` +MemoryPanel.prototype.update = function (calldata) { + this.basicPanel.update(calldata) } -MemoryPanel.prototype.init = function () { - var self = this - this.parent.event.register('indexChanged', this, function (index) { - if (index < 0) return - if (self.parent.currentStepIndex !== index) return - - self.traceManager.getMemoryAt(index, function (error, memory) { - if (error) { - console.log(error) - self.basicPanel.update({}) - } else if (self.parent.currentStepIndex === index) { - self.basicPanel.update(ui.formatMemory(memory, 16)) - } - }) - }) +MemoryPanel.prototype.render = function () { + return yo`
${this.basicPanel.render()}
` } module.exports = MemoryPanel