use remix-astwalker in remix-debug

pull/5370/head
yann300 4 years ago committed by Aniket
parent da7ac91fea
commit c7223d1f29
  1. 2
      libs/remix-debug/index.js
  2. 1
      libs/remix-debug/package.json
  3. 15
      libs/remix-debug/src/solidity-decoder/astHelper.js
  4. 8
      libs/remix-debug/src/solidity-decoder/internalCallTree.js
  5. 23
      libs/remix-debug/src/source/sourceMappingDecoder.js
  6. 1
      libs/remix-debug/test/tests.js

@ -12,7 +12,6 @@ const SolidityDecoder = require('./src/solidity-decoder')
const BreakpointManager = require('./src/code/breakpointManager')
const SourceMappingDecoder = require('./src/source/sourceMappingDecoder')
const AstWalker = require('./src/source/astWalker')
const traceHelper = require('./src/trace/traceHelper')
@ -28,7 +27,6 @@ module.exports = {
init,
traceHelper,
SourceMappingDecoder,
AstWalker,
EthDebugger: EthDebugger,
TransactionDebugger: TransactionDebugger,
/**

@ -22,6 +22,7 @@
"ethereumjs-util": "^6.2.0",
"ethereumjs-vm": "4.1.3",
"@remix-project/remix-lib": "0.4.30",
"@remix-project/remix-astwalker": "0.0.25",
"web3": "^1.2.4"
},
"devDependencies": {

@ -1,5 +1,5 @@
'use strict'
const AstWalker = require('../source/astWalker')
const { AstWalker } = require('@remix-project/remix-astwalker')
/**
* return all contract definitions of the given @astList
@ -15,12 +15,13 @@ function extractContractDefinitions (sourcesList) {
}
const walker = new AstWalker()
for (let k in sourcesList) {
walker.walk(sourcesList[k].ast, { 'ContractDefinition': (node) => {
ret.contractsById[node.id] = node
ret.sourcesByContract[node.id] = k
ret.contractsByName[k + ':' + node.name] = node
return false
}})
walker.walkFull(sourcesList[k].ast, (node) => {
if (node.nodeType === 'ContractDefinition') {
ret.contractsById[node.id] = node
ret.sourcesByContract[node.id] = k
ret.contractsByName[k + ':' + node.name] = node
}
})
}
return ret
}

@ -1,7 +1,7 @@
'use strict'
const { AstWalker } = require('@remix-project/remix-astwalker')
const remixLib = require('@remix-project/remix-lib')
const SourceLocationTracker = require('../source/sourceLocationTracker')
const AstWalker = require('../source/astWalker')
const EventManager = require('../eventManager')
const decodeInfo = require('./decodeInfo')
@ -312,22 +312,20 @@ function resolveFunctionDefinition (tree, step, sourceLocation) {
function extractVariableDeclarations (ast, astWalker) {
const ret = {}
astWalker.walk(ast, (node) => {
astWalker.walkFull(ast, (node) => {
if (node.nodeType === 'VariableDeclaration') {
ret[node.src] = node
}
return true
})
return ret
}
function extractFunctionDefinitions (ast, astWalker) {
const ret = {}
astWalker.walk(ast, (node) => {
astWalker.walkFull(ast, (node) => {
if (node.nodeType === 'FunctionDefinition') {
ret[node.src] = node
}
return true
})
return ret
}

@ -1,7 +1,7 @@
'use strict'
const { AstWalker } = require('@remix-project/remix-astwalker')
const remixLib = require('@remix-project/remix-lib')
const util = remixLib.util
const AstWalker = require('./astWalker')
/**
* Decompress the source mapping given by solc-bin.js
@ -144,33 +144,26 @@ function findNodeAtInstructionIndex (astNodeType, instIndex, sourceMap, ast) {
function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
const astWalker = new AstWalker()
const callback = {}
let found = null
callback['*'] = function (node) {
const callback = function (node) {
const nodeLocation = sourceLocationFromAstNode(node)
if (!nodeLocation) {
return true
return
}
if (nodeLocation.start <= sourceLocation.start && nodeLocation.start + nodeLocation.length >= sourceLocation.start + sourceLocation.length) {
if (astNodeType === node.nodeType) {
found = node
return false
} else {
return true
}
} else {
return false
}
}
astWalker.walk(ast.ast, callback)
astWalker.walkFull(ast.ast, callback)
return found
}
function nodesAtPosition (astNodeType, position, ast) {
const astWalker = new AstWalker()
const callback = {}
const found = []
callback['*'] = function (node) {
const callback = function (node) {
var nodeLocation = sourceLocationFromAstNode(node)
if (!nodeLocation) {
return
@ -178,14 +171,10 @@ function nodesAtPosition (astNodeType, position, ast) {
if (nodeLocation.start <= position && nodeLocation.start + nodeLocation.length >= position) {
if (!astNodeType || astNodeType === node.nodeType) {
found.push(node)
if (astNodeType) return false
}
return true
} else {
return false
}
}
astWalker.walk(ast.ast, callback)
astWalker.walkFull(ast.ast, callback)
return found
}

@ -1,6 +1,5 @@
'use strict'
require('./astwalker.js')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')

Loading…
Cancel
Save