MCPcopy Create free account
hub / github.com/Snapchat/Valdi / doLoadModule

Function doLoadModule

valdi/test/integration/TSNTestUtils.cpp:17–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17static 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
41static tsn_value moduleInitFn(tsn_vm* ctx) {
42 auto* tsnModule = tsn_new_module(ctx, 1, 0, 1);

Callers

nothing calls this directly

Calls 7

tsn_new_functionFunction · 0.85
tsn_is_exceptionFunction · 0.85
tsn_get_func_argFunction · 0.85
tsn_set_propertyFunction · 0.85
tsn_releaseFunction · 0.85
tsn_exceptionFunction · 0.85
tsn_undefinedFunction · 0.85

Tested by

no test coverage detected