-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
refactor[venom]: make venom repr parseable #4402
Merged
charles-cooper
merged 19 commits into
vyperlang:master
from
charles-cooper:refactor/bb-output
Dec 19, 2024
Merged
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bfdc7a7
refactor[venom]: make venom repr parseable
charles-cooper c68c455
Merge branch 'master' into refactor/bb-output
charles-cooper 8bb9a68
update phi repr
charles-cooper abd2e54
Merge branch 'master' into refactor/bb-output
charles-cooper 055328a
fix VAR_IDENT parsing
charles-cooper 80a6c51
small grammar fixes
charles-cooper 2568231
allow escaped strings for labels
charles-cooper f967dce
wip escaped labels
charles-cooper d90f606
fix: invalid uses of IRLabel.__repr__
charles-cooper 813d937
add tests -- round-trip through venom frontend
charles-cooper 79206f3
Merge branch 'master' into refactor/bb-output
charles-cooper 46d4a7a
extract grammar as VENOM_GRAMMAR variable
charles-cooper 84a9445
xfail when optimization level == codesize
charles-cooper 06ff7f9
wip - try removing db case
charles-cooper cb53c5e
Merge branch 'master' into refactor/bb-output
charles-cooper 192d82c
fix rule for variables
charles-cooper 86c6a60
change text format for `invoke`
charles-cooper 403ded7
Merge branch 'master' into refactor/bb-output
charles-cooper 7180acc
factor out a function
charles-cooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import glob | ||
|
||
import pytest | ||
|
||
from tests.venom_utils import assert_ctx_eq, parse_venom | ||
from vyper.compiler import compile_code | ||
from vyper.compiler.settings import OptimizationLevel | ||
from vyper.venom.context import IRContext | ||
|
||
""" | ||
Check that venom text format round-trips through parser | ||
""" | ||
|
||
|
||
def get_example_vy_filenames(): | ||
return glob.glob("**/*.vy", root_dir="examples/", recursive=True) | ||
|
||
|
||
@pytest.mark.parametrize("vy_filename", get_example_vy_filenames()) | ||
def test_round_trip(vy_filename, optimize, request): | ||
if optimize == OptimizationLevel.CODESIZE: | ||
# codesize optimization issues things like `db b"\x12\x34"` which we | ||
# don't handle. | ||
request.node.add_marker(pytest.mark.xfail(strict=False, reason="unimplemented in parser")) | ||
|
||
path = f"examples/{vy_filename}" | ||
with open(path) as f: | ||
vyper_source = f.read() | ||
|
||
out = compile_code(vyper_source, output_formats=["bb_runtime"]) | ||
bb_runtime = out["bb_runtime"] | ||
venom_code = IRContext.__repr__(bb_runtime) | ||
|
||
ctx = parse_venom(venom_code) | ||
|
||
assert_ctx_eq(bb_runtime, ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if it would be better to just change up some of the labels instead of parsing escaped string (I dont know how many cases are there I stumbled so far on case with the space which could be replaced by underscore)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i could do it both ways honestly, but this seemed nicer for debugging (you can imagine the frontend generating a sentence or description of where it came from for a label)