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

Improve push ir conversion #625

Merged
merged 5 commits into from
Nov 10, 2020
Merged

Improve push ir conversion #625

merged 5 commits into from
Nov 10, 2020

Conversation

samczsun
Copy link
Contributor

@samczsun samczsun commented Sep 3, 2020

First attempt at handling arr.push() better. Might have used ReferenceVariable wrong. Also removed a block about pushing an array because I'm not sure what Solidity code might trigger that. Hopefully fixes #593

                Expression: arr.push().push()
                IRs:
                        REF_2 -> LENGTH arr
                        TMP_2(uint256) := REF_2(uint256)
                        TMP_3(uint256) = TMP_2 + 1
                        REF_2 (->arr) := TMP_3(uint256)
                        REF_3(uint256[]) -> arr[TMP_2]
                        TMP_0(uint256[]) := REF_3(uint256[])
                        REF_4 -> LENGTH TMP_0
                        TMP_4(uint256) := REF_4(uint256)
                        TMP_5(uint256) = TMP_4 + 1
                        REF_4 (->TMP_0) := TMP_5(uint256)
                        REF_5(uint256) -> TMP_0[TMP_4]
                        TMP_1(uint256) := REF_5(uint256)

@samczsun samczsun requested a review from montyly September 3, 2020 23:06
@montyly
Copy link
Member

montyly commented Sep 4, 2020

So the array path is needed for something like:

contract C{

    uint[][] arr;

    function f() public{
        arr.push([1,2]);
    }

}

In master it generates:

			TMP_1(None) =  ['1', '2']
			PUSH TMP_1 in arr
			TMP_0 -> LENGTH arr

In bugfix/593, it triggers an error: ERROR:ContractSolcParsing:Impossible to generate IR for C.f

@samczsun
Copy link
Contributor Author

samczsun commented Sep 4, 2020

                Expression: arr.push((1,2))
                IRs:
                        REF_7 -> LENGTH arr
                        TMP_7(uint256) := REF_7(uint256)
                        TMP_8(uint256) = TMP_7 + 1
                        REF_7 (->arr) := TMP_8(uint256)
                        REF_8(uint256[]) -> arr[TMP_7]
                        TMP_9(uint256[]) =  ['1', '2']
                        REF_8 (->arr) := TMP_9(uint256[])

@montyly montyly merged commit 32d993c into dev Nov 10, 2020
@montyly montyly deleted the bugfix/593 branch November 10, 2020 13:00
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.

2 participants