-
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.
* Addressing constants with type identifiers, introducing tests and fixing path typo in rust-lite * Fixing warning * Addressing comments * Minor adjustments in tests --------- Co-authored-by: Virgil <[email protected]>
- Loading branch information
1 parent
8dd30e7
commit 4e187e5
Showing
9 changed files
with
63 additions
and
4 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
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,14 @@ | ||
```k | ||
module RUST-EXPRESSION-CONSTANTS | ||
imports private COMMON-K-CELL | ||
imports private RUST-SHARED-SYNTAX | ||
imports private RUST-REPRESENTATION | ||
imports private RUST-PREPROCESSING-CONFIGURATION | ||
rule <k> Name:Identifier::.PathExprSegments => V ... </k> | ||
<constant-name> Name </constant-name> | ||
<constant-value> V:Value </constant-value> | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
new ConstantValueLookup; | ||
call ConstantValueLookup.lookup_constant; | ||
return_value; | ||
check_eq 7_000_u64 |
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 ConstantValueLookup; | ||
call ConstantValueLookup.lookup_constant_with_type; | ||
return_value; | ||
check_eq 7100_u64 |
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,24 @@ | ||
#![no_std] | ||
|
||
#[allow(unused_imports)] | ||
use multiversx_sc::imports::*; | ||
|
||
pub const SAMPLE_CONSTANT: u64 = 7_000; | ||
|
||
#[multiversx_sc::contract] | ||
pub trait ConstantValueLookup { | ||
#[init] | ||
fn init(&self) { | ||
} | ||
|
||
#[upgrade] | ||
fn upgrade(&self) {} | ||
|
||
fn lookup_constant(&self) -> u64 { SAMPLE_CONSTANT } | ||
|
||
fn lookup_constant_with_type(&self) -> u64 { | ||
let x = 100_u64 + SAMPLE_CONSTANT; | ||
x | ||
} | ||
|
||
} |
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