-
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.
* Top level functions (#147) (#149) * Refactor methods * Run global functions * Tests for top level fn without args * External blocks Co-authored-by: Virgil <[email protected]> * adding the declaration of structs * Adding declaration of tests * Enabling parsing by having struct expressions * Introducing struct creations * Adding tests * Partially addressing the PR review * Fixing Struct syntax not matching reference * Adapting the struct expressions to be closer to the reference * Adding missing comment * Addressing PR review --------- Co-authored-by: Virgil <[email protected]>
- Loading branch information
1 parent
d579e16
commit 3e4b57e
Showing
9 changed files
with
206 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
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
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 :: structs :: StructFile; | ||
call :: structs :: StructFile.struct_with_var_assignment; | ||
return_value; | ||
check_eq 2_u32 |
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 :: structs :: StructFile; | ||
call :: structs :: StructFile.struct_without_var_assignment; | ||
return_value; | ||
check_eq 3_u32 |
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,36 @@ | ||
#![no_std] | ||
|
||
#[allow(unused_imports)] | ||
use multiversx_sc::imports::*; | ||
|
||
struct Pair{i: u32, j: u32 } | ||
struct Triple{i: u32, j: u32, k: u32 } | ||
|
||
#[multiversx_sc::contract] | ||
pub trait StructFile { | ||
#[init] | ||
fn init(&self) { | ||
} | ||
|
||
#[upgrade] | ||
fn upgrade(&self) {} | ||
|
||
fn struct_with_var_assignment(&self) -> u32 { | ||
let _pair = ::structs::Pair { | ||
i: 1_u32, | ||
j: 2_u32 | ||
}; | ||
let x = _pair.j; | ||
x | ||
} | ||
|
||
fn struct_without_var_assignment(&self) -> u32 { | ||
let _triple = ::structs::Triple { | ||
1_u32, | ||
2_u32, | ||
3_u32 | ||
}; | ||
let x = _triple.k; | ||
x | ||
} | ||
} |