Skip to content

Commit eea2a44

Browse files
authored
Allow inline members in JS classes. NFC (#22808)
Fixes: #21414
1 parent 1b0516e commit eea2a44

File tree

66 files changed

+86
-101
lines changed

Some content is hidden

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

66 files changed

+86
-101
lines changed

src/library.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,12 +2362,8 @@ addToLibrary({
23622362
},
23632363

23642364
$HandleAllocator: class {
2365-
constructor() {
2366-
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
2367-
// Use inline field declarations.
2368-
this.allocated = [undefined];
2369-
this.freelist = [];
2370-
}
2365+
allocated = [undefined];
2366+
freelist = [];
23712367
get(id) {
23722368
#if ASSERTIONS
23732369
assert(this.allocated[id] !== undefined, `invalid handle: ${id}`);

src/library_fs.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ FS.staticInit();
7474
#else
7575
ErrnoError: class {
7676
#endif
77+
name = 'ErrnoError';
7778
// We set the `name` property to be able to identify `FS.ErrnoError`
7879
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
7980
// - when using PROXYFS, an error can come from an underlying FS
@@ -84,9 +85,6 @@ FS.staticInit();
8485
#if ASSERTIONS
8586
super(runtimeInitialized ? strError(errno) : '');
8687
#endif
87-
// TODO(sbc): Use the inline member declaration syntax once we
88-
// support it in acorn and closure.
89-
this.name = 'ErrnoError';
9088
this.errno = errno;
9189
#if ASSERTIONS
9290
for (var key in ERRNO_CODES) {
@@ -100,16 +98,11 @@ FS.staticInit();
10098
},
10199

102100
FSStream: class {
103-
constructor() {
104-
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
105-
// Use inline field declarations.
106-
this.shared = {};
101+
shared = {};
107102
#if USE_CLOSURE_COMPILER
108-
// Closure compiler requires us to declare all properties in the
109-
// constructor.
110-
this.node = null;
103+
// Closure compiler requires us to declare all properties ahead of time
104+
node = null;
111105
#endif
112-
}
113106
get object() {
114107
return this.node;
115108
}
@@ -139,21 +132,21 @@ FS.staticInit();
139132
}
140133
},
141134
FSNode: class {
135+
node_ops = {};
136+
stream_ops = {};
137+
readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
138+
writeMode = {{{ cDefs.S_IWUGO }}};
139+
mounted = null;
142140
constructor(parent, name, mode, rdev) {
143141
if (!parent) {
144142
parent = this; // root node sets parent to itself
145143
}
146144
this.parent = parent;
147145
this.mount = parent.mount;
148-
this.mounted = null;
149146
this.id = FS.nextInode++;
150147
this.name = name;
151148
this.mode = mode;
152-
this.node_ops = {};
153-
this.stream_ops = {};
154149
this.rdev = rdev;
155-
this.readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
156-
this.writeMode = {{{ cDefs.S_IWUGO }}};
157150
}
158151
get read() {
159152
return (this.mode & this.readMode) === this.readMode;
@@ -1667,17 +1660,14 @@ FS.staticInit();
16671660
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
16681661
// Actual getting is abstracted away for eventual reuse.
16691662
class LazyUint8Array {
1670-
constructor() {
1671-
this.lengthKnown = false;
1672-
this.chunks = []; // Loaded chunks. Index is the chunk number
1663+
lengthKnown = false;
1664+
chunks = []; // Loaded chunks. Index is the chunk number
16731665
#if USE_CLOSURE_COMPILER
1674-
// Closure compiler requires us to declare all properties in the
1675-
// constructor.
1676-
this.getter = undefined;
1677-
this._length = 0;
1678-
this._chunkSize = 0;
1666+
// Closure compiler requires us to declare all properties ahead of time.
1667+
getter = undefined;
1668+
_length = 0;
1669+
_chunkSize = 0;
16791670
#endif
1680-
}
16811671
get(idx) {
16821672
if (idx > this.length-1 || idx < 0) {
16831673
return undefined;

src/library_wasi.js

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

77
var WasiLibrary = {
88
#if !MINIMAL_RUNTIME
9-
$ExitStatus__docs: '/** @constructor */',
10-
$ExitStatus: function(status) {
11-
this.name = 'ExitStatus';
12-
this.message = `Program terminated with exit(${status})`;
13-
this.status = status;
9+
$ExitStatus: class {
10+
name = 'ExitStatus';
11+
constructor(status) {
12+
this.message = `Program terminated with exit(${status})`;
13+
this.status = status;
14+
}
1415
},
1516
proc_exit__deps: ['$ExitStatus', '$keepRuntimeAlive'],
1617
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8475
1+
8472
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20806
1+
20767
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8456
1+
8453
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20774
1+
20735
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9500
1+
9499
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24650
1+
24611
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8436
1+
8431

0 commit comments

Comments
 (0)