From df4c6cfcfaf102a2808d2018f9427585cb9e0921 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Fri, 18 Apr 2025 01:40:53 -0500 Subject: [PATCH] Still figuring things out --- src/instructions/numeric.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/instructions/numeric.rs b/src/instructions/numeric.rs index 100431b..913f864 100644 --- a/src/instructions/numeric.rs +++ b/src/instructions/numeric.rs @@ -12,17 +12,15 @@ use std::ops::{Add, Div, Mul, Sub}; use super::utils::{CastingTrait, NumericTrait}; -/// Adds two addable values together. +/// Adds two values together. fn _add(a: T, b: T) -> Option where T: Add + Copy, { Some(b + a) } -make_instruction_new!(_add, int, int, int, int); -make_instruction_new!(_add, float, float, float, float); -/// Subtracts two subtractable values from each other. +/// Subtracts two values from each other. fn _sub(vals: Vec) -> Option where T: Sub + Copy, @@ -32,7 +30,7 @@ where make_instruction!(int, int, _sub, i128, 2); make_instruction!(float, float, _sub, Decimal, 2); -/// Multiplies two multipliable values together. +/// Multiplies two values with each other. fn _mult(vals: Vec) -> Option where T: Mul + Copy, @@ -303,6 +301,17 @@ where make_instruction!(int, int, _square, i128, 1); make_instruction!(float, float, _square, Decimal, 1); +macro_rules! make_instructions { + ($stack:ident) => { + paste::item! { + make_instruction_new!(_add, $stack, $stack, $stack, $stack); + } + }; +} + +make_instructions!(int); +make_instructions!(float); + #[cfg(test)] mod tests { use super::*;