WIP: Implemented parseExpressionStatementAux draft
authorDavid Teller <dteller@mozilla.com>
Fri, 04 Aug 2017 16:50:07 +0200
changeset 641372 f0c7a24aa199c7a3346430ce75fa482e8f2cde62
parent 641371 633a3245abdb39beed9d2b8d9959856c880c90c2
child 641373 533144912f72c98d07d2bed1d3bc377219b3efc5
push id72504
push userdteller@mozilla.com
push dateSun, 06 Aug 2017 22:28:40 +0000
milestone57.0a1
WIP: Implemented parseExpressionStatementAux MozReview-Commit-ID: 3rXlVIvcLML
js/src/frontend/BinSource.cpp
--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -79,18 +79,18 @@ const std::string BINJS_DIRECT_EVAL = "B
 
 class ASTReader: private JS::AutoGCRooter
 {
 public:
     ASTReader(JSContext* cx_, LifoAlloc& alloc_, const ReadOnlyCompileOptions& options)
         : AutoGCRooter(cx_, BINPARSER)
         , traceListHead(nullptr)
         , allocator(cx_, alloc_)
+        , options_(options)
         , cx(cx_)
-        , options_(options)
         , alloc(alloc_)
     { }
 
     static bool test() {
         // FIXME: Just a small hack to force the build system to
         // display undefined symbols.
         ASTReader foo(nullptr, *static_cast<LifoAlloc*>(nullptr), *static_cast<ReadOnlyCompileOptions*>(nullptr));
         UniquePtr<ParseNode> out;
@@ -1980,16 +1980,44 @@ ASTReader::parseExpression(SimpleTokenRe
         default:
             return this->raiseError();
     }
 
     return false;
 }
 
 bool
+ASTReader::parseExpressionStatementAux(SimpleTokenReader* reader, const BinKind kind, const SimpleTokenReader::BinFields& fields, UniquePtr<ParseNode>& out) {
+    MOZ_ASSERT(kind == BinKind::expression_statement);
+    if (out) {
+        return this->raiseError();
+    }
+
+    UniquePtr<ParseNode> result;
+    for (auto field: fields) {
+        switch (field) {
+            case BinField::expression:
+                if (!this->parseExpression(reader, result)) {
+                    return false;
+                }
+                break;
+            default:
+                return this->raiseError();
+        }
+    }
+
+    if (!result) {
+        return this->raiseError();
+    }
+
+    out = Move(result);
+    return false;
+}
+
+bool
 ASTReader::readNumber(SimpleTokenReader* reader, Maybe<double>& out) {
     if (out) {
         return this->raiseError();
     }
 
     return reader->readMaybeF64(&out);
 }