Commit 80b87ef2 authored by aniket-engg's avatar aniket-engg Committed by Aniket

traceManager and traceStepManager updated

parent d2161740
This diff is collapsed.
......@@ -4,52 +4,55 @@ const traceHelper = require('./traceHelper')
const remixLib = require('@remix-project/remix-lib')
const util = remixLib.util
function TraceStepManager (_traceAnalyser) {
this.traceAnalyser = _traceAnalyser
}
export class TraceStepManager {
TraceStepManager.prototype.isCallInstruction = function (index) {
const state = this.traceAnalyser.trace[index]
return traceHelper.isCallInstruction(state) && !traceHelper.isCallToPrecompiledContract(index, this.traceAnalyser.trace)
}
traceAnalyser
TraceStepManager.prototype.isReturnInstruction = function (index) {
const state = this.traceAnalyser.trace[index]
return traceHelper.isReturnInstruction(state)
}
constructor (_traceAnalyser) {
this.traceAnalyser = _traceAnalyser
}
TraceStepManager.prototype.findStepOverBack = function (currentStep) {
if (this.isReturnInstruction(currentStep)) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.start > 0 ? call.start - 1 : 0
isCallInstruction (index) {
const state = this.traceAnalyser.trace[index]
return traceHelper.isCallInstruction(state) && !traceHelper.isCallToPrecompiledContract(index, this.traceAnalyser.trace)
}
return currentStep > 0 ? currentStep - 1 : 0
}
TraceStepManager.prototype.findStepOverForward = function (currentStep) {
if (this.isCallInstruction(currentStep)) {
const call = util.findCall(currentStep + 1, this.traceAnalyser.traceCache.callsTree.call)
return call.return + 1 < this.traceAnalyser.trace.length ? call.return + 1 : this.traceAnalyser.trace.length - 1
isReturnInstruction (index) {
const state = this.traceAnalyser.trace[index]
return traceHelper.isReturnInstruction(state)
}
findStepOverBack (currentStep) {
if (this.isReturnInstruction(currentStep)) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.start > 0 ? call.start - 1 : 0
}
return currentStep > 0 ? currentStep - 1 : 0
}
return this.traceAnalyser.trace.length >= currentStep + 1 ? currentStep + 1 : currentStep
}
TraceStepManager.prototype.findNextCall = function (currentStep) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
const subCalls = Object.keys(call.calls)
if (subCalls.length) {
var callStart = util.findLowerBound(currentStep, subCalls) + 1
if (subCalls.length > callStart) {
return subCalls[callStart] - 1
findStepOverForward (currentStep) {
if (this.isCallInstruction(currentStep)) {
const call = util.findCall(currentStep + 1, this.traceAnalyser.traceCache.callsTree.call)
return call.return + 1 < this.traceAnalyser.trace.length ? call.return + 1 : this.traceAnalyser.trace.length - 1
}
return this.traceAnalyser.trace.length >= currentStep + 1 ? currentStep + 1 : currentStep
}
findNextCall (currentStep) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
const subCalls = Object.keys(call.calls)
if (subCalls.length) {
var callStart = util.findLowerBound(currentStep, subCalls) + 1
if (subCalls.length > callStart) {
return parseInt(subCalls[callStart]) - 1
}
return currentStep
}
return currentStep
}
return currentStep
}
TraceStepManager.prototype.findStepOut = function (currentStep) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.return
findStepOut (currentStep) {
const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call)
return call.return
}
}
module.exports = TraceStepManager
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