mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 09:35:43 +00:00
Scripts: $.fileName names the file of the code that reads it
$.fileName gave the file being run, so a function defined in a file that #include inserted, in a file $.evalFile ran, or in an earlier run of a named engine reported the calling file instead of its own. - vectorcraft_js: HostItem::SiteGetter gives a getter the CallSite (source tag, line, column) of the code that reads it. - $.fileName maps that place through the run's source maps, or the maps a named engine kept, to the file the code is in. It is empty in code from a script given as source and in kept code whose map was dropped. Code that eval or Function compiled still gets the file being run. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
@@ -321,7 +321,8 @@ impl Files {
|
||||
std::env::var("JSINCLUDE").map(|v| v.split(';').map(str::trim).filter(|p| !p.is_empty()).map(PathBuf::from).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The file being run now, as `$.fileName` gives it (empty for a script given as text).
|
||||
/// The file being run now: the script, or the file `$.evalFile` is running (empty for a script
|
||||
/// given as text). `$.fileName` gives it to code that `eval` or `Function` compiled.
|
||||
pub(crate) fn file_name(&self) -> String {
|
||||
self.frames.last().map(|f| f.shown.to_string()).unwrap_or_default()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user