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 end offsets and compressed source map #1580

merged 12 commits into from Aug 24, 2019


Copy link

@iamdefinitelyahuman iamdefinitelyahuman commented Aug 24, 2019

What I did

  • Add end offsets to Vyper AST nodes and pc_pos_map
  • Add jump map and compressed source map to compiler source map output

How I did it

  • Add tokens to the python AST nodes using the asttokens library
  • Use the tokens to add end_lineno and end_col_offset attributes to the final Vyper AST. (Attributes with these names are included in the standard ast library as of Python 3.8)
  • include these new attributes when generating the LLLnode objects, and add their values to pc_pos_map as returned by vyper.compile_lll.assembly_to_evm
  • add pc_jump_map to assembly_to_evm output, in the format {'program counter': [io-]} - i indicates a jump instruction going into a private function, o coming out of a private function, - is an internal instruction such as a for loop or if / else statement.
  • added vyper.compiler.compress_source_map: given source code, pc_pos_map and pc_jump_map, generates a compressed source map in the same format used by solc
  • added vyper.compiler.expand_source_map: given a compressed source map string, expands it into a list of 4 item lists as [start, length, contract_id, jump]
  • include pc_jump_map and pc_pos_map_compressed to compiler output given by vyper.compiler.get_source_map

How to verify it

Run the tests. I have added several new test cases around the jump map and compressed source map.

Description for the changelog

  • Add end offsets to source map

Cute Animal Picture


Copy link

@jacqueswww jacqueswww left a comment


Copy link

@jacqueswww jacqueswww commented Aug 24, 2019

@iamdefinitelyahuman I think the CLI switch is missing?

Copy link
Contributor Author

@iamdefinitelyahuman iamdefinitelyahuman commented Aug 24, 2019

@jacqueswww For now I've just included it as part of the output for source_map - my next target is #1520 where I plan to separate it all out a bit more.

If you'd like I can add another flag, compressed_source_map maybe?

Copy link

@jacqueswww jacqueswww commented Aug 24, 2019

I reckon that's fine for now, especially because of #1520 👍

@fubuloubu fubuloubu merged commit 389897f into vyperlang:master Aug 24, 2019
3 checks passed
@iamdefinitelyahuman iamdefinitelyahuman deleted the ast-end-offsets branch Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants