From 1c8722ba992c4b34d079e8baf5ee189b2068c831 Mon Sep 17 00:00:00 2001 From: Erin Date: Sat, 28 Aug 2021 23:59:04 +0200 Subject: [PATCH] Added placeholders for And + Or and used placeholders for -, * and / in interpret --- ablescript/src/interpret.rs | 10 +++++----- ablescript/src/variables.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index 73e9ed8..656583a 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -142,15 +142,15 @@ impl ExecEnv { let rhs = self.eval_expr(rhs)?; match kind { Add => lhs + rhs, - Subtract => todo!(), - Multiply => todo!(), - Divide => todo!(), + Subtract => lhs - rhs, + Multiply => lhs * rhs, + Divide => lhs / rhs, Greater => Value::Bool(lhs > rhs), Less => Value::Bool(lhs < rhs), Equal => Value::Bool(lhs == rhs), NotEqual => Value::Bool(lhs != rhs), - And => todo!(), - Or => todo!(), + And => lhs & rhs, + Or => lhs | rhs, } } Not(expr) => Bool(!self.eval_expr(expr)?.into_bool()), diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 20f0031..7a5492a 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -392,6 +392,22 @@ impl PartialOrd for Value { } } +impl ops::BitAnd for Value { + type Output = Value; + + fn bitand(self, rhs: Self) -> Self::Output { + todo!() + } +} + +impl ops::BitOr for Value { + type Output = Value; + + fn bitor(self, rhs: Self) -> Self::Output { + todo!() + } +} + impl Display for Value { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self {