WIP: readString(MutableHandleString) draft
authorDavid Teller <dteller@mozilla.com>
Sun, 06 Aug 2017 16:52:07 +0200
changeset 641392 546310aeaaed167db4503bc705eb46dcbc9bc5fb
parent 641391 0bd1e89ab3b2d273f0329b9fd5848b0b7dcff120
child 641393 16cc2644af05396705f03ba1ccc644391277f9e0
push id72504
push userdteller@mozilla.com
push dateSun, 06 Aug 2017 22:28:40 +0000
milestone57.0a1
WIP: readString(MutableHandleString) MozReview-Commit-ID: Ip05eI45IrW
js/src/frontend/BinSource.cpp
--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -2449,16 +2449,40 @@ ASTReader::parsePatternAux(SimpleTokenRe
             // For the moment, we only support identifiers.
             return this->raiseError();
     }
 
     return true;
 }
 
 bool
+ASTReader::readString(SimpleTokenReader* reader, MutableHandleString out) {
+    if (out) {
+        return this->raiseError();
+    }
+
+    Maybe<std::string> string;
+    if (!this->readString(reader, string)) {
+        return false;
+    }
+
+    if (!string) {
+        return true;
+    }
+
+    RootedAtom atom(cx, Atomize(this->cx, string->data(), string->length()));
+    if (!atom) {
+        return false;
+    }
+
+    out.set(Move(atom));
+    return true;
+}
+
+bool
 ASTReader::readString(SimpleTokenReader* reader, MutableHandle<PropertyName*> out) {
     if (out) {
         return this->raiseError();
     }
 
     RootedAtom atom(cx);
 
     if (!this->readString(reader, &atom)) {