-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference}; | ||
use powdr_ast::analyzed::{AlgebraicExpression, AlgebraicReference}; | ||
|
||
/// Checks if an expression is | ||
/// - a polynomial | ||
/// - not part of a polynomial array | ||
/// - not shifted with `'` | ||
/// | ||
/// and return the polynomial if so | ||
pub fn try_to_simple_poly<T>(expr: &Expression<T>) -> Option<&AlgebraicReference> { | ||
if let Expression::Reference(p @ AlgebraicReference { next: false, .. }) = expr { | ||
/// Checks if an algebraic expression just a polynomial / column reference without "next" | ||
/// and returns the polynomial if so | ||
pub fn try_to_simple_poly<T>(expr: &AlgebraicExpression<T>) -> Option<&AlgebraicReference> { | ||
if let AlgebraicExpression::Reference(p @ AlgebraicReference { next: false, .. }) = expr { | ||
Some(p) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
pub fn try_to_simple_poly_ref<T>(expr: &Expression<T>) -> Option<&AlgebraicReference> { | ||
if let Expression::Reference(poly_ref) = expr { | ||
(!poly_ref.next).then_some(poly_ref) | ||
} else { | ||
None | ||
} | ||
} |