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

Cleanup import resolution logic #93

Merged
merged 2 commits into from
Feb 10, 2022
Merged

Cleanup import resolution logic #93

merged 2 commits into from
Feb 10, 2022

Conversation

cd1m0
Copy link
Contributor

@cd1m0 cd1m0 commented Feb 10, 2022

As of #87 we changed solc-typed-ast to infer the set of all imported files, and pass them in to the compiler in the standard JSON. The idea was that we could support a uniform interface between wasm and native compilers - since one of them (wasm) has support for resolving callbacks, but the native one doesn't. Also this way compilers don't need to look around the file system or do anything else - we give them everything they need to compile.

The logic of finding all of the imports however is a little more complex as described here. Our (ok, ok my) original code was a little hacky. In this PR we clean it up to follow more precisely the algorithm described in the docs.

Specifically:

  1. The keys in the map files computed in findAllFiles are now proper source unit names as defined in docs.
  2. findAllFiles was cleaned up a little ,and now no-longer returns a new map.
  3. We pass the original remappings to the underlying compilers again (this is needed so that the underlying compiler computes the same source unit names as we do, and finds them in the files map)

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2022

Codecov Report

Merging #93 (eda0998) into master (6d537a4) will decrease coverage by 0.05%.
The diff coverage is 90.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   92.26%   92.20%   -0.06%     
==========================================
  Files         254      254              
  Lines        5195     5197       +2     
  Branches      817      819       +2     
==========================================
- Hits         4793     4792       -1     
- Misses        253      254       +1     
- Partials      149      151       +2     
Impacted Files Coverage Δ
src/compile/input.ts 78.57% <ø> (ø)
src/compile/inference/imports.ts 90.90% <88.88%> (-5.17%) ⬇️
src/compile/utils.ts 91.30% <100.00%> (-0.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d537a4...eda0998. Read the comment docs.

blitz-1306
blitz-1306 previously approved these changes Feb 10, 2022
Copy link
Contributor

@blitz-1306 blitz-1306 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve. One small question, that is not a blocker and not affect approach overall.

src/compile/inference/imports.ts Outdated Show resolved Hide resolved
src/compile/inference/imports.ts Show resolved Hide resolved
@blitz-1306 blitz-1306 added bug Something isn't working enhancement New feature or request and removed enhancement New feature or request labels Feb 10, 2022
Copy link
Contributor

@blitz-1306 blitz-1306 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@blitz-1306 blitz-1306 merged commit 4f2389f into master Feb 10, 2022
@blitz-1306 blitz-1306 deleted the import_logic_cleanup branch February 10, 2022 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants