-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coprocessor: add mod(Int/Real/Decimal) RPN functions #4727
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
290900a
coprocessor: add mod(Int/Real/Decimal) RPN functions
lonng 7f5eb59
remove empty line
lonng 7aeed2b
address comment
lonng ea350c2
Merge branch 'master' into rpn-mod
lonng b113a9e
Merge branch 'master' into rpn-mod
lonng 312988c
Merge commit 'e4df79deec9519d4a6a44992c17eba5228380956' into pr/4727
breezewish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,15 @@ fn plus_mapper(lhs_is_unsigned: bool, rhs_is_unsigned: bool) -> Box<dyn RpnFunct | |
} | ||
} | ||
|
||
fn mod_mapper(lhs_is_unsigned: bool, rhs_is_unsigned: bool) -> Box<dyn RpnFunction> { | ||
match (lhs_is_unsigned, rhs_is_unsigned) { | ||
(false, false) => Box::new(RpnFnArithmetic::<IntIntMod>::new()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can discover some higher ordered generics to deal with these IntInt, IntUint, UintInt, UintUint later, to reduce code duplicates :) We will have many functions that is different in signed / unsigned integers. Would be too verbose if we need a standalone function for each of them. |
||
(false, true) => Box::new(RpnFnArithmetic::<IntUintMod>::new()), | ||
(true, false) => Box::new(RpnFnArithmetic::<UintIntMod>::new()), | ||
(true, true) => Box::new(RpnFnArithmetic::<UintUintMod>::new()), | ||
} | ||
} | ||
|
||
#[rustfmt::skip] | ||
fn map_pb_sig_to_rpn_func(value: ScalarFuncSig, children: &[Expr]) -> Result<Box<dyn RpnFunction>> { | ||
Ok(match value { | ||
|
@@ -135,6 +144,9 @@ fn map_pb_sig_to_rpn_func(value: ScalarFuncSig, children: &[Expr]) -> Result<Box | |
ScalarFuncSig::PlusInt => map_int_sig(value, children, plus_mapper)?, | ||
ScalarFuncSig::PlusReal => Box::new(RpnFnArithmetic::<RealPlus>::new()), | ||
ScalarFuncSig::PlusDecimal => Box::new(RpnFnArithmetic::<DecimalPlus>::new()), | ||
ScalarFuncSig::ModReal => Box::new(RpnFnArithmetic::<RealMod>::new()), | ||
ScalarFuncSig::ModDecimal => Box::new(RpnFnArithmetic::<DecimalMod>::new()), | ||
ScalarFuncSig::ModInt => map_int_sig(value, children, mod_mapper)?, | ||
_ => return Err(box_err!( | ||
"ScalarFunction {:?} is not supported in batch mode", | ||
value | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can write
Option<f64>
here and convert it below in the loop to make the test vec clearer. (I can do it later)