Consensys / sol-dbg

Solidity source debugger built around EthereumJS
Apache License 2.0
21 stars 3 forks source link

Feature: Query via typed AST #10

Open sambacha opened 2 years ago

sambacha commented 2 years ago

AST Query

TLDR: Provide an AST pattern, and see details about when that pattern was introduced.

Overview

This enables a much easier way to understand how or why a pattern was introduced. For instance, you can answer questions such as:

To query the codebase to search for such a pattern, we can specify an AST selector as it would be accepted by Forge Lint.

AST selector is supported on AST Explorer for solidity.

For instance, to search for console.log() calls in javascript, the ESLint selector would be

"CallExpression[callee.object.name=console][callee.property.name=log]"

Other use cases

This could be used to help automate refactoring, finding regressions, and more since the debugger is based on a typed AST.

References

see ref. implementation for ESLint, https://github.com/NickHeiner/query-pattern-age/tree/use-in-tv#query-pattern-age

cd1m0 commented 1 year ago

Is this report meant to be subimtted to the solc-typed-ast repo?

sambacha commented 1 year ago

Is this report meant to be subimtted to the solc-typed-ast repo?

Imma be real with you i opened this issue as a way to reference the idea - bookmark it for myself

sambacha commented 1 year ago

Really why not just go to yul ir that would be better

cd1m0 commented 1 year ago

Could you provide more context about what you mean by "going to yul ir" in the context of the solidity debugger?