summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/Parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/Parser.h')
-rw-r--r--js/src/frontend/Parser.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index 6b5ade425..efb543efa 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -85,6 +85,31 @@ class ParseContext : public Nestable<ParseContext>
}
};
+ class ClassStatement : public Statement
+ {
+ FunctionBox* constructorBox_;
+
+ public:
+ explicit ClassStatement(ParseContext* pc)
+ : Statement(pc, StatementKind::Class),
+ constructorBox_(nullptr)
+ { }
+
+ void clearConstructorBoxForAbortedSyntaxParse(FunctionBox* funbox) {
+ MOZ_ASSERT(constructorBox_ == funbox);
+ constructorBox_ = nullptr;
+ }
+
+ void setConstructorBox(FunctionBox* funbox) {
+ MOZ_ASSERT(!constructorBox_);
+ constructorBox_ = funbox;
+ }
+
+ FunctionBox* constructorBox() const {
+ return constructorBox_;
+ }
+ };
+
// The intra-function scope stack.
//
// Tracks declared and used names within a scope.
@@ -432,6 +457,11 @@ class ParseContext : public Nestable<ParseContext>
return Statement::findNearest<T>(innermostStatement_, predicate);
}
+ template <typename T>
+ T* findInnermostStatement() {
+ return Statement::findNearest<T>(innermostStatement_);
+ }
+
AtomVector& positionalFormalParameterNames() {
return *positionalFormalParameterNames_;
}
@@ -532,6 +562,13 @@ ParseContext::Statement::is<ParseContext::LabelStatement>() const
return kind_ == StatementKind::Label;
}
+template <>
+inline bool
+ParseContext::Statement::is<ParseContext::ClassStatement>() const
+{
+ return kind_ == StatementKind::Class;
+}
+
template <typename T>
inline T&
ParseContext::Statement::as()