Move ComparisonNumber into the library and add an OwnedLiteral for booleans.

This commit is contained in:
Tom Alexander
2020-06-14 17:08:01 -04:00
parent 8ab315abfe
commit 83c86ff9b3
6 changed files with 148 additions and 169 deletions

View File

@@ -18,6 +18,13 @@ impl From<&OwnedLiteral> for MathNumber {
fn from(original: &OwnedLiteral) -> Self {
match original {
OwnedLiteral::LString(_) => panic!("Strings should not be cast to numbers for math"),
OwnedLiteral::LBoolean(boolean) => {
if *boolean {
MathNumber::Integer(1)
} else {
MathNumber::Integer(0)
}
}
OwnedLiteral::LPositiveInteger(num) => {
return MathNumber::Integer((*num).try_into().unwrap())
}