Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
g-r-a-n-t committed Dec 17, 2020
1 parent 5a950da commit e48763d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions semantics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl ExpressionAttributes {
}
}

/// Adds a move to memory, if it is already in memory.
pub fn into_cloned(mut self) -> Result<Self, SemanticError> {
if self.location != Location::Memory {
Err(SemanticError::cannot_move())
Expand All @@ -99,6 +100,7 @@ impl ExpressionAttributes {
}
}

/// Adds a move to memory, if it is in storage.
pub fn into_cloned_from_sto(mut self) -> Result<Self, SemanticError> {
if !matches!(self.location, Location::Storage { .. }) {
Err(SemanticError::cannot_move())
Expand All @@ -108,6 +110,7 @@ impl ExpressionAttributes {
}
}

/// Adds a move to value, if it is in storage or memory.
pub fn into_loaded(mut self) -> Result<Self, SemanticError> {
match self.typ {
Type::Base(_) => {}
Expand All @@ -121,6 +124,8 @@ impl ExpressionAttributes {
Ok(self)
}

/// Adds a move (if necessary) to value if it is a base type and ensures
/// reference types are in memory.
pub fn into_assignable(self) -> Result<Self, SemanticError> {
let assign_location = Location::assign_location(self.typ.to_owned())?;

Expand Down
6 changes: 6 additions & 0 deletions semantics/src/traversal/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub fn expr(
Ok(attributes)
}

/// Gather context information for expressions and check for type errors.
///
/// Also ensures that the expression is on the stack.
pub fn value_expr(
scope: Shared<BlockScope>,
context: Shared<Context>,
Expand All @@ -72,6 +75,9 @@ pub fn value_expr(
Ok(attributes)
}

/// Gather context information for expressions and check for type errors.
///
/// Also ensures that the expression is in the type's assigment location.
pub fn assignable_expr(
scope: Shared<BlockScope>,
context: Shared<Context>,
Expand Down

0 comments on commit e48763d

Please sign in to comment.