summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/FullParseHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/FullParseHandler.h')
-rw-r--r--js/src/frontend/FullParseHandler.h68
1 files changed, 48 insertions, 20 deletions
diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h
index 0fd137796..2d7f57e1e 100644
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -10,6 +10,8 @@
#include "mozilla/Attributes.h"
#include "mozilla/PodOperations.h"
+#include <string.h>
+
#include "frontend/ParseNode.h"
#include "frontend/SharedContext.h"
@@ -181,6 +183,10 @@ class FullParseHandler
return new_<NullLiteral>(pos);
}
+ ParseNode* newRawUndefinedLiteral(const TokenPos& pos) {
+ return new_<RawUndefinedLiteral>(pos);
+ }
+
// The Boxer object here is any object that can allocate ObjectBoxes.
// Specifically, a Boxer has a .newObjectBox(T) method that accepts a
// Rooted<RegExpObject*> argument and returns an ObjectBox*.
@@ -296,10 +302,9 @@ class FullParseHandler
}
MOZ_MUST_USE bool addSpreadElement(ParseNode* literal, uint32_t begin, ParseNode* inner) {
- TokenPos pos(begin, inner->pn_pos.end);
- ParseNode* spread = new_<UnaryNode>(PNK_SPREAD, JSOP_NOP, pos, inner);
+ ParseNode* spread = newSpread(begin, inner);
if (!spread)
- return null();
+ return false;
literal->append(spread);
literal->pn_xflags |= PNX_ARRAYHOLESPREAD | PNX_NONCONST;
return true;
@@ -327,8 +332,10 @@ class FullParseHandler
return literal;
}
- ParseNode* newClass(ParseNode* name, ParseNode* heritage, ParseNode* methodBlock) {
- return new_<ClassNode>(name, heritage, methodBlock);
+ ParseNode* newClass(ParseNode* name, ParseNode* heritage, ParseNode* methodBlock,
+ const TokenPos& pos)
+ {
+ return new_<ClassNode>(name, heritage, methodBlock, pos);
}
ParseNode* newClassMethodList(uint32_t begin) {
return new_<ListNode>(PNK_CLASSMETHODLIST, TokenPos(begin, begin + 1));
@@ -388,6 +395,18 @@ class FullParseHandler
return true;
}
+ MOZ_MUST_USE bool addSpreadProperty(ParseNode* literal, uint32_t begin, ParseNode* inner) {
+ MOZ_ASSERT(literal->isKind(PNK_OBJECT));
+ MOZ_ASSERT(literal->isArity(PN_LIST));
+
+ setListFlag(literal, PNX_NONCONST);
+ ParseNode* spread = newSpread(begin, inner);
+ if (!spread)
+ return false;
+ literal->append(spread);
+ return true;
+ }
+
MOZ_MUST_USE bool addObjectMethodDefinition(ParseNode* literal, ParseNode* key, ParseNode* fn,
JSOp op)
{
@@ -670,9 +689,18 @@ class FullParseHandler
pn->setDirectRHSAnonFunction(true);
}
- ParseNode* newFunctionDefinition() {
- return new_<CodeNode>(PNK_FUNCTION, pos());
+ ParseNode* newFunctionStatement() {
+ return new_<CodeNode>(PNK_FUNCTION, JSOP_NOP, pos());
+ }
+
+ ParseNode* newFunctionExpression() {
+ return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA, pos());
}
+
+ ParseNode* newArrowFunction() {
+ return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA_ARROW, pos());
+ }
+
bool setComprehensionLambdaBody(ParseNode* pn, ParseNode* body) {
MOZ_ASSERT(body->isKind(PNK_STATEMENTLIST));
ParseNode* paramsBody = newList(PNK_PARAMSBODY, body);
@@ -699,7 +727,7 @@ class FullParseHandler
}
ParseNode* newModule() {
- return new_<CodeNode>(PNK_MODULE, pos());
+ return new_<CodeNode>(PNK_MODULE, JSOP_NOP, pos());
}
ParseNode* newLexicalScope(LexicalScope::Data* bindings, ParseNode* body) {
@@ -845,7 +873,7 @@ class FullParseHandler
MOZ_MUST_USE ParseNode* setLikelyIIFE(ParseNode* pn) {
return parenthesize(pn);
}
- void setPrologue(ParseNode* pn) {
+ void setInDirectivePrologue(ParseNode* pn) {
pn->pn_prologue = true;
}
@@ -861,29 +889,29 @@ class FullParseHandler
return node->isKind(PNK_NAME);
}
- bool nameIsEvalAnyParentheses(ParseNode* node, ExclusiveContext* cx) {
- MOZ_ASSERT(isNameAnyParentheses(node),
- "must only call this function on known names");
+ bool isArgumentsAnyParentheses(ParseNode* node, ExclusiveContext* cx) {
+ return node->isKind(PNK_NAME) && node->pn_atom == cx->names().arguments;
+ }
- return node->pn_atom == cx->names().eval;
+ bool isEvalAnyParentheses(ParseNode* node, ExclusiveContext* cx) {
+ return node->isKind(PNK_NAME) && node->pn_atom == cx->names().eval;
}
const char* nameIsArgumentsEvalAnyParentheses(ParseNode* node, ExclusiveContext* cx) {
MOZ_ASSERT(isNameAnyParentheses(node),
"must only call this function on known names");
- if (nameIsEvalAnyParentheses(node, cx))
+ if (isEvalAnyParentheses(node, cx))
return js_eval_str;
- if (node->pn_atom == cx->names().arguments)
+ if (isArgumentsAnyParentheses(node, cx))
return js_arguments_str;
return nullptr;
}
- bool nameIsUnparenthesizedAsync(ParseNode* node, ExclusiveContext* cx) {
- MOZ_ASSERT(isNameAnyParentheses(node),
- "must only call this function on known names");
-
- return node->pn_atom == cx->names().async;
+ bool isAsyncKeyword(ParseNode* node, ExclusiveContext* cx) {
+ return node->isKind(PNK_NAME) &&
+ node->pn_pos.begin + strlen("async") == node->pn_pos.end &&
+ node->pn_atom == cx->names().async;
}
bool isCall(ParseNode* pn) {