| 1645 | } |
| 1646 | |
| 1647 | tsn_value tsn_call(tsn_vm* ctx, tsn_value_const func_obj, tsn_value_const this_obj, int argc, tsn_value_const* argv) { |
| 1648 | tsn_value retval; |
| 1649 | |
| 1650 | auto* closure = tsn_get_closure_from_func(func_obj); |
| 1651 | if (closure != nullptr) { |
| 1652 | // Fast path for calls to TSN functions |
| 1653 | retval = call_closure_callable(ctx, func_obj, this_obj, argc, argv, closure); |
| 1654 | } else { |
| 1655 | // We must retain-release the arguments ourselves as QuickJS |
| 1656 | // might mutate the argv array in place, potentially setting up |
| 1657 | // different variables. It expects us to release the array after |
| 1658 | // a JS call is made. |
| 1659 | for (int i = 0; i < argc; i++) { |
| 1660 | tsn_retain(ctx, argv[i]); |
| 1661 | } |
| 1662 | |
| 1663 | retval = JS_CallInternal_tsn(ctx, func_obj, this_obj, JS_UNDEFINED, argc, argv, 0); |
| 1664 | |
| 1665 | for (int i = 0; i < argc; i++) { |
| 1666 | tsn_release(ctx, argv[i]); |
| 1667 | } |
| 1668 | } |
| 1669 | |
| 1670 | return retval; |
| 1671 | } |
| 1672 | |
| 1673 | tsn_value tsn_call_vargs(tsn_vm* ctx, tsn_value_const func_obj, tsn_value_const this_obj, tsn_value_const args) { |
| 1674 | uint32_t len; |
no test coverage detected