зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1165486 - Detect with scopes at parse time using the static scope chain instead of treating it as a polluted global. (r=luke)
This commit is contained in:
Родитель
3a023fc067
Коммит
b9d919ceeb
|
@ -634,6 +634,15 @@ FunctionBox::FunctionBox(ExclusiveContext* cx, ObjectBox* traceListHead, JSFunct
|
||||||
FunctionBox* parent = outerpc->sc->asFunctionBox();
|
FunctionBox* parent = outerpc->sc->asFunctionBox();
|
||||||
if (parent && parent->inWith)
|
if (parent && parent->inWith)
|
||||||
inWith = true;
|
inWith = true;
|
||||||
|
} else {
|
||||||
|
// This is like the above case, but when inside eval.
|
||||||
|
//
|
||||||
|
// For example:
|
||||||
|
//
|
||||||
|
// with(o) { eval("(function() { g(); })();"); }
|
||||||
|
//
|
||||||
|
// In this case, the static scope chain tells us the presence of with.
|
||||||
|
inWith = outerpc->sc->asGlobalSharedContext()->inWith();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,14 @@ class GlobalSharedContext : public SharedContext
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool inWith() const {
|
||||||
|
for (StaticScopeIter<CanGC> it(context, topStaticScope_); !it.done(); it++) {
|
||||||
|
if (it.type() == StaticScopeIter<CanGC>::With)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FunctionBox : public ObjectBox, public SharedContext
|
class FunctionBox : public ObjectBox, public SharedContext
|
||||||
|
|
Загрузка…
Ссылка в новой задаче