-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing boolean logical operators (#79)
- Loading branch information
1 parent
10237fc
commit a7c109a
Showing
8 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```k | ||
module RUST-BOOL-OPERATIONS | ||
imports private RUST-BOOL-LOGICAL-OPERATIONS | ||
endmodule | ||
module RUST-BOOL-LOGICAL-OPERATIONS | ||
imports RUST-SHARED-SYNTAX | ||
imports private RUST-REPRESENTATION | ||
rule ptrValue(_, A:Bool) && ptrValue(_, B:Bool) => ptrValue(null, A andBool B) | ||
rule ptrValue(_, A:Bool) || ptrValue(_, B:Bool) => ptrValue(null, A orBool B) | ||
rule ! ptrValue(_, B:Bool) => ptrValue(null, notBool B) | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
new BoolOperations; | ||
call BoolOperations.bool_logical_operation_and; | ||
return_value; | ||
check_eq true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
new BoolOperations; | ||
call BoolOperations.bool_logical_operation_or; | ||
return_value; | ||
check_eq true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
new BoolOperations; | ||
call BoolOperations.bool_logical_operation_not; | ||
return_value; | ||
check_eq false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![no_std] | ||
|
||
#[allow(unused_imports)] | ||
use multiversx_sc::imports::*; | ||
|
||
#[multiversx_sc::contract] | ||
pub trait BoolOperations { | ||
#[init] | ||
fn init(&self) { | ||
} | ||
|
||
#[upgrade] | ||
fn upgrade(&self) {} | ||
|
||
fn bool_logical_operation_and(&self) -> bool { true && true } | ||
|
||
fn bool_logical_operation_or(&self) -> bool { false || true } | ||
|
||
fn bool_logical_operation_not(&self) -> bool { ! true } | ||
|
||
} |