quickjs_jit_stdlib/llrt/llrt_utils/ctx.rs
1// Vendored from LLRT d9fd873e793c (libs/llrt_utils/src/ctx.rs); module paths and
2// feature names adapted by scripts/import-stdlib.py.
3// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4// SPDX-License-Identifier: Apache-2.0
5use rquickjs::{Ctx, Result};
6
7pub trait CtxExt {
8 fn get_script_or_module_name(&self) -> Result<String>;
9}
10
11impl CtxExt for Ctx<'_> {
12 fn get_script_or_module_name(&self) -> Result<String> {
13 if let Some(name) = self.script_or_module_name(0) {
14 name.to_string()
15 } else {
16 Ok(String::from("."))
17 }
18 }
19}