NethermindEth / warp

Warp - Bringing Solidity to Starknet at warp speed. Warp is a Solidity to Cairo Compiler, this allows teams to write/migrate Solidity to Cairo for easy onboarding into the StarkNet ecosystem.
https://nethermind.io/warp/
Apache License 2.0
754 stars 70 forks source link

Use boolean operations as a part of Cairo1 compiler #963

Closed AlejandroLabourdette closed 1 year ago

AlejandroLabourdette commented 1 year ago

This PR is on hold because bools are being represented in memory as a felt (that could be generalized to all being represented as felts) so was needed some sort of new pass that intervene in those write/read from memory or storage to do a proper conversion Take a look at this issue: https://github.com/NethermindEth/warp/issues/1012

rodrigo-pino commented 1 year ago

Good work! Only missing thing is you need to update the binary expression evaluator for boolean values as well. You should wait for this to get merged

AlejandroLabourdette commented 1 year ago

Good work! Only missing thing is you need to update the binary expression evaluator for boolean values as well. You should wait for this to get merged

Imo these is solved since @cicr99 and @aniket2405 's PR introduce the literal binary expression evaluator changes for booleans.

rodrigo-pino commented 1 year ago

@AlejandroLabourdette when defining constant values such as

bool x = true;

It gets transpiled as

let x = 1;

Which is a felt. This PR should use boolean for those values as well.

AlejandroLabourdette commented 1 year ago

@AlejandroLabourdette when defining constant values such as

bool x = true;

It gets transpiled as

let x = 1;

Which is a felt. This PR should use boolean for those values as well.

It was a minor hard condition in literal writer

case LiteralKind.Bool:
        return [node.value === 'true' ? '1' : '0'];

It's fixed now

AlejandroLabourdette commented 1 year ago

Actually about this

If they (memoryRead and memoryWrite) will be required then I think is a good Idea to put this PR on hold until we address the rewriting (to Cairo1) of those scripts

I think we should merge this PR, since is blocking others like InferType, and then when they are rewritten treat the case of bools just like are managed in storageRead and storageWrite

piwonskp commented 1 year ago

Conflicts

piwonskp commented 1 year ago

Conflicts