mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-15 00:18:06 -05:00
Make NativeFunction use exceptions (panics not converted though)
This commit is contained in:
@@ -91,7 +91,7 @@ impl StackFrameTrait for ArrayMappingFrame {
|
||||
Val::Number(array_i as f64),
|
||||
Val::Array(array_data.clone()),
|
||||
],
|
||||
),
|
||||
)?,
|
||||
) {
|
||||
None => Ok(FrameStepOk::Continue),
|
||||
Some(val) => Ok(FrameStepOk::Pop(CallResult {
|
||||
|
||||
@@ -77,7 +77,7 @@ impl StackFrameTrait for ReduceFrame {
|
||||
Val::Number(array_i as f64),
|
||||
Val::Array(array_data.clone()),
|
||||
],
|
||||
));
|
||||
)?);
|
||||
|
||||
return Ok(FrameStepOk::Continue);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ impl StackFrameTrait for ReduceRightFrame {
|
||||
Val::Number(array_i as f64),
|
||||
Val::Array(array_data.clone()),
|
||||
],
|
||||
));
|
||||
)?);
|
||||
|
||||
return Ok(FrameStepOk::Continue);
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ impl StackFrameTrait for SortFrame {
|
||||
std::panic!("Not implemented: exception: comparator is not a function");
|
||||
}
|
||||
LoadFunctionResult::NativeFunction(native_fn) => {
|
||||
let res = native_fn(&mut Val::Undefined, vec![left, right]).to_number();
|
||||
let res = native_fn(&mut Val::Undefined, vec![left, right])?.to_number();
|
||||
|
||||
let should_swap = match res.is_nan() {
|
||||
true => false,
|
||||
|
||||
Reference in New Issue
Block a user