Include some TODOs for functions

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-25 09:04:37 -07:00
parent f35053a6c1
commit 6c64697cde

View File

@@ -190,6 +190,9 @@ impl BaseObjInst {
pub(crate) fn not_implemented_un(vm: &mut Vm, _state: FunctionState) -> FunctionResult { pub(crate) fn not_implemented_un(vm: &mut Vm, _state: FunctionState) -> FunctionResult {
let fname = &vm.frame().name; 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!( todo!(
"Raise some kind of not implemented/not callable error for {} function (self: {})", "Raise some kind of not implemented/not callable error for {} function (self: {})",
fname, fname,
@@ -198,6 +201,9 @@ impl BaseObjInst {
} }
pub(crate) fn not_implemented_bin(vm: &mut Vm, _state: FunctionState) -> FunctionResult { 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; 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()) 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::<FloatInst>() { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::<FloatInst>() {
vm.create_float(lhs_value as f64 $op float_inst.float_value()) vm.create_float(lhs_value as f64 $op float_inst.float_value())
} else { } else {
// TODO IntInst arithmetic operator - throw an exception when RHS is not Int, Float
// BLOCKED-ON: exceptions
todo!( todo!(
concat!("cannot use '", stringify!($op), "' operator with Int and {}"), concat!("cannot use '", stringify!($op), "' operator with Int and {}"),
rhs.borrow().type_name() 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::<FloatInst>() { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::<FloatInst>() {
vm.create_bool((lhs_value as f64) $op float_inst.float_value()) vm.create_bool((lhs_value as f64) $op float_inst.float_value())
} else { } else {
// TODO IntInst logical operator - throw an exception when RHS is not Int, Float
// BLOCKED-ON: exceptions
todo!( todo!(
concat!("cannot use '", stringify!($op), "' operator with Int and {}"), concat!("cannot use '", stringify!($op), "' operator with Int and {}"),
rhs.borrow().type_name() rhs.borrow().type_name()
@@ -328,8 +338,12 @@ impl IntInst {
} else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::<FloatInst>() { } else if let Some(float_inst) = rhs.borrow().as_any().downcast_ref::<FloatInst>() {
vm.create_float(lhs_value as f64 * float_inst.float_value()) vm.create_float(lhs_value as f64 * float_inst.float_value())
} else if let Some(str_inst) = rhs.borrow().as_any().downcast_ref::<StrInst>() { } else if let Some(str_inst) = rhs.borrow().as_any().downcast_ref::<StrInst>() {
// 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)) vm.create_str(str_inst.str_value().repeat(lhs_value as usize))
} else { } else {
// TODO IntInst::mul - throw an exception when RHS is not Int, Float, Str
// BLOCKED-ON: exceptions
todo!( todo!(
"cannot use '*' operator with Int and {}", "cannot use '*' operator with Int and {}",
rhs.borrow().type_name() rhs.borrow().type_name()