Refactor wasm feature gates.

This commit is contained in:
Stephen Chung
2022-01-04 22:16:20 +08:00
parent d99953c101
commit 328f6910b6
21 changed files with 110 additions and 64 deletions

View File

@@ -25,7 +25,12 @@ const BUILTIN: &str = "data type was checked";
#[inline]
#[must_use]
fn is_numeric(type_id: TypeId) -> bool {
let result = type_id == TypeId::of::<u8>()
let result = false;
#[cfg(not(feature = "only_i64"))]
#[cfg(not(feature = "only_i32"))]
let result = result
|| type_id == TypeId::of::<u8>()
|| type_id == TypeId::of::<u16>()
|| type_id == TypeId::of::<u32>()
|| type_id == TypeId::of::<u64>()
@@ -34,7 +39,10 @@ fn is_numeric(type_id: TypeId) -> bool {
|| type_id == TypeId::of::<i32>()
|| type_id == TypeId::of::<i64>();
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(feature = "only_i32"))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_arch = "wasm64"))]
let result = result || type_id == TypeId::of::<u128>() || type_id == TypeId::of::<i128>();
#[cfg(not(feature = "no_float"))]

View File

@@ -1142,7 +1142,7 @@ impl Engine {
} else {
// Turn it into a method call only if the object is not shared and not a simple value
is_ref_mut = true;
let obj_ref = target.take_ref().expect("reference");
let obj_ref = target.take_ref().expect("ref");
args.push(obj_ref);
args.extend(arg_values.iter_mut());
}
@@ -1217,7 +1217,7 @@ impl Engine {
// Turn it into a method call only if the object is not shared and not a simple value
let (first, rest) = arg_values.split_first_mut().expect("not empty");
first_arg_value = Some(first);
let obj_ref = target.take_ref().expect("reference");
let obj_ref = target.take_ref().expect("ref");
args.push(obj_ref);
args.extend(rest.iter_mut());
}