Skip to content

Commit 9b67335

Browse files
authored
Rename internal _scriptDir to _scriptName. NFC (emscripten-core#21736)
This always seems to refer to full filename/url. Perhaps in the past it actually did hold the directory name?
1 parent 6185c30 commit 9b67335

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Due to the way MODULARIZE works, Closure is run on generated code that does not define _scriptDir,
2-
// but only after MODULARIZE has finished, _scriptDir is injected to the generated code.
1+
// Due to the way MODULARIZE works, Closure is run on generated code that does not define _scriptName,
2+
// but only after MODULARIZE has finished, _scriptName is injected to the generated code.
33
// Therefore it cannot be minified.
44
/**
55
* @suppress {duplicate, undefinedVars}
66
*/
7-
var _scriptDir;
7+
var _scriptName;

src/library_pthread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ var LibraryPThread = {
380380
// independently load up the same main application file.
381381
'urlOrBlob': Module['mainScriptUrlOrBlob']
382382
#if !EXPORT_ES6
383-
|| _scriptDir
383+
|| _scriptName
384384
#endif
385385
,
386386
#if WASM2JS

src/library_wasm_worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ if (ENVIRONMENT_IS_WASM_WORKER) {
174174
'mem': wasmMemory,
175175
#else
176176
'wasm': wasmModule,
177-
'js': Module['mainScriptUrlOrBlob'] || _scriptDir,
177+
'js': Module['mainScriptUrlOrBlob'] || _scriptName,
178178
'wasmMemory': wasmMemory,
179179
#endif
180180
'sb': stackLowestAddress, // sb = stack bottom (lowest stack address, SP points at this when stack is full)

src/library_webaudio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ let LibraryWebAudio = {
202202
#if MINIMAL_RUNTIME
203203
Module['js']
204204
#else
205-
Module['mainScriptUrlOrBlob'] || _scriptDir
205+
Module['mainScriptUrlOrBlob'] || _scriptName
206206
#endif
207207
);
208208
}).then(() => {

src/shell.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ var quit_ = (status, toThrow) => {
144144
};
145145

146146
#if SHARED_MEMORY && !MODULARIZE
147-
// In MODULARIZE mode _scriptDir needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
147+
// In MODULARIZE mode _scriptName needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
148148
// before the page load. In non-MODULARIZE modes generate it here.
149-
var _scriptDir = (typeof document != 'undefined') ? document.currentScript?.src : undefined;
149+
var _scriptName = (typeof document != 'undefined') ? document.currentScript?.src : undefined;
150150

151151
if (ENVIRONMENT_IS_WORKER) {
152-
_scriptDir = self.location.href;
152+
_scriptName = self.location.href;
153153
}
154154
#if ENVIRONMENT_MAY_BE_NODE
155155
else if (ENVIRONMENT_IS_NODE) {
156-
_scriptDir = __filename;
156+
_scriptName = __filename;
157157
}
158158
#endif // ENVIRONMENT_MAY_BE_NODE
159159
#endif // SHARED_MEMORY && !MODULARIZE
@@ -371,8 +371,8 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
371371
#if MODULARIZE
372372
// When MODULARIZE, this JS may be executed later, after document.currentScript
373373
// is gone, so we saved it, and we use it here instead of any other info.
374-
if (_scriptDir) {
375-
scriptDirectory = _scriptDir;
374+
if (_scriptName) {
375+
scriptDirectory = _scriptName;
376376
}
377377
#endif
378378
// blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.

src/shell_minimal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function',
153153
#if PTHREADS
154154

155155
#if !MODULARIZE
156-
// In MODULARIZE mode _scriptDir needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
156+
// In MODULARIZE mode _scriptName needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
157157
// before the page load. In non-MODULARIZE modes generate it here.
158-
var _scriptDir = (typeof document != 'undefined') ? document.currentScript?.src : undefined;
158+
var _scriptName = (typeof document != 'undefined') ? document.currentScript?.src : undefined;
159159
#endif
160160

161161
if (ENVIRONMENT_IS_WORKER) {
162-
_scriptDir = self.location.href;
162+
_scriptName = self.location.href;
163163
}
164164
#if ENVIRONMENT_MAY_BE_NODE
165165
else if (ENVIRONMENT_IS_NODE) {
166-
_scriptDir = __filename;
166+
_scriptName = __filename;
167167
}
168168
#endif
169169

tools/link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,10 +2372,10 @@ def modularize():
23722372
else:
23732373
script_url = "typeof document != 'undefined' ? document.currentScript?.src : undefined"
23742374
if shared.target_environment_may_be('node'):
2375-
script_url_node = "if (typeof __filename != 'undefined') _scriptDir ||= __filename;"
2375+
script_url_node = "if (typeof __filename != 'undefined') _scriptName ||= __filename;"
23762376
src = '''%(node_imports)s
23772377
var %(EXPORT_NAME)s = (() => {
2378-
var _scriptDir = %(script_url)s;
2378+
var _scriptName = %(script_url)s;
23792379
%(script_url_node)s
23802380
return (%(src)s);
23812381
})();

0 commit comments

Comments
 (0)