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

refactor: remove FunctionSignature #3390

Merged
merged 112 commits into from
May 17, 2023

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented May 8, 2023

What I did

Refactoring PR that removes GlobalContext.parse_type() and consolidates FunctionSignature into ContractFunctionT, and moves FrameInfo and IR labels into a new FunctionIRInfo class.

Also removes dead code in IR generation
- parse_Name in vyper/codegen/stmt.py is never reachable because a statement can no longer be a standalone Name node. ~
~ - This was the original form of the equivalent function a while [back (https://github.com/vyperlang/vyper/blob/17bfed46411e2bc9aa47c88a784f068a59a09d9d/vyper/parser/stmt.py). Also removed code related to a single statement Name node being "vdb", which "vdb" file no longer exists in the repo.

How I did it

How to verify it

See tests

Commit message

refactor: remove `FunctionSignature`

This commit merges the old `FunctionSignature` with the newer
`ContractFunctionT` class. The old functionality has been subsumed under
`ContractFunctionT`. `ContractFunctionT` has additionally been
refactored for clarity; the new main fields are `positional_args` and
`keyword_args`, which improves on the old terminology of
`base_args`/`default_args` vs `min_arg_count`/`max_arg_count` and
improves the readability of downstream code.

this commit also
- removes the old codegen `parse_type()` functions
- simplifies codegen by removing the sigs dictionary from
  `vyper/codegen/context.py`
- simplifies the `lookup_internal_function` routine (now renamed to
  `_align_kwargs`)
- simplifies `vyper/codegen/module.py` by removing the sigs dictionaries
  and now instead relying on type annotations

Description for the changelog

Remove parse_type() and FunctionSignature

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented May 8, 2023

Codecov Report

Merging #3390 (37af37c) into master (f450cb1) will decrease coverage by 21.36%.
The diff coverage is 93.63%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##           master    #3390       +/-   ##
===========================================
- Coverage   89.05%   67.69%   -21.36%     
===========================================
  Files          86       84        -2     
  Lines       10792    10758       -34     
  Branches     2449     2451        +2     
===========================================
- Hits         9611     7283     -2328     
- Misses        781     2847     +2066     
- Partials      400      628      +228     
Impacted Files Coverage Δ
vyper/builtins/_utils.py 0.00% <ø> (-100.00%) ⬇️
vyper/codegen/global_context.py 90.47% <ø> (-9.53%) ⬇️
vyper/ast/nodes.py 72.58% <80.00%> (-21.66%) ⬇️
vyper/compiler/output.py 37.50% <85.71%> (-53.60%) ⬇️
vyper/semantics/types/function.py 69.50% <88.88%> (-15.03%) ⬇️
vyper/codegen/self_call.py 96.07% <94.11%> (+0.42%) ⬆️
vyper/codegen/function_definitions/common.py 97.40% <96.42%> (-2.60%) ⬇️
vyper/ast/expansion.py 79.06% <100.00%> (-15.94%) ⬇️
vyper/builtins/_convert.py 39.69% <100.00%> (-51.18%) ⬇️
vyper/codegen/context.py 89.43% <100.00%> (-2.54%) ⬇️
... and 12 more

... and 39 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tserg tserg marked this pull request as draft May 8, 2023 11:36
@charles-cooper
Copy link
Member

ah interesting - i was originally planning to remove FunctionSignature entirely and replace its functionality with ContractFunctionT, maybe that should be the scope of this PR instead?

vyper/codegen/module.py Fixed Show fixed Hide fixed
vyper/codegen/context.py Fixed Show fixed Hide fixed
vyper/codegen/self_call.py Fixed Show fixed Hide fixed
@charles-cooper
Copy link
Member

alright - i made a couple more changes that i had been planning to do later but seemed appropriate as part of this PR:

  • remove the sigs data structure from the codegen Context object entirely
  • remove the local_sigs dict from vyper/codegen/module.py, and
  • lookup_internal_function into vyper/codegen/self_call.py

these clean up a lot of the conceptual burden around how function signatures are calculated and passed around, and lay some nice groundwork for future work on modules :)

@charles-cooper charles-cooper changed the title refactor: remove FunctionSignature and parse_type refactor: remove FunctionSignature May 16, 2023
@charles-cooper charles-cooper marked this pull request as ready for review May 16, 2023 21:00
Copy link
Member

@charles-cooper charles-cooper 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, nice work!

@charles-cooper charles-cooper enabled auto-merge (squash) May 17, 2023 15:06
@charles-cooper charles-cooper enabled auto-merge (squash) May 17, 2023 16:45
@charles-cooper charles-cooper merged commit 08f0ac5 into vyperlang:master May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants