--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -231,24 +231,25 @@ public:
BinParseContext(ASTReader*, GlobalSharedContext*, Directives*);
};
bool
ASTReader::parse(char* start, char* stop, GlobalSharedContext* sc, UniquePtr<ParseNode>& out) {
SimpleTokenReader reader(this->cx);
reader.init(start, stop, nullptr);
+#if 0
Directives directives(options().strictOption);
GlobalSharedContext globalsc(this->cx, ScopeKind::Global,
directives, options().extraWarningsOption);
BinParseContext globalpc(this, &globalsc, /* newDirectives = */ nullptr);
if (!globalpc.init()) {
return false;
}
-
+#endif // 0
if (!this->parseProgram(&reader, out) || !reader.uninit()) {
return false;
}
return true;
}
@@ -2226,16 +2227,71 @@ ASTReader::parseDirectiveList(SimpleToke
return false;
}
}
return true;
}
bool
+ASTReader::parseSwitchCase(SimpleTokenReader* reader, UniquePtr<ParseNode>& out) {
+ if (out) {
+ return this->raiseError();
+ }
+
+ BinKind kind;
+ SimpleTokenReader::BinFields fields(this->cx);
+ SimpleTokenReader sub(this->cx);
+
+ if (!reader->taggedTuple(kind, fields, &sub)) {
+ return false;
+ }
+
+ if (kind != BinKind::switch_case) {
+ return this->raiseError();
+ }
+
+ UniquePtr<ParseNode> test; // Optional.
+ UniquePtr<ParseNode> statements; // Required.
+
+ for (auto field: fields) {
+ switch (field) {
+ case BinField::test:
+ if (!this->parseExpression(&sub, test)) {
+ return false;
+ }
+ break;
+ case BinField::consequent:
+ if (!this->parseStatementList(&sub, statements)) {
+ return false;
+ }
+ break;
+ default:
+ return this->raiseError();
+ }
+ }
+
+ if (!statements) {
+ return this->raiseError();
+ }
+ MOZ_ASSERT(statements->isKind(PNK_STATEMENTLIST));
+
+ UniquePtr<ParseNode> result;
+
+ result = UniquePtr<ParseNode>(new_<CaseClause>(test.get(), statements.get(), 0));
+ if (!result) {
+ return false;
+ }
+
+ Unused << test.release();
+ Unused << statements.release();
+}
+
+
+bool
ASTReader::readNumber(SimpleTokenReader* reader, Maybe<double>& out) {
if (out) {
return this->raiseError();
}
return reader->readMaybeF64(&out);
}