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

Arithmetic expression mapping for U256 values #24

Closed
4 tasks
g-r-a-n-t opened this issue Sep 14, 2020 · 0 comments
Closed
4 tasks

Arithmetic expression mapping for U256 values #24

g-r-a-n-t opened this issue Sep 14, 2020 · 0 comments

Comments

@g-r-a-n-t
Copy link
Member

g-r-a-n-t commented Sep 14, 2020

The following Fe expressions should be mapped to Yul, like so:

Fe Yul
a + b add(a', b')
a - b sub(a', b')
a * b mul(a', b')
a / b div(a', b')

Where a and b are vyp::Exprs and a' and b' are yul::Expressions.

todo:

  • call a new function expr_bin_operation here that returns an ExtExpression.
  • add a match statement to expr_bin_operation that matches the Add, Sub, Mult, and Div operations and calls more new functions expr_add, expr_sub, expr_mult, and expr_div. (mark all other branches as unimplemented)
  • match both the left and right ExtExpression types (i.e. (Base::U256, Base::U256)) in each of the expr_ functions and return a new ExtExpression of type U256 with an expression containing the correct arithmetic function.
  • add a test contract with a function that takes two params, adds them together, and returns the result.

Note: the Base::U256 enum value should contain a U256 struct with arithmetic functions attached to it. However, this is not necessary at the moment.

Fits into #21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant