Commit 2984cc21 authored by aniket-engg's avatar aniket-engg Committed by Aniket

source imports updated

parent 4c0a7417
'use strict' 'use strict'
const SourceMappingDecoder = require('./sourceMappingDecoder') import { getLinebreakPositions, convertOffsetToLineColumn } from './sourceMappingDecoder'
export class OffsetToColumnConverter { export class OffsetToColumnConverter {
...@@ -8,7 +8,6 @@ export class OffsetToColumnConverter { ...@@ -8,7 +8,6 @@ export class OffsetToColumnConverter {
constructor(compilerEvent) { constructor(compilerEvent) {
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.sourceMappingDecoder = new SourceMappingDecoder()
if (compilerEvent) { if (compilerEvent) {
compilerEvent.register('compilationFinished', (success, data, source) => { compilerEvent.register('compilationFinished', (success, data, source) => {
this.clear() this.clear()
...@@ -23,12 +22,12 @@ export class OffsetToColumnConverter { ...@@ -23,12 +22,12 @@ export class OffsetToColumnConverter {
// source id was string before. in newer versions it has been changed to an integer so we need to check the type here // source id was string before. in newer versions it has been changed to an integer so we need to check the type here
if (typeof source.id === 'string') source.id = parseInt(source.id, 10) if (typeof source.id === 'string') source.id = parseInt(source.id, 10)
if (source.id === file) { if (source.id === file) {
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) this.lineBreakPositionsByContent[file] = getLinebreakPositions(sources[filename].content)
break break
} }
} }
} }
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) return convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
} }
clear () { clear () {
......
'use strict' 'use strict'
const EventManager = require('../eventManager') import { EventManager } from '../eventManager'
const helper = require('../trace/traceHelper') import { isContractCreation } from '../trace/traceHelper'
const SourceMappingDecoder = require('./sourceMappingDecoder') import { atIndex } from './sourceMappingDecoder'
const remixLib = require('@remix-project/remix-lib') import { util } from '@remix-project/remix-lib'
const { map } = require('jquery')
const util = remixLib.util
/** /**
* Process the source code location for the current executing bytecode * Process the source code location for the current executing bytecode
...@@ -14,7 +12,6 @@ export class SourceLocationTracker { ...@@ -14,7 +12,6 @@ export class SourceLocationTracker {
opts opts
codeManager codeManager
event event
sourceMappingDecoder
sourceMapByAddress sourceMapByAddress
constructor (_codeManager, { debugWithGeneratedSources }) { constructor (_codeManager, { debugWithGeneratedSources }) {
...@@ -23,7 +20,6 @@ export class SourceLocationTracker { ...@@ -23,7 +20,6 @@ export class SourceLocationTracker {
} }
this.codeManager = _codeManager this.codeManager = _codeManager
this.event = new EventManager() this.event = new EventManager()
this.sourceMappingDecoder = new SourceMappingDecoder()
this.sourceMapByAddress = {} this.sourceMapByAddress = {}
} }
...@@ -36,7 +32,7 @@ export class SourceLocationTracker { ...@@ -36,7 +32,7 @@ export class SourceLocationTracker {
*/ */
async getSourceLocationFromInstructionIndex (address, index, contracts) { async getSourceLocationFromInstructionIndex (address, index, contracts) {
const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts) const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts)
return this.sourceMappingDecoder.atIndex(index, sourceMap['map']) return atIndex(index, sourceMap['map'])
} }
/** /**
...@@ -49,7 +45,7 @@ export class SourceLocationTracker { ...@@ -49,7 +45,7 @@ export class SourceLocationTracker {
async getSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) { async getSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) {
const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts) const sourceMap = await this.extractSourceMap(this, this.codeManager, address, contracts)
const index = this.codeManager.getInstructionIndex(address, vmtraceStepIndex) const index = this.codeManager.getInstructionIndex(address, vmtraceStepIndex)
return this.sourceMappingDecoder.atIndex(index, sourceMap['map']) return atIndex(index, sourceMap['map'])
} }
/** /**
...@@ -72,7 +68,7 @@ export class SourceLocationTracker { ...@@ -72,7 +68,7 @@ export class SourceLocationTracker {
* @param {Object} contractDetails - AST of compiled contracts * @param {Object} contractDetails - AST of compiled contracts
*/ */
async getValidSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) { async getValidSourceLocationFromVMTraceIndex (address, vmtraceStepIndex, contracts) {
let map = { file: -1} let map: Record<string, number> = { file: -1}
while (vmtraceStepIndex >= 0 && map.file === -1) { while (vmtraceStepIndex >= 0 && map.file === -1) {
map = await this.getSourceLocationFromVMTraceIndex(address, vmtraceStepIndex, contracts) map = await this.getSourceLocationFromVMTraceIndex(address, vmtraceStepIndex, contracts)
vmtraceStepIndex = vmtraceStepIndex - 1 vmtraceStepIndex = vmtraceStepIndex - 1
...@@ -85,7 +81,7 @@ export class SourceLocationTracker { ...@@ -85,7 +81,7 @@ export class SourceLocationTracker {
} }
private getSourceMap (address, code, contracts) { private getSourceMap (address, code, contracts) {
const isCreation = helper.isContractCreation(address) const isCreation = isContractCreation(address)
let bytes let bytes
for (let file in contracts) { for (let file in contracts) {
for (let contract in contracts[file]) { for (let contract in contracts[file]) {
...@@ -111,7 +107,7 @@ export class SourceLocationTracker { ...@@ -111,7 +107,7 @@ export class SourceLocationTracker {
codeManager.getCode(address).then((result) => { codeManager.getCode(address).then((result) => {
const sourceMap = this.getSourceMap(address, result.bytecode, contracts) const sourceMap = this.getSourceMap(address, result.bytecode, contracts)
if (sourceMap) { if (sourceMap) {
if (!helper.isContractCreation(address)) self.sourceMapByAddress[address] = sourceMap if (!isContractCreation(address)) self.sourceMapByAddress[address] = sourceMap
return resolve(sourceMap) return resolve(sourceMap)
} }
reject('no sourcemap associated with the code ' + address) reject('no sourcemap associated with the code ' + address)
......
'use strict' 'use strict'
const { AstWalker } = require('@remix-project/remix-astwalker') import { AstWalker } from '@remix-project/remix-astwalker'
const remixLib = require('@remix-project/remix-lib') import { util } from '@remix-project/remix-lib'
const util = remixLib.util
/** /**
* Decompress the source mapping given by solc-bin.js * Decompress the source mapping given by solc-bin.js
......
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