make linter happy

pull/5370/head
Iuri Matias 6 years ago
parent f7aa459cc5
commit 87fea226a1
  1. 85
      remix-debug/rdb.js
  2. 2
      remix-debug/src/cmdline/contextManager.js
  3. 51
      remix-debug/src/cmdline/index.js
  4. 2
      remix-debug/src/debugger/debugger.js
  5. 2
      remix-debug/src/debugger/solidityLocals.js
  6. 3
      remix-debug/src/debugger/solidityState.js
  7. 10
      remix-debug/src/debugger/stepManager.js

@ -1,13 +1,13 @@
var CmdLine = require('./src/cmdline/index.js')
var compilation = require('./compilation.json')
// var compilation = require('./compilation.json')
var solc = require('solc')
var fs = require('fs')
var filename = 'test/sol/simple_storage.sol'
var short_filename = "simple_storage.sol"
var shortFilename = 'simple_storage.sol'
var input_json = {
var inputJson = {
language: 'Solidity',
sources: {
},
@ -25,85 +25,84 @@ var input_json = {
}
}
input_json.sources[short_filename] = {content: fs.readFileSync(filename).toString()}
inputJson.sources[shortFilename] = {content: fs.readFileSync(filename).toString()}
console.dir(input_json)
console.dir(inputJson)
console.log("compiling...")
console.log('compiling...')
let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input_json)))
let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(inputJson)))
console.dir(Object.keys(compilationData))
var compilation = {}
compilation.data = compilationData
compilation.source = { sources: input_json.sources }
compilation.source = { sources: inputJson.sources }
console.dir(compilation)
console.dir(compilation.data.errors)
var cmd_line = new CmdLine()
cmd_line.connect("http", "http://localhost:8545")
cmd_line.loadCompilationResult(compilation)
cmd_line.initDebugger()
var deployContract = function (cb) {
let _web3 = cmd_line.debugger.debugger.web3
let blockNumber = null
let txNumber = null
let tx = null
let code = compilation.data.contracts[short_filename].SimpleStorage.evm.bytecode.object
console.dir("deploying...")
console.dir(code)
_web3.eth.sendTransaction({data: "0x" + code, from: _web3.eth.accounts[0], gas: 800000}, cb)
}
let _web3 = cmd_line.debugger.debugger.web3
var tx = "0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa"
var cmdLine = new CmdLine()
cmdLine.connect('http', 'http://localhost:8545')
cmdLine.loadCompilationResult(compilation)
cmdLine.initDebugger()
// var deployContract = function (cb) {
// let _web3 = cmdLine.debugger.debugger.web3
//
// let blockNumber = null
// let txNumber = null
// let tx = null
//
// let code = compilation.data.contracts[shortFilename].SimpleStorage.evm.bytecode.object
// console.dir('deploying...')
// console.dir(code)
// _web3.eth.sendTransaction({data: '0x' + code, from: _web3.eth.accounts[0], gas: 800000}, cb)
// }
// let _web3 = cmdLine.debugger.debugger.web3
var tx = '0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa'
// deployContract((err, tx) => {
cmd_line.startDebug(tx, short_filename)
cmdLine.startDebug(tx, shortFilename)
cmd_line.events.on("source", () => {
cmd_line.getSource().forEach(console.dir)
cmdLine.events.on('source', () => {
cmdLine.getSource().forEach(console.dir)
})
// })
// })
const repl = require('repl')
const r = repl.start({
repl.start({
prompt: '> ',
eval: (cmd, context, filename, cb) => {
let command = cmd.trim()
if (command === 'next' || command === 'n') {
cmd_line.stepOverForward(true)
cmdLine.stepOverForward(true)
}
if (command === 'previous' || command === 'p' || command === 'prev') {
cmd_line.stepOverBack(true)
cmdLine.stepOverBack(true)
}
if (command === 'step' || command === 's') {
cmd_line.stepIntoForward(true)
cmdLine.stepIntoForward(true)
}
if (command === 'stepback' || command === 'sb') {
cmd_line.stepIntoBack(true)
cmdLine.stepIntoBack(true)
}
if (command === 'exit' || command === 'quit') {
process.exit(0)
}
if (command === 'var local' || command === 'v l' || command === 'vl') {
cmd_line.displayLocals()
cmdLine.displayLocals()
}
if (command === 'var global' || command === 'v g' || command === 'vg') {
cmd_line.displayGlobals()
cmdLine.displayGlobals()
}
if (command.split(' ')[0] === 'jump') {
let stepIndex = parseInt(command.split(' ')[1], 10)
cmd_line.jumpTo(stepIndex)
cmdLine.jumpTo(stepIndex)
}
cb(null, '');
cb(null, '')
}
});
module.exports = cmd_line
})
module.exports = cmdLine

@ -48,7 +48,7 @@ class ContextManager {
self.web3 = (!webDebugNode ? obj : webDebugNode)
}
self.event.trigger('providerChanged', [type, self.web3])
if (cb) return cb();
if (cb) return cb()
})
self.event.trigger('providerChanged', [type, self.web3])
}

@ -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)
}
}

@ -116,7 +116,7 @@ Debugger.prototype.debugTx = function (tx, loadingCb) {
this.step_manager.event.register('stepChanged', this, function (stepIndex) {
if (!stepIndex) {
return self.event.trigger("endDebug")
return self.event.trigger('endDebug')
}
self.debugger.codeManager.resolveStep(stepIndex, tx)

@ -40,7 +40,7 @@ class DebuggerSolidityLocals {
self.stepManager.currentStepIndex,
(error, result) => {
if (error) {
return error;
return error
}
var stack = result[0].value
var memory = result[1].value

@ -40,10 +40,9 @@ class DebuggerSolidityState {
try {
self.decode(index)
} catch (err) {
console.dir("====> error")
console.dir('====> error')
console.dir(err)
}
}, 500)
}

@ -168,7 +168,7 @@ class DebuggerStepManager {
let steps = []
while (step < this.traceLength) {
let _step = this.resolveToReducedTrace(step, 1)
if (!_step) break;
if (!_step) break
steps.push(_step)
step += 1
}
@ -177,16 +177,16 @@ class DebuggerStepManager {
}
calculateCodeLength () {
let steps = this.calculateCodeStepList().reverse()
return this.calculateCodeStepList().reverse()[1] || this.traceLength;
this.calculateCodeStepList().reverse()
return this.calculateCodeStepList().reverse()[1] || this.traceLength
}
nextStep () {
return this.resolveToReducedTrace(this.currentStepIndex, 1);
return this.resolveToReducedTrace(this.currentStepIndex, 1)
}
previousStep () {
return this.resolveToReducedTrace(this.currentStepIndex, -1);
return this.resolveToReducedTrace(this.currentStepIndex, -1)
}
resolveToReducedTrace (value, incr) {

Loading…
Cancel
Save