Skip to content

Arithmetic expression mapping for U256 values #24

Closed
@g-r-a-n-t

Description

@g-r-a-n-t

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions