mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1141905 part 2. Make the 5-arg version of CreateScopeObjectsForScopeChain non-static so it can be called from multiple files, and move it to a possibly-saner location. r=shu
This commit is contained in:
parent
73238ec577
commit
48ae1e607a
@ -3197,48 +3197,10 @@ JS::GetSelfHostedFunction(JSContext *cx, const char *selfHostedName, HandleId id
|
||||
|
||||
static bool
|
||||
CreateScopeObjectsForScopeChain(JSContext *cx, AutoObjectVector &scopeChain,
|
||||
HandleObject dynamicTerminatingScope,
|
||||
MutableHandleObject dynamicScopeObj,
|
||||
MutableHandleObject staticScopeObj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0; i < scopeChain.length(); ++i) {
|
||||
assertSameCompartment(cx, scopeChain[i]);
|
||||
MOZ_ASSERT(!scopeChain[i]->is<GlobalObject>());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Construct With object wrappers for the things on this scope
|
||||
// chain and use the result as the thing to scope the function to.
|
||||
Rooted<StaticWithObject*> staticWith(cx);
|
||||
RootedObject staticEnclosingScope(cx);
|
||||
Rooted<DynamicWithObject*> dynamicWith(cx);
|
||||
RootedObject dynamicEnclosingScope(cx, dynamicTerminatingScope);
|
||||
for (size_t i = scopeChain.length(); i > 0; ) {
|
||||
staticWith = StaticWithObject::create(cx);
|
||||
if (!staticWith)
|
||||
return false;
|
||||
staticWith->initEnclosingNestedScope(staticEnclosingScope);
|
||||
staticEnclosingScope = staticWith;
|
||||
|
||||
dynamicWith = DynamicWithObject::create(cx, scopeChain[--i], dynamicEnclosingScope,
|
||||
staticWith, DynamicWithObject::NonSyntacticWith);
|
||||
if (!dynamicWith)
|
||||
return false;
|
||||
dynamicEnclosingScope = dynamicWith;
|
||||
}
|
||||
|
||||
dynamicScopeObj.set(dynamicEnclosingScope);
|
||||
staticScopeObj.set(staticEnclosingScope);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
CreateScopeObjectsForScopeChain(JSContext *cx, AutoObjectVector &scopeChain,
|
||||
MutableHandleObject dynamicScopeObj,
|
||||
MutableHandleObject staticScopeObj)
|
||||
{
|
||||
return CreateScopeObjectsForScopeChain(cx, scopeChain, cx->global(),
|
||||
return js::CreateScopeObjectsForScopeChain(cx, scopeChain, cx->global(),
|
||||
dynamicScopeObj, staticScopeObj);
|
||||
}
|
||||
|
||||
|
@ -2512,6 +2512,44 @@ js::GetObjectEnvironmentObjectForFunction(JSFunction *fun)
|
||||
return &env->as<DynamicWithObject>().object();
|
||||
}
|
||||
|
||||
bool
|
||||
js::CreateScopeObjectsForScopeChain(JSContext *cx, AutoObjectVector &scopeChain,
|
||||
HandleObject dynamicTerminatingScope,
|
||||
MutableHandleObject dynamicScopeObj,
|
||||
MutableHandleObject staticScopeObj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0; i < scopeChain.length(); ++i) {
|
||||
assertSameCompartment(cx, scopeChain[i]);
|
||||
MOZ_ASSERT(!scopeChain[i]->is<GlobalObject>());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Construct With object wrappers for the things on this scope
|
||||
// chain and use the result as the thing to scope the function to.
|
||||
Rooted<StaticWithObject*> staticWith(cx);
|
||||
RootedObject staticEnclosingScope(cx);
|
||||
Rooted<DynamicWithObject*> dynamicWith(cx);
|
||||
RootedObject dynamicEnclosingScope(cx, dynamicTerminatingScope);
|
||||
for (size_t i = scopeChain.length(); i > 0; ) {
|
||||
staticWith = StaticWithObject::create(cx);
|
||||
if (!staticWith)
|
||||
return false;
|
||||
staticWith->initEnclosingNestedScope(staticEnclosingScope);
|
||||
staticEnclosingScope = staticWith;
|
||||
|
||||
dynamicWith = DynamicWithObject::create(cx, scopeChain[--i], dynamicEnclosingScope,
|
||||
staticWith, DynamicWithObject::NonSyntacticWith);
|
||||
if (!dynamicWith)
|
||||
return false;
|
||||
dynamicEnclosingScope = dynamicWith;
|
||||
}
|
||||
|
||||
dynamicScopeObj.set(dynamicEnclosingScope);
|
||||
staticScopeObj.set(staticEnclosingScope);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
typedef HashSet<PropertyName *> PropertyNameSet;
|
||||
|
@ -1091,6 +1091,12 @@ ScopeIter::enclosingScope() const
|
||||
return *scope_;
|
||||
}
|
||||
|
||||
extern bool
|
||||
CreateScopeObjectsForScopeChain(JSContext *cx, AutoObjectVector &scopeChain,
|
||||
HandleObject dynamicTerminatingScope,
|
||||
MutableHandleObject dynamicScopeObj,
|
||||
MutableHandleObject staticScopeObj);
|
||||
|
||||
#ifdef DEBUG
|
||||
bool
|
||||
AnalyzeEntrainedVariables(JSContext *cx, HandleScript script);
|
||||
|
Loading…
Reference in New Issue
Block a user