|
|
|
@ -1,10 +1,13 @@ |
|
|
|
|
var Web3 = require('web3') |
|
|
|
|
var Debugger = require('../debugger/debugger.js') |
|
|
|
|
var ContextManager = require('./contextManager.js') |
|
|
|
|
var EventManager = require('events') |
|
|
|
|
|
|
|
|
|
class CmdLine { |
|
|
|
|
|
|
|
|
|
constructor () { |
|
|
|
|
this.events = new EventManager() |
|
|
|
|
this.lineColumnPos = null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
connect (providerType, url) { |
|
|
|
@ -36,35 +39,53 @@ class CmdLine { |
|
|
|
|
this.contextManager.switchProvider('debugger_web3') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getSource() { |
|
|
|
|
const self = this |
|
|
|
|
|
|
|
|
|
console.dir("getSource") |
|
|
|
|
console.dir(this.lineColumnPos) |
|
|
|
|
console.dir(this.filename) |
|
|
|
|
|
|
|
|
|
let lineColumnPos = this.lineColumnPos |
|
|
|
|
|
|
|
|
|
if (!lineColumnPos || !lineColumnPos.start) return; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
line = content[lineColumnPos.start.line - 1] |
|
|
|
|
if ( line !== undefined) { |
|
|
|
|
source.push(" " + lineColumnPos.start.line + ": " + line) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let currentLineNumber = lineColumnPos.start.line |
|
|
|
|
let currentLine = content[currentLineNumber] |
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return source |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: is filename really necessary?
|
|
|
|
|
startDebug(txNumber, filename) { |
|
|
|
|
const self = this |
|
|
|
|
this.filename = filename |
|
|
|
|
this.debugger.debug(null, txNumber, null, () => { |
|
|
|
|
|
|
|
|
|
self.debugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { |
|
|
|
|
if (!lineColumnPos || !lineColumnPos.start) return; |
|
|
|
|
|
|
|
|
|
let content = self.compilation.lastCompilationResult.source.sources[filename].content.split("\n") |
|
|
|
|
|
|
|
|
|
let line |
|
|
|
|
line = content[lineColumnPos.start.line - 2] |
|
|
|
|
if ( line !== undefined) { |
|
|
|
|
console.dir(" " + (lineColumnPos.start.line - 1) + ": " + line) |
|
|
|
|
} |
|
|
|
|
line = content[lineColumnPos.start.line - 1] |
|
|
|
|
if ( line !== undefined) { |
|
|
|
|
console.dir(" " + lineColumnPos.start.line + ": " + line) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let currentLineNumber = lineColumnPos.start.line |
|
|
|
|
let currentLine = content[currentLineNumber] |
|
|
|
|
console.dir("=> " + (currentLineNumber + 1) + ": " + currentLine) |
|
|
|
|
|
|
|
|
|
let startLine = lineColumnPos.start.line |
|
|
|
|
for (var i=1; i < 4; i++) { |
|
|
|
|
let line = content[startLine + i] |
|
|
|
|
console.dir(" " + (startLine + i + 1) + ": " + line) |
|
|
|
|
} |
|
|
|
|
self.debugger.event.register('newSourceLocation', function (lineColumnPos, _rawLocation) { |
|
|
|
|
self.lineColumnPos = lineColumnPos |
|
|
|
|
self.events.emit("source") |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
self.debugger.vmDebuggerLogic.event.register('solidityState', (data) => { |
|
|
|
|