WIP: parseDirectiveList draft
authorDavid Teller <dteller@mozilla.com>
Sat, 05 Aug 2017 00:08:56 +0200
changeset 641382 0909a011cb51c8ab0ac976cf47970987625ecee7
parent 641381 4ccb7cb527a3bce949786b19751d94ebf0f2c1bf
child 641383 470dc71503ead093d80b2cc49b18f2bd40f6c9d2
push id72504
push userdteller@mozilla.com
push dateSun, 06 Aug 2017 22:28:40 +0000
milestone57.0a1
WIP: parseDirectiveList MozReview-Commit-ID: 6CYMr5GQ6rv
js/src/frontend/BinSource.cpp
--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -364,17 +364,17 @@ ASTReader::parseScope(SimpleTokenReader*
 
 bool
 ASTReader::parseBlockStatementAux(SimpleTokenReader* reader,
     const BinKind name,
     const SimpleTokenReader::BinFields& fields,
     UniquePtr<ParseNode>& out)
 {
     UniquePtr<ParseNode> body;
-    UniquePtr<ParseNode> directives;
+    UniquePtr<ParseNode> directives; // Ignored
     ScopeData scope(this->cx);
 
     for (auto field: fields) {
         switch (field) {
             case BinField::binjs_scope:
                 if (!this->parseScope(reader, scope)) {
                     return false;
                 }
@@ -2204,16 +2204,39 @@ ASTReader::parseExpressionAux(SimpleToke
             default:
                 return this->raiseError();
         }
 
         return true;
 }
 
 bool
+ASTReader::parseDirectiveList(SimpleTokenReader* reader, UniquePtr<ParseNode>& out) {
+    if (out) {
+        return this->raiseError();
+    }
+
+    uint32_t length;
+    SimpleTokenReader sub(this->cx);
+    if (!reader->readList(&length, &sub)) {
+        return false;
+    }
+
+    for (uint32_t i = 0; i < length; ++i) {
+        std::string string;
+        if (!this->readString(&sub, string)) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+
+bool
 ASTReader::readNumber(SimpleTokenReader* reader, Maybe<double>& out) {
     if (out) {
         return this->raiseError();
     }
 
     return reader->readMaybeF64(&out);
 }