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

If expressions #82

Merged
merged 9 commits into from
Sep 12, 2024
Merged

If expressions #82

merged 9 commits into from
Sep 12, 2024

Conversation

ACassimiro
Copy link
Collaborator

Introducing if expressions to our rust-lite semantics.

ACassimiro and others added 5 commits September 10, 2024 18:24
* Arrange the cells for easier debugging

* Create a list of traits to help with mx preprocessing

* Static method calls

* Integer - value conversions

* Ignore generic args when casting structs

* Framework for executing Mx+Rust

* Framework for testing Mx+Rust

* Implement storage functions

* Implement storage accessors

* Implement BigUint::from

* Default storage values

* Storage set_if_empty

* Storage tests

---------

Co-authored-by: Virgil <[email protected]>
@ACassimiro ACassimiro marked this pull request as draft September 12, 2024 00:43
@ACassimiro ACassimiro marked this pull request as ready for review September 12, 2024 00:48
@ACassimiro
Copy link
Collaborator Author

Addresses #17 .

Copy link
Member

@virgil-serbanuta virgil-serbanuta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to make sure that these work before closing #17:

fn test_if1(&self) {  // No return type
  if true {
    10u64
  } else {
    11u64
  };
}

and

fn test_if2(&self) -> u64 {
  if true {
    10u64
  } else {
    11u64
  };
  11
}

rule S:ExpressionWithBlock ; => S

rule (if ptrValue(_, true) S:BlockExpression):ExpressionWithBlock => S [owise]
rule (if ptrValue(_, false) _:BlockExpression):ExpressionWithBlock => . [owise]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the standard is to use ".K" instead of ".". It also produces this warning:

[Warning] Compiler: Use of deprecated production found; this syntax may be
removed in the future.
        Source(/mnt/data/pi-squared/rust-demo-semantics/rust-semantics/execution/conditionals.md)
        Location(10,75,10,76)
        10 |        rule (if ptrValue(_, false) _:BlockExpression):ExpressionWithBlock =>
. [owise]
           .                                                                             
^

Comment on lines 9 to 13
rule (if ptrValue(_, true) S:BlockExpression):ExpressionWithBlock => S [owise]
rule (if ptrValue(_, false) _:BlockExpression):ExpressionWithBlock => . [owise]

rule (if ptrValue(_, true) A:BlockExpression else _:IfElseExpression):ExpressionWithBlock => A
rule (if ptrValue(_, false) _:BlockExpression else B:IfElseExpression):ExpressionWithBlock => B
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the 4 rules above are actually part of expression evaluation.

imports RUST-SHARED-SYNTAX
imports RUST-VALUE-SYNTAX

rule S:ExpressionWithBlock ; => S
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not specific to if so I would put it in a different file (block-expressions.md maybe?)

@ACassimiro ACassimiro merged commit ff36b94 into main Sep 12, 2024
1 check passed
@ACassimiro ACassimiro deleted the if-expressions branch September 12, 2024 19:45
@ACassimiro
Copy link
Collaborator Author

Also addresses #30.

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