No funded issue found.
Check out the Issue Explorer
Be the OSS Funding you wish to see in the world.
Looking to fund some work? You can submit a new Funded Issue here .
Time left
Opened
Issue Type
Workers Auto Approve
Project Type
Time Commitment
Experience Level
Permissions
Accepted
Reserved For
memory arrays should have push() and pop()
hyperledger-labs
solang, solidity, arrays, push, pop
Dynamic memory arrays currently cannot be resized. This is true for Solang and solc solidity. However, Solang uses a heap, and has a realloc() function. Thus it is is possible for Solang to support pop() and push() on memory arrays.
Note that push and pop already supported on contract storage arrays. Also, arrays are stored in struct vectors in Solang, which are allocated with malloc.
Steps:
- In [method call](https://github.com/hyperledger-labs/solang/blob/master/src/resolver/expression.rs#L4124) add some code to detect "push" and "pop" call on memory arrays. This should result in a new Expression::DynamicArrayPush() and Expression::DynamicArrayPop().
Note that push() with no arguments should return a reference to the new element.
- In the [code emitter](https://github.com/hyperledger-labs/solang/blob/master/src/emit/mod.rs#L1473), some code is needed to emit code for Expression::DynamicArrayPush() and Expression::DynamicArrayPop(). Both of these will new to call realloc() to resize the array, and of course pop needs to return the last element and push the new element.
- The call return value of realloc() might be a new pointer if the memory was be moved. The array variable will need to be updated.
- An alternative implementation would generate a Expression::DynamicArrayResize() for the code emitter.
- Arrays can be the `bytes` type, or every type followed by `[]`, so `int64[]`, `address[]`, `struct-foo[]`, `enum-bar[]`. All types will need test cases like the one below.
```
contract c {
function test() public {
bytes foo = new bytes(1);
foo[0] = 128;
foo.push(64);
assert(foo.length == 2);
assert(foo[1] == 64);
assert(64 == foo.pop());
assert(foo.length == 1);
}
}
```
Setup your profile
Tell us a little about you:
Skills
No results found for [[search]] .
Type to search skills..
Bio Required
[[totalcharacter]] / 240
Are you currently looking for work?
[[ option.string ]]
Next
Setup your profile
Our tools are based on the principles of earn (š°), learn (š), and meet (š¬).
Select the ones you are interested in. You can change it later in your settings.
I'm also an organization manager looking for a great community.
Back
Next
Save
Enable your organization profile
Gitcoin products can help grow community around your brand. Create your tribe, events, and incentivize your community with bounties. Announce new and upcoming events using townsquare. Find top-quality hackers and fund them to work with you on a grant.
These are the organizations you own. If you don't see your organization here please be sure that information is public on your GitHub profile. Gitcoin will sync this information for you.
Select the products you are interested in:
Out of the box you will receive Tribes Lite for your organization. Please provide us with a contact email:
Email
Back
Save