| 15 | } |
| 16 | |
| 17 | static tsn_value doLoadModule(tsn_vm* ctx, |
| 18 | tsn_value_const this_val, |
| 19 | tsn_stackframe* /*stackframe*/, |
| 20 | int argc, |
| 21 | tsn_value_const* argv, |
| 22 | tsn_closure* closure) { |
| 23 | auto functionName = closure->module->atoms[0]; |
| 24 | auto helloFn = tsn_new_function(ctx, closure->module, functionName, &sayHello, 0); |
| 25 | if (tsn_is_exception(ctx, helloFn)) { |
| 26 | return helloFn; |
| 27 | } |
| 28 | |
| 29 | auto exports = tsn_get_func_arg(ctx, argc, argv, 2); |
| 30 | auto ret = tsn_set_property(ctx, &exports, functionName, &helloFn); |
| 31 | tsn_release(ctx, helloFn); |
| 32 | tsn_release(ctx, exports); |
| 33 | |
| 34 | if (ret < 0) { |
| 35 | return tsn_exception(ctx); |
| 36 | } else { |
| 37 | return tsn_undefined(ctx); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | static tsn_value moduleInitFn(tsn_vm* ctx) { |
| 42 | auto* tsnModule = tsn_new_module(ctx, 1, 0, 1); |
nothing calls this directly
no test coverage detected