forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the storage definitions to the
ty
module. (FuelLabs#2983)
- Loading branch information
1 parent
0190824
commit d51a24e
Showing
8 changed files
with
51 additions
and
49 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#[allow(clippy::module_inception)] | ||
mod expression; | ||
mod expression_variant; | ||
mod storage; | ||
|
||
pub use expression::*; | ||
pub use expression_variant::*; | ||
pub use storage::*; |
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,34 @@ | ||
use sway_types::{state::StateIndex, Ident, Span, Spanned}; | ||
|
||
use crate::type_system::TypeId; | ||
|
||
/// Describes the full storage access including all the subfields | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct TyStorageAccess { | ||
pub fields: Vec<TyStorageAccessDescriptor>, | ||
pub(crate) ix: StateIndex, | ||
} | ||
|
||
impl Spanned for TyStorageAccess { | ||
fn span(&self) -> Span { | ||
self.fields | ||
.iter() | ||
.fold(self.fields[0].span.clone(), |acc, field| { | ||
Span::join(acc, field.span.clone()) | ||
}) | ||
} | ||
} | ||
|
||
impl TyStorageAccess { | ||
pub fn storage_field_name(&self) -> Ident { | ||
self.fields[0].name.clone() | ||
} | ||
} | ||
|
||
/// Describes a single subfield access in the sequence when accessing a subfield within storage. | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct TyStorageAccessDescriptor { | ||
pub name: Ident, | ||
pub(crate) type_id: TypeId, | ||
pub(crate) span: Span, | ||
} |
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
33 changes: 1 addition & 32 deletions
33
sway-core/src/semantic_analysis/ast_node/expression/typed_expression_variant.rs
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