diff options
author | Martok <martok@martoks-place.de> | 2023-04-10 15:40:27 +0200 |
---|---|---|
committer | Martok <martok@martoks-place.de> | 2023-05-01 17:16:20 +0200 |
commit | 3ceff0d99425b471ce91bbe2cb38a97f699368dd (patch) | |
tree | a34a08aaa5d6b9a3d16baf88a2818f6c04b9df9b /js/src/builtin | |
parent | fc82386ef5ed5203270b99403303d50638fc95b1 (diff) | |
download | uxp-3ceff0d99425b471ce91bbe2cb38a97f699368dd.tar.gz |
Issue #2142 - Optimize .initializers scoping and emitter
* Refactor code for emitting the .initializers array into ClassEmitter
* Only emit .initializers scope when actually required
* Remove unfinished code to handle non-present class field initialisers
* Use predicate count_if and any_of of ListNode
* Remove unnecessary parameters for class field parsing
Based-on: m-c 1553744, 1555979, 1555037/1, 1535804/{1-5}
Diffstat (limited to 'js/src/builtin')
-rw-r--r-- | js/src/builtin/ReflectParse.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 2b885574da..6ca0c30e16 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -2766,24 +2766,22 @@ ASTSerializer::classField(ClassField* classField, MutableHandleValue dst) { RootedValue key(cx), val(cx); // Dig through the lambda and get to the actual expression - if (classField->initializer()) { - ParseNode* value = classField->initializer() - ->body() - ->head()->as<LexicalScopeNode>() - .scopeBody()->as<ListNode>() - .head()->as<UnaryNode>() - .kid()->as<BinaryNode>() - .right(); - // RawUndefinedExpr is the node we use for "there is no initializer". If one - // writes, literally, `x = undefined;`, it will not be a RawUndefinedExpr - // node, but rather a variable reference. - // Behavior for "there is no initializer" should be { ..., "init": null } - if (value->getKind() != PNK_RAW_UNDEFINED) { - if (!expression(value, &val)) - return false; - } else { - val.setNull(); - } + ParseNode* value = classField->initializer() + ->body() + ->head()->as<LexicalScopeNode>() + .scopeBody()->as<ListNode>() + .head()->as<UnaryNode>() + .kid()->as<BinaryNode>() + .right(); + // RawUndefinedExpr is the node we use for "there is no initializer". If one + // writes, literally, `x = undefined;`, it will not be a RawUndefinedExpr + // node, but rather a variable reference. + // Behavior for "there is no initializer" should be { ..., "init": null } + if (value->getKind() != PNK_RAW_UNDEFINED) { + if (!expression(value, &val)) + return false; + } else { + val.setNull(); } return propertyName(&classField->name(), &key) && builder.classField(key, val, &classField->pn_pos, dst); |