Skip to content

Commit f202448

Browse files
Revert "Allow inline members in JS classes. NFC (emscripten-core#22808)"
This reverts commit eea2a44.
1 parent 010d061 commit f202448

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

src/library.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,8 +2282,12 @@ addToLibrary({
22822282
},
22832283

22842284
$HandleAllocator: class {
2285-
allocated = [undefined];
2286-
freelist = [];
2285+
constructor() {
2286+
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
2287+
// Use inline field declarations.
2288+
this.allocated = [undefined];
2289+
this.freelist = [];
2290+
}
22872291
get(id) {
22882292
#if ASSERTIONS
22892293
assert(this.allocated[id] !== undefined, `invalid handle: ${id}`);

src/library_fs.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ FS.staticInit();
7373
#else
7474
ErrnoError: class {
7575
#endif
76-
name = 'ErrnoError';
7776
// We set the `name` property to be able to identify `FS.ErrnoError`
7877
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
7978
// - when using PROXYFS, an error can come from an underlying FS
@@ -84,6 +83,9 @@ FS.staticInit();
8483
#if ASSERTIONS
8584
super(runtimeInitialized ? strError(errno) : '');
8685
#endif
86+
// TODO(sbc): Use the inline member declaration syntax once we
87+
// support it in acorn and closure.
88+
this.name = 'ErrnoError';
8789
this.errno = errno;
8890
#if ASSERTIONS
8991
for (var key in ERRNO_CODES) {
@@ -97,11 +99,16 @@ FS.staticInit();
9799
},
98100

99101
FSStream: class {
100-
shared = {};
102+
constructor() {
103+
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
104+
// Use inline field declarations.
105+
this.shared = {};
101106
#if USE_CLOSURE_COMPILER
102-
// Closure compiler requires us to declare all properties ahead of time
103-
node = null;
107+
// Closure compiler requires us to declare all properties in the
108+
// constructor.
109+
this.node = null;
104110
#endif
111+
}
105112
get object() {
106113
return this.node;
107114
}
@@ -131,22 +138,22 @@ FS.staticInit();
131138
}
132139
},
133140
FSNode: class {
134-
node_ops = {};
135-
stream_ops = {};
136-
readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
137-
writeMode = {{{ cDefs.S_IWUGO }}};
138-
mounted = null;
139141
constructor(parent, name, mode, rdev) {
140142
if (!parent) {
141143
parent = this; // root node sets parent to itself
142144
}
143145
this.parent = parent;
144146
this.mount = parent.mount;
147+
this.mounted = null;
145148
this.id = FS.nextInode++;
146149
this.name = name;
147150
this.mode = mode;
151+
this.node_ops = {};
152+
this.stream_ops = {};
148153
this.rdev = rdev;
149154
this.atime = this.mtime = this.ctime = Date.now();
155+
this.readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
156+
this.writeMode = {{{ cDefs.S_IWUGO }}};
150157
}
151158
get read() {
152159
return (this.mode & this.readMode) === this.readMode;
@@ -1674,14 +1681,17 @@ FS.staticInit();
16741681
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
16751682
// Actual getting is abstracted away for eventual reuse.
16761683
class LazyUint8Array {
1677-
lengthKnown = false;
1678-
chunks = []; // Loaded chunks. Index is the chunk number
1684+
constructor() {
1685+
this.lengthKnown = false;
1686+
this.chunks = []; // Loaded chunks. Index is the chunk number
16791687
#if USE_CLOSURE_COMPILER
1680-
// Closure compiler requires us to declare all properties ahead of time.
1681-
getter = undefined;
1682-
_length = 0;
1683-
_chunkSize = 0;
1688+
// Closure compiler requires us to declare all properties in the
1689+
// constructor.
1690+
this.getter = undefined;
1691+
this._length = 0;
1692+
this._chunkSize = 0;
16841693
#endif
1694+
}
16851695
get(idx) {
16861696
if (idx > this.length-1 || idx < 0) {
16871697
return undefined;

src/library_wasi.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
var WasiLibrary = {
88
#if !MINIMAL_RUNTIME
9-
$ExitStatus: class {
10-
name = 'ExitStatus';
11-
constructor(status) {
12-
this.message = `Program terminated with exit(${status})`;
13-
this.status = status;
14-
}
9+
$ExitStatus__docs: '/** @constructor */',
10+
$ExitStatus: function(status) {
11+
this.name = 'ExitStatus';
12+
this.message = `Program terminated with exit(${status})`;
13+
this.status = status;
1514
},
1615
proc_exit__deps: ['$ExitStatus', '$keepRuntimeAlive'],
1716
#endif

tools/acorn-optimizer.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,8 @@ if (extraInfoStart > 0) {
20372037
// outputted code if --closureFriendly was requested.
20382038
const sourceComments = {};
20392039
const params = {
2040-
ecmaVersion: 'latest',
2040+
// Keep in sync with --language_in that we pass to closure in building.py
2041+
ecmaVersion: 2021,
20412042
sourceType: exportES6 ? 'module' : 'script',
20422043
allowAwaitOutsideFunction: true,
20432044
};

tools/building.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None):
598598
CLOSURE_EXTERNS += [path_from_root('src/closure-externs/dyncall-externs.js')]
599599

600600
args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS']
601-
args += ['--language_in', 'UNSTABLE']
601+
# Keep in sync with ecmaVersion in tools/acorn-optimizer.mjs
602+
args += ['--language_in', 'ECMASCRIPT_2021']
602603
# We do transpilation using babel
603604
args += ['--language_out', 'NO_TRANSPILE']
604605
# Tell closure never to inject the 'use strict' directive.

0 commit comments

Comments
 (0)