Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermediate Representation (IR) Support #50

Merged
merged 23 commits into from
Aug 7, 2023
Merged

Conversation

0x19
Copy link
Contributor

@0x19 0x19 commented Aug 5, 2023

Completely new package, Intermediate Representation, designed to bring sanity to the AST by providing contract visual representation that is readable.

Current version will not support function body statements, except FunctionCall.

Function call will be used later on to build control flow graphs so we'll add it inside.

Following package will be used so we can properly build ABIs as well as future CFG graphs (Control Flow Unit) 🥳

Each node has AST node connected to it so in case that any additional transformations/retrievals are needed such as source location, body statements, etc... can be done manually. In the future full support for statements will come but for now, building only necessary parts.

There's one primary unit test in builder_test.go that does most of the required job. Rest of the unit tests are just boilerplates for the future and to test out that getters are actually there, in place, working.

Bugfixes:

  • Reference forward declaration were broken for: Source Unit, BaseContracts, Imports and Symbols. Basically, everywhere in cases where contract sources are randomized. This is now resolved and we're one step closer to the fully correctly referenced ast.
  • Some of the nodes didn't use pointer, I've made sure it's sorted out.
  • Fallback and Revert had Declaration in name which I've dropped to be in standard as everything else.

Additions:

  • Added support for MaskLocalSourcesPath in sources.go ensuring returned response path do not contain full path. This is for example when we're serving it from the browser to not see local full path where it's located 😂

@0x19 0x19 added documentation Improvements or additions to documentation enhancement New feature or request future work Something we should do in the future ir Intermediate Representation labels Aug 5, 2023
@0x19 0x19 self-assigned this Aug 5, 2023
@coveralls
Copy link

coveralls commented Aug 5, 2023

Pull Request Test Coverage Report for Build 5789356876

  • 1734 of 2357 (73.57%) changed or added relevant lines in 53 files are covered.
  • 9 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.7%) to 79.122%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ast/parameter_list.go 6 7 85.71%
ast/if.go 5 7 71.43%
ir/event.go 52 55 94.55%
ir/modifier.go 23 26 88.46%
ir/parameter.go 26 29 89.66%
ir/pragma.go 35 38 92.11%
ast/primary_expression.go 20 25 80.0%
ir/root.go 68 73 93.15%
ast/builder.go 0 6 0.0%
ast/state_variable.go 4 10 40.0%
Files with Coverage Reduction New Missed Lines %
ast/function_call.go 1 86.05%
ast/if.go 1 86.3%
ast/parameter_list.go 1 85.87%
ast/primary_expression.go 3 89.16%
ast/tuple.go 3 91.59%
Totals Coverage Status
Change from base Build 5767250455: -0.7%
Covered Lines: 8277
Relevant Lines: 10461

💛 - Coveralls

@0x19 0x19 changed the title Intermediate Response (IR) Support Intermediate Representation (IR) Support Aug 5, 2023
@0x19
Copy link
Contributor Author

0x19 commented Aug 5, 2023

At this point we have all of the basic parts covered from the AST besides the FunctionCall.

Prior this PR is merged to master following needs to happen:

  • FunctionCall needs to be implemented.
  • Protocol buffers needs to be resolved.
  • Unit tests! Not going out without it!

Once this is done, we're ready for release of 1st revision of the Intermediate Response package!

@0x19 0x19 linked an issue Aug 6, 2023 that may be closed by this pull request
@0x19 0x19 linked an issue Aug 6, 2023 that may be closed by this pull request
@0x19 0x19 merged commit e74af8c into main Aug 7, 2023
8 checks passed
@0x19 0x19 deleted the intermediate-response branch August 7, 2023 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request future work Something we should do in the future ir Intermediate Representation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abstract Syntax Tree (AST) Forward Statement Discovery Intermediate Representation (IR) Support
2 participants