Commit d833c974 authored by yann300's avatar yann300 Committed by Aniket

make sure compilation result fn is used with `await` && check for `null` returns

parent 042377b9
...@@ -24,6 +24,7 @@ function Debugger (options) { ...@@ -24,6 +24,7 @@ function Debugger (options) {
this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, async (sourceLocation) => { this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, async (sourceLocation) => {
const compilationResult = await this.compilationResult() const compilationResult = await this.compilationResult()
if (!compilationResult) return { start: null, end: null }
return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources) return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources)
}, (step) => { }, (step) => {
this.event.trigger('breakpointStep', [step]) this.event.trigger('breakpointStep', [step])
...@@ -49,6 +50,7 @@ Debugger.prototype.registerAndHighlightCodeItem = function (index) { ...@@ -49,6 +50,7 @@ Debugger.prototype.registerAndHighlightCodeItem = function (index) {
this.debugger.traceManager.getCurrentCalledAddressAt(index, async (error, address) => { this.debugger.traceManager.getCurrentCalledAddressAt(index, async (error, address) => {
if (error) return console.log(error) if (error) return console.log(error)
const compilationResultForAddress = await this.compilationResult(address) const compilationResultForAddress = await this.compilationResult(address)
if (!compilationResultForAddress) return
this.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, compilationResultForAddress.data.contracts, (error, rawLocation) => { this.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, compilationResultForAddress.data.contracts, (error, rawLocation) => {
if (!error && compilationResultForAddress && compilationResultForAddress.data) { if (!error && compilationResultForAddress && compilationResultForAddress.data) {
var lineColumnPos = this.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, compilationResultForAddress.source.sources, compilationResultForAddress.data.sources) var lineColumnPos = this.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, compilationResultForAddress.source.sources, compilationResultForAddress.data.sources)
......
...@@ -86,7 +86,7 @@ class BreakpointManager { ...@@ -86,7 +86,7 @@ class BreakpointManager {
console.log('cannot jump to breakpoint ' + e) console.log('cannot jump to breakpoint ' + e)
return return
} }
let lineColumn = this.locationToRowConverter(sourceLocation) let lineColumn = await this.locationToRowConverter(sourceLocation)
if (this.previousLine !== lineColumn.start.line) { if (this.previousLine !== lineColumn.start.line) {
if (direction === -1 && lineHadBreakpoint) { // TODO : improve this when we will build the correct structure before hand if (direction === -1 && lineHadBreakpoint) { // TODO : improve this when we will build the correct structure before hand
lineHadBreakpoint = false lineHadBreakpoint = false
......
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