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

AST Reference Discovery Ideas #115

Open
0x19 opened this issue Sep 26, 2023 · 2 comments
Open

AST Reference Discovery Ideas #115

0x19 opened this issue Sep 26, 2023 · 2 comments
Assignees
Labels
ast Abstract Syntax Tree ideas Potential Ideas

Comments

@0x19
Copy link
Contributor

0x19 commented Sep 26, 2023

Forward statement resolution in AST seems to be a bit more complicated than it should. However, I am not yet sure how to handle it in the future.

Problematic with forward statement means that node can be anywhere. What that means is that reference for any particular statement can be:

  • In any object.
  • Defined in the same object but after it is executed.
  • Globally defined outside of any object at any point prior or after the statement execution.
  • Literally some types, for example events, structs, vars etc... Can be defined literally anywhere in the code and called out from literally anywhere.

Knowing the problem, dealing with solution becomes troublesome when types descriptions are in question. We basically need to understand the type itself and regularly I need to come back to references during testing as some type is not discovered efficiently. For example, node is not found at all, resulting in skewed AST results and panics due to type description object is not found.

For now I am patching the code to resolve it. However, I'd like in the future to find out proper way how to traverse through the tree and figure out all of the types without doing some ad-hoc kumbaya patches to the resolver.

Moreover, even if node is found, are we certain that that particular node corresponds to the proper reference or just globally defined reference? This calls for a node reverse lookup.

Anyway, just ideas posting here so this story can be upgraded in the future and perhaps better solution can be done.

This is just so we are on a same page, a severe amount of work and will broke the entire code resolution once touched.

@0x19 0x19 self-assigned this Sep 26, 2023
@0x19
Copy link
Contributor Author

0x19 commented Sep 26, 2023

One of the ideas is to build node trees prior ast is built. However, generics in Go still sucks in this particular case especially if you wish to lets say build sane protocol buffer representation of each node and in the end having it result with nice JSON without bunch of things in the object that do not even relate to the expression itself.

@0x19
Copy link
Contributor Author

0x19 commented Sep 26, 2023

Note that at this moment, until millions of contracts are parsed through it there's no valid reason of doing this task as we need to know all of the edge cases prior doing anything sane.

@0x19 0x19 added ast Abstract Syntax Tree ideas Potential Ideas labels Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Abstract Syntax Tree ideas Potential Ideas
Projects
None yet
Development

No branches or pull requests

1 participant