--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -32,29 +32,41 @@ NewEmptyBindingData(JSContext* cx, LifoA
}
PodZero(bindings);
return bindings;
}
struct ScopeData MOZ_STACK_CLASS {
public:
ScopeData(JSContext* cx)
- : letNames(cx, Names(cx))
- , constNames(cx, Names(cx))
- , varNames(cx, Names(cx))
- , capturedNames(cx, NameBag(cx))
+ : letNames(cx)
+ , constNames(cx)
+ , varNames(cx)
+ , capturedNames(cx)
{ }
bool isSome() const {
- return hasDirectEval.isSome();
+ if (hasDirectEval.isSome()) {
+ MOZ_ASSERT(letNames.isSome());
+ MOZ_ASSERT(constNames.isSome());
+ MOZ_ASSERT(varNames.isSome());
+ MOZ_ASSERT(capturedNames.isSome());
+ return true;
+ } else {
+ MOZ_ASSERT(!letNames.isSome());
+ MOZ_ASSERT(!constNames.isSome());
+ MOZ_ASSERT(!varNames.isSome());
+ MOZ_ASSERT(!capturedNames.isSome());
+ return false;
+ }
}
Maybe<bool> hasDirectEval;
- Rooted<Names> letNames;
- Rooted<Names> constNames;
- Rooted<Names> varNames;
- Rooted<NameBag> capturedNames;
+ Rooted<Maybe<Names>> letNames;
+ Rooted<Maybe<Names>> constNames;
+ Rooted<Maybe<Names>> varNames;
+ Rooted<Maybe<NameBag>> capturedNames;
};
const std::string BINJS_SCOPE = "BINJS:Scope";
const std::string BINJS_VAR_NAME = "BINJS:VarDeclaredNames";
const std::string BINJS_LET_NAME = "BINJS:LetDeclaredNames";
const std::string BINJS_CONST_NAME = "BINJS:ConstDeclaredNames";
const std::string BINJS_CAPTURED_NAME = "BINJS:CapturedNames";
const std::string BINJS_DIRECT_EVAL = "BINJS:HasDirectEval";
@@ -245,40 +257,40 @@ ASTReader::parseBlockStatementAux(Simple
if (!body || !scope.isSome()) {
// FIXME: Once we have headers + header validation, this error check
// should become an assertion.
return this->raiseError();
}
// Probably not a good idea.
UniquePtr<LexicalScope::Data> bindings(
- NewEmptyBindingData<LexicalScope>(this->cx, this->alloc, scope.letNames.length() + scope.constNames.length())
+ NewEmptyBindingData<LexicalScope>(this->cx, this->alloc, scope.letNames->length() + scope.constNames->length())
);
if (!bindings) {
return this->raiseError();
}
BindingName* cursor = bindings->names;
- for (auto& name: scope.letNames) {
+ for (auto& name: *scope.letNames.get()) {
JS::Rooted<JSAtom*> atom(cx, AtomizeString(this->cx, name));
- bool isCaptured = scope.capturedNames.has(name);
+ bool isCaptured = scope.capturedNames->has(name);
BindingName binding(atom, isCaptured);
PodCopy(cursor, &binding, 1); // FIXME: Why does this work?
cursor++;
bindings->length++;
}
- for (auto& name: scope.constNames) {
+ for (auto& name: *scope.constNames.get()) {
JS::Rooted<JSAtom*> atom(cx, AtomizeString(this->cx, name));
- bool isCaptured = scope.capturedNames.has(name);
+ bool isCaptured = scope.capturedNames->has(name);
BindingName binding(atom, isCaptured);
PodCopy(cursor, &binding, 1); // FIXME: Why does this work?
cursor++;
bindings->length++;
}
- bindings->constStart = scope.letNames.length();
+ bindings->constStart = scope.letNames->length();
UniquePtr<ParseNode> result(new_<LexicalScopeNode>(bindings.release(), body.release()));
out = Move(result);
// FIXME: Validate capturedNames, etc.
return true;
}
bool