Skip to content

Commit 599b673

Browse files
[Wasm] Improve Decimal class.
- Remove superfluous methods. The once inherited from `Expr<T>` are already what we need. - *Delete* (with `require false`) certain operators and methods that are not supported by `Decimal`, e.g. `rotl` or `neg`.
1 parent 8176c1a commit 599b673

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

src/backend/WasmUtil.hpp

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,17 @@ struct Decimal : Expr<Base>
119119
Expr<To> to() { return val().template to<To>() / powi(To(10), To(scale_)); }
120120

121121
Decimal clone() const { return Decimal(expr_type::clone(), scale_); }
122-
bool can_be_null() const { return expr_type::can_be_null(); }
123-
Bool is_null() {
124-
if (can_be_null()) {
125-
return expr_type::is_null();
126-
} else {
127-
expr_type::discard();
128-
return Bool(false);
129-
}
130-
}
131-
Bool not_null() {
132-
if (can_be_null()) {
133-
return expr_type::not_null();
134-
} else {
135-
expr_type::discard();
136-
return Bool(true);
137-
}
138-
}
139122

140123

141124
/*------------------------------------------------------------------------------------------------------------------
142125
* Unary operations
143126
*----------------------------------------------------------------------------------------------------------------*/
144127

128+
/** Bitwise negation is not supported by `Decimal` type. */
129+
Decimal operator~()
130+
requires false
131+
{ M_unreachable("modulo division on decimals is not defined"); }
132+
145133

146134
/*------------------------------------------------------------------------------------------------------------------
147135
* Binary operations
@@ -210,6 +198,42 @@ struct Decimal : Expr<Base>
210198
requires false
211199
Decimal operator%(T&&) { M_unreachable("modulo division on decimals is not defined"); }
212200

201+
/** Bitwise and is not supported by `Decimal` type. */
202+
template<typename T>
203+
requires false
204+
Decimal operator bitand(T&&) { M_unreachable("bitwise and on decimals is not defined"); }
205+
206+
/** Bitwise or is not supported by `Decimal` type. */
207+
template<typename T>
208+
requires false
209+
Decimal operator bitor(T&&) { M_unreachable("bitwise or on decimals is not defined"); }
210+
211+
/** Bitwise xor (exclusive or) is not supported by `Decimal` type. */
212+
template<typename T>
213+
requires false
214+
Decimal operator xor(T&&) { M_unreachable("exclusive or on decimals is not defined"); }
215+
216+
/** Shift left is not supported by `Decimal` type. */
217+
template<typename T>
218+
requires false
219+
Decimal operator<<(T&&) { M_unreachable("shift left on decimals is not defined"); }
220+
221+
/** Shift right is not supported by `Decimal` type. */
222+
template<typename T>
223+
requires false
224+
Decimal operator>>(T&&) { M_unreachable("shift right on decimals is not defined"); }
225+
226+
/** Shift right is not supported by `Decimal` type. */
227+
template<typename T>
228+
requires false
229+
Decimal rotl(T&&) { M_unreachable("rotate left on decimals is not defined"); }
230+
231+
/** Shift right is not supported by `Decimal` type. */
232+
template<typename T>
233+
requires false
234+
Decimal rotr(T&&) { M_unreachable("rotate right on decimals is not defined"); }
235+
236+
213237
friend std::ostream & operator<<(std::ostream &out, const Decimal &d) {
214238
return out << "Decimal: " << static_cast<const expr_type&>(d) << ", scale = " << d.scale_;
215239
}

0 commit comments

Comments
 (0)