Bug 1383157 - change pn_type to a ParseNodeKind; r?jimb
MozReview-Commit-ID: 3woMGwYs3wY
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -174,17 +174,17 @@ class ObjectBox;
* not a concrete syntax tree in all respects (for example, || and && are left
* associative, but (A && B && C) translates into the right-associated tree
* <A && <B && C>> so that code generation can emit a left-associative branch
* around <B && C> when A is false). Nodes are labeled by kind, with a
* secondary JSOp label when needed.
*
* The long comment after this enum block describes the kinds in detail.
*/
-enum ParseNodeKind
+enum ParseNodeKind : uint16_t
{
#define EMIT_ENUM(name) PNK_##name,
FOR_EACH_PARSE_NODE_KIND(EMIT_ENUM)
#undef EMIT_ENUM
PNK_LIMIT, /* domain size */
PNK_BINOP_FIRST = PNK_OR,
PNK_BINOP_LAST = PNK_POW,
PNK_ASSIGNMENT_START = PNK_ASSIGN,
@@ -445,17 +445,21 @@ enum ParseNodeArity
class LoopControlStatement;
class BreakStatement;
class ContinueStatement;
class ConditionalExpression;
class PropertyAccess;
class ParseNode
{
- uint16_t pn_type; /* PNK_* type */
+ ParseNodeKind pn_type; /* PNK_* type */
+ // pn_op and pn_arity are not declared as the correct enum types
+ // due to difficulties with MS bitfield layout rules and a GCC
+ // bug. See https://bugzilla.mozilla.org/show_bug.cgi?id=1383157#c4 for
+ // details.
uint8_t pn_op; /* see JSOp enum and jsopcode.tbl */
uint8_t pn_arity:4; /* see ParseNodeArity enum */
bool pn_parens:1; /* this expr was enclosed in parens */
bool pn_rhs_anon_fun:1; /* this expr is anonymous function or class that
* is a direct RHS of PNK_ASSIGN or PNK_COLON of
* property, that needs SetFunctionName. */
ParseNode(const ParseNode& other) = delete;
@@ -489,17 +493,17 @@ class ParseNode
}
JSOp getOp() const { return JSOp(pn_op); }
void setOp(JSOp op) { pn_op = op; }
bool isOp(JSOp op) const { return getOp() == op; }
ParseNodeKind getKind() const {
MOZ_ASSERT(pn_type < PNK_LIMIT);
- return ParseNodeKind(pn_type);
+ return pn_type;
}
void setKind(ParseNodeKind kind) {
MOZ_ASSERT(kind < PNK_LIMIT);
pn_type = kind;
}
bool isKind(ParseNodeKind kind) const { return getKind() == kind; }
ParseNodeArity getArity() const { return ParseNodeArity(pn_arity); }