| 259 | } |
| 260 | |
| 261 | static tsn_value tsn_require_relative( |
| 262 | tsn_vm* ctx, tsn_value_const /*this_val*/, int argc, tsn_value_const* argv, int /*magic*/, tsn_value* func_data) { |
| 263 | if (argc < 1) { |
| 264 | return JS_ThrowReferenceError(ctx, "Missing module name argument"); |
| 265 | } |
| 266 | |
| 267 | auto parentModulePath = ValueRef(ctx, JS_GetPropertyStr(ctx, func_data[0], "path")); |
| 268 | TSN_CHECK_EXCEPTION(parentModulePath); |
| 269 | |
| 270 | auto parentModulePathAtom = JS_ValueToAtom(ctx, *parentModulePath); |
| 271 | if (parentModulePathAtom == 0) { |
| 272 | return tsn_exception(ctx); |
| 273 | } |
| 274 | |
| 275 | auto requestedModulePath = JS_ValueToAtom(ctx, argv[0]); |
| 276 | if (requestedModulePath == 0) { |
| 277 | JS_FreeAtom(ctx, parentModulePathAtom); |
| 278 | return tsn_exception(ctx); |
| 279 | } |
| 280 | |
| 281 | auto* normalizedName = JS_NormalizeModuleName( |
| 282 | ctx, JS_AtomToCString(ctx, parentModulePathAtom), JS_AtomToCString(ctx, requestedModulePath)); |
| 283 | JS_FreeAtom(ctx, requestedModulePath); |
| 284 | JS_FreeAtom(ctx, parentModulePathAtom); |
| 285 | |
| 286 | if (normalizedName == nullptr) { |
| 287 | return tsn_exception(ctx); |
| 288 | } |
| 289 | |
| 290 | auto output = tsn_require_from_string(ctx, normalizedName); |
| 291 | js_free(ctx, normalizedName); |
| 292 | return output; |
| 293 | } |
| 294 | |
| 295 | tsn_value tsn_get_property0(tsn_vm* ctx, const tsn_value_const* obj, tsn_atom prop) { |
| 296 | return JS_GetProperty(ctx, *obj, prop); |
nothing calls this directly
no test coverage detected