|
|
|
@ -12,7 +12,7 @@ class CmdLine { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
connect (providerType, url) { |
|
|
|
|
if (providerType !== 'http') throw new Error("unsupported provider type") |
|
|
|
|
if (providerType !== 'http') throw new Error('unsupported provider type') |
|
|
|
|
this.web3 = new Web3(new Web3.providers.HttpProvider(url)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -52,30 +52,30 @@ class CmdLine { |
|
|
|
|
|
|
|
|
|
let lineColumnPos = this.lineColumnPos |
|
|
|
|
|
|
|
|
|
if (!lineColumnPos || !lineColumnPos.start) return []; |
|
|
|
|
if (!lineColumnPos || !lineColumnPos.start) return [] |
|
|
|
|
|
|
|
|
|
let content = self.compilation.lastCompilationResult.source.sources[this.filename].content.split("\n") |
|
|
|
|
let content = self.compilation.lastCompilationResult.source.sources[this.filename].content.split('\n') |
|
|
|
|
|
|
|
|
|
let source = [] |
|
|
|
|
|
|
|
|
|
let line |
|
|
|
|
line = content[lineColumnPos.start.line - 2] |
|
|
|
|
if (line !== undefined) { |
|
|
|
|
source.push(" " + (lineColumnPos.start.line - 1) + ": " + line) |
|
|
|
|
source.push(' ' + (lineColumnPos.start.line - 1) + ': ' + line) |
|
|
|
|
} |
|
|
|
|
line = content[lineColumnPos.start.line - 1] |
|
|
|
|
if (line !== undefined) { |
|
|
|
|
source.push(" " + lineColumnPos.start.line + ": " + line) |
|
|
|
|
source.push(' ' + lineColumnPos.start.line + ': ' + line) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let currentLineNumber = lineColumnPos.start.line |
|
|
|
|
let currentLine = content[currentLineNumber] |
|
|
|
|
source.push("=> " + (currentLineNumber + 1) + ": " + currentLine) |
|
|
|
|
source.push('=> ' + (currentLineNumber + 1) + ': ' + currentLine) |
|
|
|
|
|
|
|
|
|
let startLine = lineColumnPos.start.line |
|
|
|
|
for (var i = 1; i < 4; i++) { |
|
|
|
|
let line = content[startLine + i] |
|
|
|
|
source.push(" " + (startLine + i + 1) + ": " + line) |
|
|
|
|
source.push(' ' + (startLine + i + 1) + ': ' + line) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return source |
|
|
|
@ -83,9 +83,9 @@ class CmdLine { |
|
|
|
|
|
|
|
|
|
getCurrentLine () { |
|
|
|
|
let lineColumnPos = this.lineColumnPos |
|
|
|
|
if (!lineColumnPos) return "" |
|
|
|
|
if (!lineColumnPos) return '' |
|
|
|
|
let currentLineNumber = lineColumnPos.start.line |
|
|
|
|
let content = this.compilation.lastCompilationResult.source.sources[this.filename].content.split("\n") |
|
|
|
|
let content = this.compilation.lastCompilationResult.source.sources[this.filename].content.split('\n') |
|
|
|
|
return content[currentLineNumber] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -94,28 +94,27 @@ class CmdLine { |
|
|
|
|
this.filename = filename |
|
|
|
|
this.txHash = txNumber |
|
|
|
|
this.debugger.debug(null, txNumber, null, () => { |
|
|
|
|
|
|
|
|
|
self.debugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { |
|
|
|
|
self.lineColumnPos = lineColumnPos |
|
|
|
|
self.rawLocation = rawLocation |
|
|
|
|
self.events.emit("source", [lineColumnPos, rawLocation]) |
|
|
|
|
}); |
|
|
|
|
self.events.emit('source', [lineColumnPos, rawLocation]) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
self.debugger.vmDebuggerLogic.event.register('solidityState', (data) => { |
|
|
|
|
self.solidityState = data |
|
|
|
|
self.events.emit("globals", data) |
|
|
|
|
}); |
|
|
|
|
self.events.emit('globals', data) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// TODO: this doesnt work too well, it should request the data instead...
|
|
|
|
|
self.debugger.vmDebuggerLogic.event.register('solidityLocals', (data) => { |
|
|
|
|
if (JSON.stringify(data) === '{}') return |
|
|
|
|
self.solidityLocals = data |
|
|
|
|
self.events.emit("locals", data) |
|
|
|
|
}); |
|
|
|
|
self.events.emit('locals', data) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if (cb) { |
|
|
|
|
// TODO: this should be an onReady event
|
|
|
|
|
setTimeout(cb, 1000); |
|
|
|
|
setTimeout(cb, 1000) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -128,7 +127,7 @@ class CmdLine { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
triggerSourceUpdate () { |
|
|
|
|
this.events.emit("source", [this.lineColumnPos, this.rawLocation]) |
|
|
|
|
this.events.emit('source', [this.lineColumnPos, this.rawLocation]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stepJumpNextBreakpoint () { |
|
|
|
@ -160,32 +159,32 @@ class CmdLine { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getTraceLength () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.traceLength |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getCodeFirstStep () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.calculateFirstStep() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getCodeTraceLength () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.calculateCodeLength() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
nextStep () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.nextStep() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
previousStep () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.previousStep() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
currentStep () { |
|
|
|
|
if (!this.debugger.step_manager) return 0; |
|
|
|
|
if (!this.debugger.step_manager) return 0 |
|
|
|
|
return this.debugger.step_manager.currentStepIndex |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -202,12 +201,12 @@ class CmdLine { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
displayLocals () { |
|
|
|
|
console.dir("= displayLocals") |
|
|
|
|
console.dir('= displayLocals') |
|
|
|
|
console.dir(this.solidityLocals) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
displayGlobals () { |
|
|
|
|
console.dir("= displayGlobals") |
|
|
|
|
console.dir('= displayGlobals') |
|
|
|
|
console.dir(this.solidityState) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|