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

Preprocess unimplemented methods #75

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust-semantics/preprocessing/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module RUST-PREPROCESSING-CONFIGURATION
<traits>
<trait multiplicity="*" type="Map">
<trait-path> my_identifier:TypePath </trait-path>
<method-list> .List </method-list> // List of Identifier
<methods>
<method multiplicity="*" type="Map">
<method-name> .Identifier </method-name>
Expand Down
11 changes: 8 additions & 3 deletions rust-semantics/preprocessing/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module INITIALIZATION
.Bag
=> <trait>
<trait-path> Name </trait-path>
<methods> .Bag </methods>
...
</trait>
</traits>

Expand All @@ -33,27 +33,32 @@ module INITIALIZATION
<k> #addMethod(
Trait:TypePath,
Name:Identifier, P:NormalizedFunctionParameterList,
R:Type, B:BlockExpression,
R:Type, B:BlockExpressionOrSemicolon,
A:OuterAttributes
) => .K
...
</k>
<trait>
...
<trait-path> Trait </trait-path>
<method-list> L:List => ListItem(Name) L </method-list>
<methods>
.Bag =>
<method>
<method-name> Name:Identifier </method-name>
<method-params> P </method-params>
<method-return-type> R </method-return-type>
<method-implementation> block(B) </method-implementation>
<method-implementation> toFBR(B) </method-implementation>
<method-outer-attributes> A </method-outer-attributes>
</method>
...
</methods>
</trait>

syntax FunctionBodyRepresentation ::= toFBR(BlockExpressionOrSemicolon) [function, total]
rule toFBR(B:BlockExpression) => block(B)
rule toFBR(;) => empty

endmodule

```
1 change: 0 additions & 1 deletion rust-semantics/representation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module RUST-REPRESENTATION

syntax FunctionBodyRepresentation ::= block(BlockExpression)
| "empty"
| storageAccessor(StringLiteral)
syntax NormalizedFunctionParameter ::= Identifier ":" Type
syntax NormalizedFunctionParameterList ::= List{NormalizedFunctionParameter, ","}

Expand Down
19 changes: 19 additions & 0 deletions tests/preprocessing/storage-method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![no_std]

#[allow(unused_imports)]
use multiversx_sc::imports::*;

#[multiversx_sc::contract]
pub trait Empty {
#[init]
fn init(&self) {
}

#[upgrade]
fn upgrade(&self) {}

#[view(getTokens)]
#[storage_mapper("tokens")]
fn tokens(&self) -> UnorderedSetMapper<TokenIdentifier>;

}
Loading