-
-
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
feat: add extend for dynamic arrays #2976
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2976 +/- ##
==========================================
+ Coverage 88.35% 88.37% +0.01%
==========================================
Files 97 97
Lines 10968 11003 +35
Branches 2593 2599 +6
==========================================
+ Hits 9691 9724 +33
- Misses 827 828 +1
- Partials 450 451 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
This is looking pretty good
vyper/codegen/core.py
Outdated
return b1.resolve(b2.resolve(ret)) | ||
|
||
|
||
def _copy_dynarray_body(dst, src, loop_count=None): |
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.
is loop_count
a necessary parameter for this function?
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.
If we do not pass in the loop_count
from _dynarray_make_setter
, the test_nested_struct_of_lists
test in tests/parser/types/test_dynamic_array.py
will pass with the --no-optimize
flag instead of throwing a compilation error. Should I amend the test?
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.
this PR is shaping up, left a couple nits. thinking about whether we might want to move the dynarray method implementations into the builtins file as well? that would probably require exposing copy_dynarray_body
as a public method of codegen.core
though.
Cool, I think that would be neater since they are used only in |
vyper/builtin_functions/functions.py
Outdated
dst_start_idx = get_element_ptr(dst, dst_len, array_bounds_check=False) | ||
|
||
# Cast dst start pointer as darray for `_dynarray_make_setter` by subtracting offset | ||
dst_i = IRnode.from_list(["sub", dst_start_idx, dst.location.word_scale]) |
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.
kind of bothers me that we still have to adjust the offset like this for copy_dynarray_body
What I did
Add
extend()
for dynamic arrays, partial fix for #2611.The source dynamic array (argument) must be of dynamic array type, up to the size of the destination dynamic array.
How I did it
extend_dyn_array
helper tocodegen/core.py
.extend
as member function of dynamic array type.How to verify it
See tests
Commit message
Description for the changelog
Add
extend()
for dynamic arrays.Cute Animal Picture