Skip to content

Commit c5d1a85

Browse files
authored
More use of JS string template literals. NFC (#19971)
Also, just `dbg` over `out` where appropriate.
1 parent fa099c1 commit c5d1a85

File tree

52 files changed

+138
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+138
-134
lines changed

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ mergeInto(LibraryManager.library, {
283283
var replacement = growMemory(newSize);
284284
#if ASSERTIONS == 2
285285
var t1 = _emscripten_get_now();
286-
out(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`);
286+
dbg(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`);
287287
#endif
288288
if (replacement) {
289289
#if ASSERTIONS && WASM2JS

src/library_autodebug.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,102 +11,102 @@
1111

1212
mergeInto(LibraryManager.library, {
1313
$log_execution: function(loc) {
14-
out('log_execution ' + loc);
14+
dbg('log_execution ' + loc);
1515
},
1616
$get_i32: function(loc, index, value) {
17-
out('get_i32 ' + [loc, index, value]);
17+
dbg('get_i32 ' + [loc, index, value]);
1818
return value;
1919
},
2020
$get_i64__deps: ['setTempRet0'],
2121
$get_i64: function(loc, index, low, high) {
22-
out('get_i64 ' + [loc, index, low, high]);
22+
dbg('get_i64 ' + [loc, index, low, high]);
2323
setTempRet0(high);
2424
return low;
2525
},
2626
$get_f32: function(loc, index, value) {
27-
out('get_f32 ' + [loc, index, value]);
27+
dbg('get_f32 ' + [loc, index, value]);
2828
return value;
2929
},
3030
$get_f64: function(loc, index, value) {
31-
out('get_f64 ' + [loc, index, value]);
31+
dbg('get_f64 ' + [loc, index, value]);
3232
return value;
3333
},
3434
$get_anyref: function(loc, index, value) {
35-
out('get_anyref ' + [loc, index, value]);
35+
dbg('get_anyref ' + [loc, index, value]);
3636
return value;
3737
},
3838
$get_exnref: function(loc, index, value) {
39-
out('get_exnref ' + [loc, index, value]);
39+
dbg('get_exnref ' + [loc, index, value]);
4040
return value;
4141
},
4242
$set_i32: function(loc, index, value) {
43-
out('set_i32 ' + [loc, index, value]);
43+
dbg('set_i32 ' + [loc, index, value]);
4444
return value;
4545
},
4646
$set_i64__deps: ['setTempRet0'],
4747
$set_i64: function(loc, index, low, high) {
48-
out('set_i64 ' + [loc, index, low, high]);
48+
dbg('set_i64 ' + [loc, index, low, high]);
4949
setTempRet0(high);
5050
return low;
5151
},
5252
$set_f32: function(loc, index, value) {
53-
out('set_f32 ' + [loc, index, value]);
53+
dbg('set_f32 ' + [loc, index, value]);
5454
return value;
5555
},
5656
$set_f64: function(loc, index, value) {
57-
out('set_f64 ' + [loc, index, value]);
57+
dbg('set_f64 ' + [loc, index, value]);
5858
return value;
5959
},
6060
$set_anyref: function(loc, index, value) {
61-
out('set_anyref ' + [loc, index, value]);
61+
dbg('set_anyref ' + [loc, index, value]);
6262
return value;
6363
},
6464
$set_exnref: function(loc, index, value) {
65-
out('set_exnref ' + [loc, index, value]);
65+
dbg('set_exnref ' + [loc, index, value]);
6666
return value;
6767
},
6868
$load_ptr: function(loc, bytes, offset, ptr) {
69-
out('load_ptr ' + [loc, bytes, offset, ptr]);
69+
dbg('load_ptr ' + [loc, bytes, offset, ptr]);
7070
return ptr;
7171
},
7272
$load_val_i32: function(loc, value) {
73-
out('load_val_i32 ' + [loc, value]);
73+
dbg('load_val_i32 ' + [loc, value]);
7474
return value;
7575
},
7676
$load_val_i64__deps: ['setTempRet0'],
7777
$load_val_i64: function(loc, low, high) {
78-
out('load_val_i64 ' + [loc, low, high]);
78+
dbg('load_val_i64 ' + [loc, low, high]);
7979
setTempRet0(high);
8080
return low;
8181
},
8282
$load_val_f32: function(loc, value) {
83-
out('load_val_f32 ' + [loc, value]);
83+
dbg('load_val_f32 ' + [loc, value]);
8484
return value;
8585
},
8686
$load_val_f64: function(loc, value) {
87-
out('load_val_f64 ' + [loc, value]);
87+
dbg('load_val_f64 ' + [loc, value]);
8888
return value;
8989
},
9090
$store_ptr: function(loc, bytes, offset, ptr) {
91-
out('store_ptr ' + [loc, bytes, offset, ptr]);
91+
dbg('store_ptr ' + [loc, bytes, offset, ptr]);
9292
return ptr;
9393
},
9494
$store_val_i32: function(loc, value) {
95-
out('store_val_i32 ' + [loc, value]);
95+
dbg('store_val_i32 ' + [loc, value]);
9696
return value;
9797
},
9898
$store_val_i64__deps: ['setTempRet0'],
9999
$store_val_i64: function(loc, low, high) {
100-
out('store_val_i64 ' + [loc, low, high]);
100+
dbg('store_val_i64 ' + [loc, low, high]);
101101
setTempRet0(high);
102102
return low;
103103
},
104104
$store_val_f32: function(loc, value) {
105-
out('store_val_f32 ' + [loc, value]);
105+
dbg('store_val_f32 ' + [loc, value]);
106106
return value;
107107
},
108108
$store_val_f64: function(loc, value) {
109-
out('store_val_f64 ' + [loc, value]);
109+
dbg('store_val_f64 ' + [loc, value]);
110110
return value;
111111
},
112112
});

src/library_browser.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ var LibraryBrowser = {
132132
#endif
133133
var img = new Image();
134134
img.onload = () => {
135-
assert(img.complete, 'Image ' + name + ' could not be decoded');
135+
assert(img.complete, `Image ${name} could not be decoded`);
136136
var canvas = /** @type {!HTMLCanvasElement} */ (document.createElement('canvas'));
137137
canvas.width = img.width;
138138
canvas.height = img.height;
@@ -143,7 +143,7 @@ var LibraryBrowser = {
143143
if (onload) onload(byteArray);
144144
};
145145
img.onerror = (event) => {
146-
out('Image ' + url + ' could not be decoded');
146+
err(`Image ${url} could not be decoded`);
147147
if (onerror) onerror();
148148
};
149149
img.src = url;
@@ -177,7 +177,7 @@ var LibraryBrowser = {
177177
audio.addEventListener('canplaythrough', () => finish(audio), false); // use addEventListener due to chromium bug 124926
178178
audio.onerror = function audio_onerror(event) {
179179
if (done) return;
180-
err('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
180+
err(`warning: browser could not fully decode audio ${name}, trying slower base64 approach`);
181181
function encode64(data) {
182182
var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
183183
var PAD = '=';
@@ -769,7 +769,7 @@ var LibraryBrowser = {
769769

770770
#if PTHREADS
771771
if (ENVIRONMENT_IS_PTHREAD) {
772-
err('emscripten_async_load_script("' + url + '") failed, emscripten_async_load_script is currently not available in pthreads!');
772+
err(`emscripten_async_load_script("${url}") failed, emscripten_async_load_script is currently not available in pthreads!`);
773773
return onerror ? onerror() : undefined;
774774
}
775775
#endif
@@ -953,7 +953,9 @@ var LibraryBrowser = {
953953
Browser.mainLoop.remainingBlockers = (8*remaining + next)/9;
954954
}
955955
}
956-
out('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); //, left: ' + Browser.mainLoop.remainingBlockers);
956+
#if RUNTIME_DEBUG
957+
dbg(`main loop blocker "${blocker.name}" took '${Date.now() - start} ms`); //, left: ' + Browser.mainLoop.remainingBlockers);
958+
#endif
957959
Browser.mainLoop.updateStatus();
958960

959961
// catches pause/resume main loop from blocker execution

src/library_dylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ var LibraryDylink = {
538538
var curr = wasmImports[sym], next = exports[sym];
539539
// don't warn on functions - might be odr, linkonce_odr, etc.
540540
if (!(typeof curr == 'function' && typeof next == 'function')) {
541-
err("warning: symbol '" + sym + "' from '" + libName + "' already exists (duplicate symbol? or weak linking, which isn't supported yet?)"); // + [curr, ' vs ', next]);
541+
err(`warning: symbol '${sym}' from '${libName}' already exists (duplicate symbol? or weak linking, which isn't supported yet?)`); // + [curr, ' vs ', next]);
542542
}
543543
}
544544
#endif

src/library_egl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ var LibraryEGL = {
344344
if (glesContextVersion == 3) {
345345
err('When initializing GLES3/WebGL2 via EGL, one must build with -sMAX_WEBGL_VERSION=2!');
346346
} else {
347-
err('When initializing GLES2/WebGL1 via EGL, one must pass EGL_CONTEXT_CLIENT_VERSION = 2 to GL context attributes! GLES version ' + glesContextVersion + ' is not supported!');
347+
err(`When initializing GLES2/WebGL1 via EGL, one must pass EGL_CONTEXT_CLIENT_VERSION = 2 to GL context attributes! GLES version ${glesContextVersion} is not supported!`);
348348
}
349349
#endif
350350
EGL.setErrorCode(0x3005 /* EGL_BAD_CONFIG */);

src/library_glemu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ var LibraryGLEmulation = {
791791
default:
792792
GL.recordError(0x500/*GL_INVALID_ENUM*/);
793793
#if GL_ASSERTIONS
794-
err('GL_INVALID_ENUM in glGetPointerv: Unsupported name ' + name + '!');
794+
err(`GL_INVALID_ENUM in glGetPointerv: Unsupported name ${name}!`);
795795
#endif
796796
return;
797797
}

src/library_glfw.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ var LibraryGLFW = {
866866
break;
867867
}
868868
case 0x00034002: { // GLFW_CURSOR_HIDDEN
869-
out("glfwSetInputMode called with GLFW_CURSOR_HIDDEN value not implemented.");
869+
err('glfwSetInputMode called with GLFW_CURSOR_HIDDEN value not implemented');
870870
break;
871871
}
872872
case 0x00034003: { // GLFW_CURSOR_DISABLED
@@ -876,30 +876,30 @@ var LibraryGLFW = {
876876
break;
877877
}
878878
default: {
879-
out("glfwSetInputMode called with unknown value parameter value: " + value + ".");
879+
err(`glfwSetInputMode called with unknown value parameter value: ${value}`);
880880
break;
881881
}
882882
}
883883
break;
884884
}
885885
case 0x00033002: { // GLFW_STICKY_KEYS
886-
out("glfwSetInputMode called with GLFW_STICKY_KEYS mode not implemented.");
886+
err('glfwSetInputMode called with GLFW_STICKY_KEYS mode not implemented');
887887
break;
888888
}
889889
case 0x00033003: { // GLFW_STICKY_MOUSE_BUTTONS
890-
out("glfwSetInputMode called with GLFW_STICKY_MOUSE_BUTTONS mode not implemented.");
890+
err('glfwSetInputMode called with GLFW_STICKY_MOUSE_BUTTONS mode not implemented');
891891
break;
892892
}
893893
case 0x00033004: { // GLFW_LOCK_KEY_MODS
894-
out("glfwSetInputMode called with GLFW_LOCK_KEY_MODS mode not implemented.");
894+
err('glfwSetInputMode called with GLFW_LOCK_KEY_MODS mode not implemented');
895895
break;
896896
}
897897
case 0x000330005: { // GLFW_RAW_MOUSE_MOTION
898-
out("glfwSetInputMode called with GLFW_RAW_MOUSE_MOTION mode not implemented.");
898+
err('glfwSetInputMode called with GLFW_RAW_MOUSE_MOTION mode not implemented');
899899
break;
900900
}
901901
default: {
902-
out("glfwSetInputMode called with unknown mode parameter value: " + mode + ".");
902+
err(`glfwSetInputMode called with unknown mode parameter value: ${mode}`);
903903
break;
904904
}
905905
}

0 commit comments

Comments
 (0)