From 6c64697cde2b58fd86b488f1878b36ce66eb61a9 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Wed, 25 Sep 2024 09:04:37 -0700 Subject: [PATCH] Include some TODOs for functions Signed-off-by: Alek Ratzloff --- src/builtins.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/builtins.rs b/src/builtins.rs index 75ab905..c85873c 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -190,6 +190,9 @@ impl BaseObjInst { pub(crate) fn not_implemented_un(vm: &mut Vm, _state: FunctionState) -> FunctionResult { let fname = &vm.frame().name; + // TODO BaseObjInst::not_implemented_un - throw an exception of some kind for not + // implemented/not available errors on unary operators + // BLOCKED-ON: exceptions todo!( "Raise some kind of not implemented/not callable error for {} function (self: {})", fname, @@ -198,6 +201,9 @@ impl BaseObjInst { } pub(crate) fn not_implemented_bin(vm: &mut Vm, _state: FunctionState) -> FunctionResult { + // TODO BaseObjInst::not_implemented_un - throw an exception of some kind for not + // implemented/not available errors on unary operators + // BLOCKED-ON: exceptions let fname = &vm.frame().name; todo!("Raise some kind of not implemented/not callable error for {} function (self: {}, rhs: {})", fname, vm.frame_stack()[0].borrow(), vm.frame_stack()[1].borrow()) } @@ -279,6 +285,8 @@ macro_rules! bin_op_math { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::() { vm.create_float(lhs_value as f64 $op float_inst.float_value()) } else { + // TODO IntInst arithmetic operator - throw an exception when RHS is not Int, Float + // BLOCKED-ON: exceptions todo!( concat!("cannot use '", stringify!($op), "' operator with Int and {}"), rhs.borrow().type_name() @@ -302,6 +310,8 @@ macro_rules! bin_op_logical { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::() { vm.create_bool((lhs_value as f64) $op float_inst.float_value()) } else { + // TODO IntInst logical operator - throw an exception when RHS is not Int, Float + // BLOCKED-ON: exceptions todo!( concat!("cannot use '", stringify!($op), "' operator with Int and {}"), rhs.borrow().type_name() @@ -328,8 +338,12 @@ impl IntInst { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::() { vm.create_float(lhs_value as f64 * float_inst.float_value()) } else if let Some(str_inst) = rhs.borrow().as_any().downcast_ref::() { + // TODO IntInst::mul - maybe convert this to just call Str.mul with arguments reversed? + // Just so we have the same logic here vm.create_str(str_inst.str_value().repeat(lhs_value as usize)) } else { + // TODO IntInst::mul - throw an exception when RHS is not Int, Float, Str + // BLOCKED-ON: exceptions todo!( "cannot use '*' operator with Int and {}", rhs.borrow().type_name()