remove moved debugger code

pull/1/head
Iuri Matias 6 years ago
parent f4bd89392c
commit 76722adc1b
  1. 81
      src/app/debugger/debugger/solidityState.js
  2. 145
      src/app/debugger/debugger/stepManager.js

@ -1,81 +0,0 @@
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager
var remixDebug = require('remix-debug')
var stateDecoder = remixDebug.SolidityDecoder.stateDecoder
var StorageViewer = remixDebug.storage.StorageViewer
class DebuggerSolidityState {
constructor (tx, _stepManager, _traceManager, _codeManager, _solidityProxy) {
this.event = new EventManager()
this.storageResolver = null
this.stepManager = _stepManager
this.traceManager = _traceManager
this.codeManager = _codeManager
this.solidityProxy = _solidityProxy
this.stateVariablesByAddresses = {}
this.tx = tx
}
init (index) {
var self = this
var decodeTimeout = null
if (index < 0) {
return self.event.trigger('solidityStateMessage', ['invalid step index'])
}
if (self.stepManager.currentStepIndex !== index) return
if (!self.solidityProxy.loaded()) {
return self.event.trigger('solidityStateMessage', ['invalid step index'])
}
if (!self.storageResolver) {
return
}
if (decodeTimeout) {
window.clearTimeout(decodeTimeout)
}
self.event.trigger('solidityStateUpdating')
decodeTimeout = setTimeout(function () {
self.decode(index)
}, 500)
}
reset () {
this.stateVariablesByAddresses = {}
}
decode (index) {
const self = this
self.traceManager.getCurrentCalledAddressAt(self.stepManager.currentStepIndex, function (error, address) {
if (error) {
return self.event.trigger('solidityState', [{}])
}
if (self.stateVariablesByAddresses[address]) {
return self.extractStateVariables(self.stateVariablesByAddresses[address], address)
}
self.solidityProxy.extractStateVariablesAt(index, function (error, stateVars) {
if (error) {
return self.event.trigger('solidityState', [{}])
}
self.stateVariablesByAddresses[address] = stateVars
self.extractStateVariables(stateVars, address)
})
})
}
extractStateVariables (stateVars, address) {
const self = this
var storageViewer = new StorageViewer({ stepIndex: self.stepManager.currentStepIndex, tx: self.tx, address: address }, self.storageResolver, self.traceManager)
stateDecoder.decodeState(stateVars, storageViewer).then((result) => {
self.event.trigger('solidityStateMessage', [''])
if (result.error) {
return self.event.trigger('solidityStateMessage', [result.error])
}
self.event.trigger('solidityState', [result])
})
}
}
module.exports = DebuggerSolidityState

@ -1,145 +0,0 @@
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager
class DebuggerStepManager {
constructor (_debugger, traceManager) {
this.event = new EventManager()
this.debugger = _debugger
this.traceManager = traceManager
this.currentStepIndex = 0
this.traceLength = 0
this.revertionPoint = null
this.listenToEvents()
}
listenToEvents () {
const self = this
this.debugger.event.register('newTraceLoaded', this, function () {
self.traceManager.getLength(function (error, newLength) {
if (error) {
return console.log(error)
}
if (self.traceLength !== newLength) {
self.event.trigger('traceLengthChanged', [newLength])
self.traceLength = newLength
}
self.jumpTo(0)
})
})
this.debugger.callTree.event.register('callTreeReady', () => {
if (self.debugger.callTree.functionCallStack.length) {
self.jumpTo(self.debugger.callTree.functionCallStack[0])
}
})
this.event.register('indexChanged', this, (index) => {
if (index < 0) return
if (self.currentStepIndex !== index) return
self.traceManager.buildCallPath(index, (error, callsPath) => {
if (error) {
console.log(error)
return self.event.trigger('revertWarning', [''])
}
self.currentCall = callsPath[callsPath.length - 1]
if (self.currentCall.reverted) {
let revertedReason = self.currentCall.outofgas ? 'outofgas' : ''
self.revertionPoint = self.currentCall.return
return self.event.trigger('revertWarning', [revertedReason])
}
for (var k = callsPath.length - 2; k >= 0; k--) {
var parent = callsPath[k]
if (!parent.reverted) continue
self.revertionPoint = parent.return
self.event.trigger('revertWarning', ['parenthasthrown'])
}
self.event.trigger('revertWarning', [''])
})
})
}
triggerStepChanged (step) {
const self = this
this.traceManager.getLength(function (error, length) {
let stepState = 'valid'
if (error) {
stepState = 'invalid'
} else if (step <= 0) {
stepState = 'initial'
} else if (step >= length - 1) {
stepState = 'end'
}
let jumpOutDisabled = (step === self.traceManager.findStepOut(step))
self.event.trigger('stepChanged', [step, stepState, jumpOutDisabled])
})
}
stepIntoBack () {
if (!this.traceManager.isLoaded()) return
var step = this.currentStepIndex - 1
this.currentStepIndex = step
if (!this.traceManager.inRange(step)) {
return
}
this.event.trigger('stepChanged', [step])
}
stepIntoForward () {
if (!this.traceManager.isLoaded()) return
var step = this.currentStepIndex + 1
this.currentStepIndex = step
if (!this.traceManager.inRange(step)) {
return
}
this.event.trigger('stepChanged', [step])
}
stepOverBack () {
if (!this.traceManager.isLoaded()) return
var step = this.traceManager.findStepOverBack(this.currentStepIndex)
this.currentStepIndex = step
this.event.trigger('stepChanged', [step])
}
stepOverForward () {
if (!this.traceManager.isLoaded()) return
var step = this.traceManager.findStepOverForward(this.currentStepIndex)
this.currentStepIndex = step
this.event.trigger('stepChanged', [step])
}
jumpOut () {
if (!this.traceManager.isLoaded()) return
var step = this.traceManager.findStepOut(this.currentStepIndex)
this.currentStepIndex = step
this.event.trigger('stepChanged', [step])
}
jumpTo (step) {
if (!this.traceManager.inRange(step)) return
this.currentStepIndex = step
this.event.trigger('stepChanged', [step])
}
jumpToException () {
this.jumpTo(this.revertionPoint)
}
jumpNextBreakpoint () {
this.debugger.breakpointManager.jumpNextBreakpoint(this.currentStepIndex, true)
}
jumpPreviousBreakpoint () {
this.debugger.breakpointManager.jumpPreviousBreakpoint(this.currentStepIndex, true)
}
}
module.exports = DebuggerStepManager
Loading…
Cancel
Save