don't print source automatically; has to be required instead

pull/5370/head
Iuri Matias 6 years ago
parent cff01523d9
commit 53a3fa5790
  1. 39
      remix-debug/src/cmdline/index.js
  2. 5
      remix-debug/src/debugger/solidityState.js

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

@ -36,7 +36,12 @@ class DebuggerSolidityState {
} }
self.event.trigger('solidityStateUpdating') self.event.trigger('solidityStateUpdating')
decodeTimeout = setTimeout(function () { decodeTimeout = setTimeout(function () {
// necessary due to some states that can crash the debugger
try {
self.decode(index) self.decode(index)
} catch(err) {
}
}, 500) }, 500)
} }

Loading…
Cancel
Save